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]);
129 dynCode.setMakeOptions(context.options() +
"\n\n" + context.libs());
134 dynCode.setFilterVariable(
"verbose",
"true");
136 << context.sha1() <<
endl;
145 const word& templateName,
146 const word& instantiatedName,
150 codedBase(name(instantiatedName), optionsDict(templateName)),
151 templateName_(templateName),
152 substitutions_(substitutions)
compileTemplate(const word &templateName, const word &instantiatedName, const List< Pair< word >> &substitutions)
Construct from name and dictionary.
#define forAll(list, i)
Loop across all elements in list.
A class for handling file names.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
word codeTemplateC(const word &baseTypeName) const
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual const word & codeName() const
Name of the dynamically generated CodedType.
static fileName resolveTemplate(const fileName &templateName)
Resolve code-template via the codeTemplateEnvName.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
A class for handling words, derived from string.
codedBase()
Construct null.
void updateLibrary() const
Update library as required.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.