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-2016 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  //- Optional "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 
76 public:
77 
78  // Constructors
79 
80  //- Construct from a dictionary
82 
83 
84  // Member functions
85 
86  //- Return the parent dictionary context
87  const dictionary& dict() const
88  {
89  return dict_;
90  }
91 
92  //- Return the code-includes
93  const string& include() const
94  {
95  return include_;
96  }
97 
98  //- Return the code-options
99  const string& options() const
100  {
101  return options_;
102  }
103 
104  //- Return the code-libs
105  const string& libs() const
106  {
107  return libs_;
108  }
109 
110  //- Return the code
111  const string& code() const
112  {
113  return code_;
114  }
115 
116  //- Return the local (file-scope) code
117  const string& localCode() const
118  {
119  return localCode_;
120  }
121 
122  //- Return SHA1 digest calculated from include, options, code
123  const SHA1Digest& sha1() const
124  {
125  return sha1_;
126  }
127 
128  //- Helper: add \#line directive
129  static void addLineDirective
130  (
131  string&,
132  const label lineNum,
133  const fileName& name
134  );
135 };
136 
137 
138 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
139 
140 } // End namespace Foam
141 
142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 
144 #endif
145 
146 // ************************************************************************* //
const string & localCode() const
Return the local (file-scope) code.
const string & include() const
Return the code-includes.
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
A class for handling file names.
Definition: fileName.H:69
const SHA1Digest & sha1() const
Return SHA1 digest calculated from include, options, code.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
static void addLineDirective(string &, const label lineNum, const fileName &name)
Helper: add #line directive.
The SHA1 message digest.
Definition: SHA1Digest.H:62
const dictionary & dict() const
Return the parent dictionary context.
dynamicCodeContext(const dictionary &)
Construct from a dictionary.
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
const string & libs() const
Return the code-libs.
Encapsulation of dynamic code dictionaries.
const string & options() const
Return the code-options.
const string & code() const
Return the code.
Namespace for OpenFOAM.