CodedBase.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) 2020 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 Class
25  Foam::CodedBase
26 
27 Description
28  Templated wrapper class to reduce code duplication and simplify maintenance
29  of coded classes.
30 
31 See also
32  Foam::codeBase
33 
34 SourceFiles
35  CodedBase.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef CodedBase_H
40 #define CodedBase_H
41 
42 #include "codedBase.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 template<class CodedType>
50 class CodedBase
51 :
52  public codedBase
53 {
54  // Private static data
55 
56  //- The keywords associated with source code
57  static const wordList codeKeys_;
58 
59  //- Name of the dynamically generated CodedType
60  const word codeName_;
61 
62  //- Dictionary contents for the CodedType
63  const dictionary dict_;
64 
65 
66  // Private Member Functions
67 
68  //- Get the keywords associated with source code
69  virtual const wordList& codeKeys() const;
70 
71  //- Return a description (type + name) for the output
72  virtual string description() const;
73 
74 
75 public:
76 
77  // Static Data Members
78 
79  //- Name of the C code template to be used
80  static const word codeTemplateC;
81 
82  //- Name of the H code template to be used
83  static const word codeTemplateH;
84 
85 
86  // Constructors
87 
88  //- Construct null
89  CodedBase()
90  {}
91 
92  //- Construct from dictionary
93  CodedBase(const dictionary& dict);
94 
95  //- Copy constructor
97 
98 
99  //- Destructor
100  virtual ~CodedBase();
101 
102 
103  // Member Functions
104 
105  //- Name of the dynamically generated CodedType
106  virtual const word& codeName() const;
107 
108  //- Get the dictionary to initialize the codeContext
109  virtual const dictionary& codeDict() const;
110 
111  void writeCode(Ostream& os) const;
112 };
113 
114 
115 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
116 
117 } // End namespace Foam
118 
119 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
120 
121 #ifdef NoRepository
122  #include "CodedBase.C"
123 #endif
124 
125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 
127 #endif
128 
129 // ************************************************************************* //
dictionary dict
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
virtual const dictionary & codeDict() const
Get the dictionary to initialize the codeContext.
Definition: CodedBase.C:93
virtual const word & codeName() const
Name of the dynamically generated CodedType.
Definition: CodedBase.C:85
static const word codeTemplateC
Name of the C code template to be used.
Definition: CodedBase.H:79
A class for handling words, derived from string.
Definition: word.H:59
Templated wrapper class to reduce code duplication and simplify maintenance of coded classes...
Definition: CodedBase.H:49
Base class for function objects and boundary conditions using dynamic code.
Definition: codedBase.H:53
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
static const word codeTemplateH
Name of the H code template to be used.
Definition: CodedBase.H:82
CodedBase()
Construct null.
Definition: CodedBase.H:88
virtual ~CodedBase()
Destructor.
Definition: CodedBase.C:78
void writeCode(Ostream &os) const
Definition: CodedBase.C:100
Namespace for OpenFOAM.