compileTemplate.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2021 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #ifndef compileTemplate_H
27 #define compileTemplate_H
28 
29 #include "codedBase.H"
30 #include "dynamicCode.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 /*---------------------------------------------------------------------------*\
38  Class compileTemplate Declaration
39 \*---------------------------------------------------------------------------*/
40 
42 :
43  public codedBase
44 {
45  // Private Member Data
46 
47  //- Name of the class Thermo basicThermo is instantiated on
48  const word templateName_;
49 
50  //- List of template argument substitutions
51  const List<Pair<word>> substitutions_;
52 
53 
54  // Private Member Functions
55 
56  fileName name(const word& instantiatedName) const;
57 
58  dictionary optionsDict
59  (
60  const word& templateName
61  ) const;
62 
63  void setFilterVariable
64  (
65  dynamicCode& dynCode,
66  const dynamicCodeContext& context,
67  const Pair<word>& substitution
68  ) const;
69 
70  //- Get the keywords associated with source code
71  virtual wordList codeKeys() const
72  {
73  return wordList::null();
74  }
75 
76  //- Adapt the context for the current object
77  virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
78 
79  //- Clear the ptr to the redirected object
80  virtual void clearRedirect() const
81  {}
82 
83 
84 public:
85 
86  // Constructors
87 
88  //- Construct from name and dictionary
90  (
91  const word& templateName,
92  const word& instantiatedName,
93  const List<Pair<word>>& substitutions
94  );
95 };
96 
97 
98 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
99 
100 } // End namespace Foam
101 
102 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
103 
104 #endif
105 
106 // ************************************************************************* //
compileTemplate(const word &templateName, const word &instantiatedName, const List< Pair< word >> &substitutions)
Construct from name and dictionary.
A class for handling file names.
Definition: fileName.H:79
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
static const List< word > & null()
Return a null List.
Definition: ListI.H:118
A class for handling words, derived from string.
Definition: word.H:59
Base class for function objects and boundary conditions using dynamic code.
Definition: codedBase.H:53
Tools for handling dynamic code compilation.
Definition: dynamicCode.H:56
Encapsulation of dynamic code dictionaries.
Namespace for OpenFOAM.