dynamicCodeContext.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) 2011-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 Class
25  Foam::dynamicCodeContext
26 
27 Description
28  Encapsulation of dynamic code dictionaries
29 
30 SourceFiles
31  dynamicCodeContext.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef dynamicCodeContext_H
36 #define dynamicCodeContext_H
37 
38 #include "dictionary.H"
39 #include "HashTable.H"
40 #include "SHA1Digest.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 /*---------------------------------------------------------------------------*\
48  Class dynamicCodeContext Declaration
49 \*---------------------------------------------------------------------------*/
50 
52 {
53  // Private Data
54 
55  //- The parent dictionary context
56  const dictionary& dict_;
57 
58  //- Code entries
59  HashTable<string> code_;
60 
61  //- Optional "codeOptions" entry
62  string options_;
63 
64  //- Optional "codeLibs" entry
65  string libs_;
66 
67  //- Calculated SHA1Digest
68  SHA1Digest sha1_;
69 
70 
71  // Private Member Functions
72 
73  //- Add a \#line directive to the start of the given source string that
74  // compilation messages are meaningful
75  static void addLineDirective
76  (
77  string&,
78  const label lineNum,
79  const fileName& name
80  );
81 
82 
83 public:
84 
85  // Constructors
86 
87  //- Construct from a dictionary and lists of which entries correspond
88  // to code
90  (
91  const dictionary& dict,
92  const wordList& codeKeys,
93  const wordList& codeDictVars
94  );
95 
96 
97  // Member Functions
98 
99  //- Return the parent dictionary context
100  const dictionary& dict() const
101  {
102  return dict_;
103  }
104 
105  //- Return the code table
106  const HashTable<string>& code() const
107  {
108  return code_;
109  }
110 
111  //- Return the code-options
112  const string& options() const
113  {
114  return options_;
115  }
116 
117  //- Return the code-libs
118  const string& libs() const
119  {
120  return libs_;
121  }
122 
123  //- Return SHA1 digest calculated from include, options, code
124  const SHA1Digest& sha1() const
125  {
126  return sha1_;
127  }
128 };
129 
130 
131 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
132 
133 } // End namespace Foam
134 
135 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
136 
137 #endif
138 
139 // ************************************************************************* //
An STL-conforming hash table.
Definition: HashTable.H:127
The SHA1 message digest.
Definition: SHA1Digest.H:63
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Encapsulation of dynamic code dictionaries.
const HashTable< string > & code() const
Return the code table.
const dictionary & dict() const
Return the parent dictionary context.
const string & options() const
Return the code-options.
const string & libs() const
Return the code-libs.
const SHA1Digest & sha1() const
Return SHA1 digest calculated from include, options, code.
dynamicCodeContext(const dictionary &dict, const wordList &codeKeys, const wordList &codeDictVars)
Construct from a dictionary and lists of which entries correspond.
A class for handling file names.
Definition: fileName.H:82
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39