34 const Foam::wordList Foam::compileTemplate::codeKeys(wordList::null());
36 const Foam::wordList Foam::compileTemplate::codeDictVars(wordList::null());
43 const word& instantiatedName
46 fileName templateFileName(instantiatedName);
47 templateFileName.replaceAll(
',',
'_');
48 templateFileName.replaceAll(
'<',
'_');
49 templateFileName.replaceAll(
'>',
'_');
51 return templateFileName;
57 const word& templateName
61 if (!optionsFile.good())
64 <<
"Failed to open dictionary file " << templateName
68 return dictionary(optionsFile);
72 void Foam::compileTemplate::setFilterVariable
75 const dynamicCodeContext& context,
76 const Pair<word>& substitution
79 const word&
name(substitution.first());
80 word
type(substitution.second());
81 const word typeRenameMapName(
name +
"Renamed");
83 if (dict_.found(
name))
85 const HashSet<word> types(dict_.lookup(
name));
86 if (!types.found(
type))
89 <<
"Unknown " <<
name <<
" type " <<
type <<
nl
90 <<
"Supported " <<
name <<
" types: " << types
95 if (dict_.found(typeRenameMapName))
97 const HashTable<word> renameMap
99 dict_.lookup(typeRenameMapName)
102 if (renameMap.found(
type))
108 dynCode.setFilterVariable(
name,
type);
112 void Foam::compileTemplate::prepare
114 dynamicCode& dynCode,
115 const dynamicCodeContext& context
118 dynCode.setFilterVariable(
"typeName", codeName());
122 setFilterVariable(dynCode, context, substitutions_[i]);
126 dynCode.addCompileFile(codeTemplateC(templateName_));
129 dynCode.setMakeOptions(context.options() +
"\n\n" + context.libs());
132 dynCode.setFilterVariable(
"verbose",
Foam::name(
bool(debug)));
136 Info<<
"compile " << codeName() <<
" sha1: " << context.sha1() <<
endl;
145 const word& templateName,
146 const word& instantiatedName,
152 name(instantiatedName),
153 optionsDict(templateName),
157 templateName_(templateName),
158 substitutions_(substitutions),
159 dict_(optionsDict(templateName))
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
#define forAll(list, i)
Loop across all elements in list.
Base class for function objects and boundary conditions using dynamic code.
bool updateLibrary(const dictionary &dict) const
Update library from given updated dictionary as required.
compileTemplate(const word &templateName, const word &instantiatedName, const List< Pair< word >> &substitutions)
Construct from name and dictionary.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
static fileName resolveTemplate(const fileName &templateName)
Resolve code-template via the codeTemplateEnvName.
A class for handling file names.
A class for handling words, derived from string.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.