36 const word& instantiatedName
39 fileName templateFileName(instantiatedName);
40 templateFileName.replaceAll(
',',
'_');
41 templateFileName.replaceAll(
'<',
'_');
42 templateFileName.replaceAll(
'>',
'_');
44 return templateFileName;
50 const word& templateName
54 if (!optionsFile.good())
57 <<
"Failed to open dictionary file " << templateName
61 return dictionary(optionsFile);
65 void Foam::compileTemplate::setFilterVariable
68 const dynamicCodeContext& context,
69 const Pair<word>& substitution
72 const word&
name(substitution.first());
73 word
type(substitution.second());
74 const word typeRenameMapName(
name +
"Renamed");
76 if (context.dict().found(
name))
78 const HashSet<word> types(context.dict().lookup(
name));
79 if (!types.found(
type))
82 <<
"Unknown " <<
name <<
" type " <<
type <<
nl
83 <<
"Supported " <<
name <<
" types: " << types
88 if (context.dict().found(typeRenameMapName))
90 const HashTable<word> renameMap
92 context.dict().lookup(typeRenameMapName)
95 if (renameMap.found(
type))
101 dynCode.setFilterVariable(
name,
type);
105 void Foam::compileTemplate::prepare
107 dynamicCode& dynCode,
108 const dynamicCodeContext& context
111 dynCode.setFilterVariable(
"typeName", codeName());
115 setFilterVariable(dynCode, context, substitutions_[i]);
119 dynCode.addCompileFile(codeTemplateC(templateName_));
122 dynCode.setMakeOptions(context.options() +
"\n\n" + context.libs());
125 dynCode.setFilterVariable(
"verbose",
Foam::name(
bool(debug)));
129 Info<<
"compile " << codeName() <<
" sha1: " << context.sha1() <<
endl;
138 const word& templateName,
139 const word& instantiatedName,
143 codedBase(
name(instantiatedName), optionsDict(templateName)),
144 templateName_(templateName),
145 substitutions_(substitutions)
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.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Base class for function objects and boundary conditions using dynamic code.
void updateLibrary() const
Update library as required.
compileTemplate(const word &templateName, const word &instantiatedName, const List< Pair< word >> &substitutions)
Construct from name and dictionary.
A list of keyword definitions, which are a keyword followed by any number of values (e....
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 bool)
Return a word representation of a bool.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.