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
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 // ************************************************************************* //
Foam::dynamicCodeContext::libs
const string & libs() const
Return the code-libs.
Definition: dynamicCodeContext.H:102
Foam::dynamicCodeContext::localCode_
string localCode_
Optional "localCode" entry.
Definition: dynamicCodeContext.H:60
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::dynamicCodeContext::dict
const dictionary & dict() const
Return the parent dictionary context.
Definition: dynamicCodeContext.H:84
Foam::dynamicCodeContext::libs_
string libs_
Optional "codeLib" entry.
Definition: dynamicCodeContext.H:69
Foam::dynamicCodeContext
Encapsulation of dynamic code dictionaries.
Definition: dynamicCodeContext.H:49
Foam::dynamicCodeContext::include
const string & include() const
Return the code-includes.
Definition: dynamicCodeContext.H:90
Foam::dynamicCodeContext::sha1_
SHA1Digest sha1_
Calculated SHA1Digest.
Definition: dynamicCodeContext.H:72
Foam::dynamicCodeContext::addLineDirective
static void addLineDirective(string &, const label lineNum, const fileName &name)
Helper: add #line directive.
Definition: dynamicCodeContext.C:128
Foam::dynamicCodeContext::dict_
const dictionary & dict_
The parent dictionary context.
Definition: dynamicCodeContext.H:54
SHA1Digest.H
Foam::label
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
Foam::dynamicCodeContext::code
const string & code() const
Return the code.
Definition: dynamicCodeContext.H:108
Foam::dynamicCodeContext::sha1
const SHA1Digest & sha1() const
Return SHA1 digest calculated from include, options, code.
Definition: dynamicCodeContext.H:120
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::dynamicCodeContext::options
const string & options() const
Return the code-options.
Definition: dynamicCodeContext.H:96
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::SHA1Digest
The SHA1 message digest.
Definition: SHA1Digest.H:62
Foam::dynamicCodeContext::localCode
const string & localCode() const
Return the local (file-scope) code.
Definition: dynamicCodeContext.H:114
Foam::dynamicCodeContext::include_
string include_
Optional "codeInclude" entry.
Definition: dynamicCodeContext.H:63
dictionary.H
Foam::dynamicCodeContext::dynamicCodeContext
dynamicCodeContext(const dictionary &)
Construct from a dictionary.
Definition: dynamicCodeContext.C:33
Foam::dynamicCodeContext::options_
string options_
Optional "codeOptions" entry.
Definition: dynamicCodeContext.H:66
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Foam::dynamicCodeContext::code_
string code_
Mandatory "code" entry.
Definition: dynamicCodeContext.H:57