substitutionModel Class Referenceabstract

Base class for substitution models. More...

Inheritance diagram for substitutionModel:
Collaboration diagram for substitutionModel:

Public Member Functions

 TypeName ("substitutionModel")
 Runtime type information. More...
 
 declareRunTimeSelectionTable (autoPtr, substitutionModel, dictionary,(const dictionary &dict, const Time &time),(dict, time))
 
 substitutionModel (const dictionary &dict, const Time &time)
 Constructor. More...
 
virtual ~substitutionModel ()=default
 Destructor. More...
 
virtual bool update ()
 Update model local data. More...
 
virtual bool valid (const word &keyName) const =0
 Return true of model applies to this keyName. More...
 
virtual bool apply (const word &key, string &buffer) const =0
 Apply substitutions to this string buffer. More...
 
virtual wordList keys () const =0
 Return a word list of the keys. More...
 

Static Public Member Functions

static string keyify (const word &w)
 Return a key representation from a word. More...
 
static word cleanKey (const string &str)
 Clean the key text. More...
 
static wordList getKeys (string &buffer)
 Return all keys from a string buffer. More...
 
static void addBuiltinStr (const word &key, const string &value)
 Add a builtin to the hash table - does not overwrite. More...
 
template<class Type >
static void addBuiltin (const word &key, const Type &value)
 Add a builtin to the hash table - does not overwrite. More...
 
static bool containsBuiltin (const word &key)
 Return true if key is builtin. More...
 
static void setBuiltinStr (const word &key, const string &value)
 Set a builtin to the hash table. More...
 
template<class Type >
static void setBuiltin (const word &key, const Type &value)
 Set a builtin to the hash table. More...
 
static bool replaceBuiltin (const word &key, string &str)
 Replace key in string. More...
 
static bool replaceBuiltin (string &str)
 Replace all occurrences of key in string. More...
 
static void writeBuiltins (Ostream &os)
 Write all builtins to stream. More...
 
static autoPtr< substitutionModelNew (const dictionary &dict, const Time &time)
 Return a reference to the selected substitution model. More...
 

Static Public Attributes

static const word KEY_BEGIN = "{{"
 Keyword starting characters. More...
 
static const word KEY_END = "}}"
 Keyword ending characters. More...
 
static HashTable< stringbuiltin_
 Built-in substitutions. More...
 

Protected Attributes

const dictionary dict_
 Construction dictionary. More...
 
const Timetime_
 Reference to the time database. More...
 

Detailed Description

Base class for substitution models.

Provides a static hash table for builtin keyword-value pairs and functions to manipulate/interact.

Source files

Definition at line 52 of file substitutionModel.H.

Constructor & Destructor Documentation

◆ substitutionModel()

substitutionModel ( const dictionary dict,
const Time time 
)

Constructor.

Definition at line 150 of file substitutionModel.C.

◆ ~substitutionModel()

virtual ~substitutionModel ( )
virtualdefault

Destructor.

Member Function Documentation

◆ keyify()

Foam::string keyify ( const word w)
static

Return a key representation from a word.

Definition at line 38 of file substitutionModel.C.

References substitutionModel::KEY_BEGIN, and substitutionModel::KEY_END.

◆ cleanKey()

Foam::word cleanKey ( const string str)
static

Clean the key text.

Definition at line 44 of file substitutionModel.C.

References Foam::stringOps::trim(), and Foam::stringOps::upper().

Here is the call graph for this function:

◆ getKeys()

Foam::wordList getKeys ( string buffer)
static

Return all keys from a string buffer.

Also cleans the key strings in the buffer

Definition at line 50 of file substitutionModel.C.

References HashSet< Key, Hash >::insert(), k, string::length(), Foam::pos(), Foam::pos0(), and HashTable< T, Key, Hash >::toc().

Referenced by foamReport::parseTemplate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addBuiltinStr()

void addBuiltinStr ( const word key,
const string value 
)
static

Add a builtin to the hash table - does not overwrite.

Definition at line 85 of file substitutionModel.C.

References Foam::glTF::key().

Referenced by substitutionModel::addBuiltin(), and foamReport::setStaticBuiltins().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addBuiltin()

