dynamicCodeContext.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2012 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 "SHA1Digest.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 /*---------------------------------------------------------------------------*\
47  Class dynamicCodeContext Declaration
48 \*---------------------------------------------------------------------------*/
49 
51 {
52  // Private data
53 
54  //- The parent dictionary context
55  const dictionary& dict_;
56 
57  //- Mandatory "code" entry
58  string code_;
59 
60  //- Optional "localCode" entry
61  string localCode_;
62 
63  //- Optional "codeInclude" entry
64  string include_;
65 
66  //- Optional "codeOptions" entry
67  string options_;
68 
69  //- Optional "codeLib" entry
70  string libs_;
71 
72  //- Calculated SHA1Digest
73  SHA1Digest sha1_;
74 
75 public:
76 
77  // Constructors
78 
79  //- Construct from a dictionary
81 
82  // Member functions
83 
84  //- Return the parent dictionary context
85  const dictionary& dict() const
86  {
87  return dict_;
88  }
89 
90  //- Return the code-includes
91  const string& include() const
92  {
93  return include_;
94  }
95 
96  //- Return the code-options
97  const string& options() const
98  {
99  return options_;
100  }
101 
102  //- Return the code-libs
103  const string& libs() const
104  {
105  return libs_;
106  }
107 
108  //- Return the code
109  const string& code() const
110  {
111  return code_;
112  }
113 
114  //- Return the local (file-scope) code
115  const string& localCode() const
116  {
117  return localCode_;
118  }
119 
120  //- Return SHA1 digest calculated from include, options, code
121  const SHA1Digest& sha1() const
122  {
123  return sha1_;
124  }
125 
126  //- Helper: add \#line directive
127  static void addLineDirective
128  (
129  string&,
130  const label lineNum,
131  const fileName& name
132  );
133 
134 };
135 
136 
137 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
138 
139 } // End namespace Foam
140 
141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142 
143 #endif
144 
145 // ************************************************************************* //
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
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
const string & options() const
Return the code-options.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
const SHA1Digest & sha1() const
Return SHA1 digest calculated from include, options, code.
Namespace for OpenFOAM.
const string & include() const
Return the code-includes.
Encapsulation of dynamic code dictionaries.
dynamicCodeContext(const dictionary &)
Construct from a dictionary.
const dictionary & dict() const
Return the parent dictionary context.
const string & localCode() const
Return the local (file-scope) code.
const string & libs() const
Return the code-libs.
A class for handling file names.
Definition: fileName.H:69
static void addLineDirective(string &, const label lineNum, const fileName &name)
Helper: add #line directive.
const string & code() const
Return the code.
The SHA1 message digest.
Definition: SHA1Digest.H:62