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);
103 const word typeBase(
name +
"Base");
104 if (context.dict().found(typeBase))
106 const HashTable<word> typeToBaseMap(context.dict().lookup(typeBase));
107 dynCode.setFilterVariable(typeBase, typeToBaseMap[
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());
134 dynCode.setFilterVariable(
"verbose",
"true");
135 Info<<
"compile " << codeName() <<
" sha1: "
136 << context.sha1() <<
endl;
145 const word& templateName,
146 const word& instantiatedName,
150 codedBase(
name(instantiatedName), optionsDict(templateName)),
151 templateName_(templateName),
152 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 complex &)
Return a string representation of a complex.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.