void addBuiltin ( const word key,
const Type &  value 
)
static

Add a builtin to the hash table - does not overwrite.

Definition at line 22 of file substitutionModelTemplates.C.

References substitutionModel::addBuiltinStr(), Foam::glTF::key(), and OStringStream::str().

Referenced by foamReport::setStaticBuiltins().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ containsBuiltin()

bool containsBuiltin ( const word key)
static

Return true if key is builtin.

Definition at line 94 of file substitutionModel.C.

References Foam::glTF::key().

Here is the call graph for this function:

◆ setBuiltinStr()

void setBuiltinStr ( const word key,
const string value 
)
static

Set a builtin to the hash table.

Definition at line 101 of file substitutionModel.C.

References Foam::glTF::key().

Referenced by foamReport::setDynamicBuiltins().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setBuiltin()

void setBuiltin ( const word key,
const Type &  value 
)
static

Set a builtin to the hash table.

Definition at line 31 of file substitutionModelTemplates.C.

References Foam::glTF::key(), and OStringStream::str().

Referenced by foamReport::setDynamicBuiltins().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ replaceBuiltin() [1/2]

bool replaceBuiltin ( const word key,
string str 
)
static

Replace key in string.

Definition at line 110 of file substitutionModel.C.

References Foam::glTF::key(), and string::replaceAll().

Referenced by foamReport::apply().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ replaceBuiltin() [2/2]

bool replaceBuiltin ( string str)
static

Replace all occurrences of key in string.

Definition at line 122 of file substitutionModel.C.

References forAllConstIters(), and string::replaceAll().

Here is the call graph for this function:

◆ writeBuiltins()

void writeBuiltins ( Ostream os)
static

Write all builtins to stream.

Definition at line 138 of file substitutionModel.C.

References Foam::nl, and os().

Referenced by foamReport::write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TypeName()

TypeName ( "substitutionModel"  )

Runtime type information.

◆ declareRunTimeSelectionTable()

declareRunTimeSelectionTable ( autoPtr  ,
substitutionModel  ,
dictionary  ,
(const dictionary &dict, const Time &time)  ,
(dict, time)   
)

◆ New()

Foam::autoPtr< Foam::substitutionModel > New ( const dictionary dict,
const Time time 
)
static

Return a reference to the selected substitution model.

Definition at line 27 of file substitutionModelNew.C.

References dict, Foam::endl(), Foam::exit(), Foam::FatalIOError, FatalIOErrorInLookup, and Foam::Info.

Referenced by foamReport::read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update()

virtual bool update ( )
inlinevirtual

Update model local data.

Reimplemented in functionObjectValue.

Definition at line 221 of file substitutionModel.H.

◆ valid()

virtual bool valid ( const word keyName) const
pure virtual

Return true of model applies to this keyName.

Implemented in dictionaryValue, fileRegEx, functionObjectValue, userValue, and environmentVariable.

◆ apply()

virtual bool apply ( const word key,
string buffer 
) const
pure virtual

Apply substitutions to this string buffer.

Implemented in dictionaryValue, fileRegEx, functionObjectValue, userValue, and environmentVariable.

◆ keys()

virtual wordList keys ( ) const
pure virtual

Return a word list of the keys.

Implemented in dictionaryValue, fileRegEx, functionObjectValue, userValue, and environmentVariable.

Member Data Documentation

◆ KEY_BEGIN

const Foam::word KEY_BEGIN = "{{"
static

Keyword starting characters.

Definition at line 61 of file substitutionModel.H.

Referenced by substitutionModel::keyify().

◆ KEY_END

const Foam::word KEY_END = "}}"
static

Keyword ending characters.

Definition at line 66 of file substitutionModel.H.

Referenced by substitutionModel::keyify().

◆ builtin_

Foam::HashTable< Foam::string > builtin_
static

Built-in substitutions.

Definition at line 71 of file substitutionModel.H.

◆ dict_

const dictionary dict_
protected

Construction dictionary.

Definition at line 158 of file substitutionModel.H.

◆ time_

const Time& time_
protected

Reference to the time database.

Definition at line 163 of file substitutionModel.H.


The documentation for this class was generated from the following files: