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-2024 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  //- Keywords associated with source code
48  static const wordList codeKeys;
49 
50  //- Name of the dictionary variables in the source code
51  static const wordList codeDictVars;
52 
53  //- Name of the class Thermo basicThermo is instantiated on
54  const word templateName_;
55 
56  //- List of template argument substitutions
57  const List<Pair<word>> substitutions_;
58 
59  const dictionary dict_;
60 
61 
62  // Private Member Functions
63 
64  fileName name(const word& instantiatedName) const;
65 
66  dictionary optionsDict
67  (
68  const word& templateName
69  ) const;
70 
71  void setFilterVariable
72  (
73  dynamicCode& dynCode,
74  const dynamicCodeContext& context,
75  const Pair<word>& substitution
76  ) const;
77 
78  //- Adapt the context for the current object
79  virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
80 
81 
82 public:
83 
84  // Constructors
85 
86  //- Construct from name and dictionary
88  (
89  const word& templateName,
90  const word& instantiatedName,
91  const List<Pair<word>>& substitutions
92  );
93 };
94 
95 
96 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
97 
98 } // End namespace Foam
99 
100 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
101 
102 #endif
103 
104 // ************************************************************************* //
Base class for function objects and boundary conditions using dynamic code.
Definition: codedBase.H:52
compileTemplate(const word &templateName, const word &instantiatedName, const List< Pair< word >> &substitutions)
Construct from name and dictionary.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Encapsulation of dynamic code dictionaries.
Tools for handling dynamic code compilation.
Definition: dynamicCode.H:57
A class for handling file names.
Definition: fileName.H:82
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.