codeIncludeEntry.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) 2023-2026 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::functionEntries::codeIncludeEntry
26 
27 Description
28  Specify an include file or list of files for \#calc within \#codeBlock
29 
30  For example if functions from transform.H are used in the \#calc expression
31  \verbatim
32  angleOfAttack 5; // degs
33 
34  #codeBlock
35  angle #calc "-degToRad($angleOfAttack)";
36 
37  #codeInclude "transform.H"
38  liftDir #calc "transform(Ry($angle), vector(0, 0, 1))";
39  dragDir #calc "transform(Ry($angle), vector(1, 0, 0))";
40  #endCodeBlock
41  \endverbatim
42 
43  The usual expansion of environment variables and other constructs
44  (eg, the \c ~OpenFOAM/ expansion) is retained.
45 
46  If multiple include files are required multiple #codeInclude entries can
47  be used or more conveniently a list of file names specified, e.g.
48  \verbatim
49  #codeInclude ("transform.H" "Field.H")
50  \endverbatim
51  or formatted in a column if is a larger number of include files required:
52  \verbatim
53  #codeInclude
54  (
55  "transform.H"
56  "Field.H"
57  )
58  \endverbatim
59 
60 See also
61  Foam::functionEntries::calcEntry
62 
63 SourceFiles
64  codeIncludeEntry.C
65 
66 \*---------------------------------------------------------------------------*/
67 
68 #ifndef codeIncludeEntry_H
69 #define codeIncludeEntry_H
70 
71 #include "functionEntry.H"
72 
73 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
74 
75 namespace Foam
76 {
77 namespace functionEntries
78 {
79 
80 /*---------------------------------------------------------------------------*\
81  Class codeIncludeEntry Declaration
82 \*---------------------------------------------------------------------------*/
83 
84 class codeIncludeEntry
85 :
86  public functionEntry
87 {
88  // Private data
89 
90  //- List of file names
91  List<fileName> fNames_;
92 
93 
94 public:
95 
96  //- Runtime type information
97  FunctionTypeName("#codeInclude");
98 
99 
100  // Constructors
101 
102  //- Construct from line number, dictionary and Istream
104  (
105  const label lineNumber,
106  const dictionary& parentDict,
107  Istream& is
108  );
109 
110  //- Copy construct
111  codeIncludeEntry(const codeIncludeEntry&) = default;
112 
113  //- Clone
114  virtual autoPtr<entry> clone(const dictionary&) const
115  {
116  return autoPtr<entry>(new codeIncludeEntry(*this));
117  }
118 
119 
120  // Member Functions
121 
122  //- Execute the functionEntry in a sub-dict context
123  virtual bool execute(dictionary& parentDict, Istream&);
124 
125  //- Return the include file names
126  const List<fileName>& fileNames() const
127  {
128  return fNames_;
129  }
130 
131  //- Add the codeInclude entry to codeDict
132  static void addCodeInclude
133  (
134  const List<fileName>& fileNames,
135  const dictionary& contextDict,
137  );
138 
139 
140  // Member Operators
141 
142  //- Disallow default bitwise assignment
143  void operator=(const codeIncludeEntry&) = delete;
144 };
145 
146 
147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148 
149 } // End namespace functionEntries
150 } // End namespace Foam
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 #endif
155 
156 // ************************************************************************* //
label lineNumber() const
Return current stream line number.
Definition: IOstream.H:450
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
virtual autoPtr< entry > clone() const
Construct on freestore as copy.
Definition: entry.C:56
Compiles and executes C++ OpenFOAM code string expressions.
Definition: codeDict.H:131
Specify an include file or list of files for #calc within #codeBlock.
FunctionTypeName("#codeInclude")
Runtime type information.
virtual bool execute(dictionary &parentDict, Istream &)
Execute the functionEntry in a sub-dict context.
const List< fileName > & fileNames() const
Return the include file names.
static void addCodeInclude(const List< fileName > &fileNames, const dictionary &contextDict, dictionary &codeDict)
Add the codeInclude entry to codeDict.
void operator=(const codeIncludeEntry &)=delete
Disallow default bitwise assignment.
codeIncludeEntry(const label lineNumber, const dictionary &parentDict, Istream &is)
Construct from line number, dictionary and Istream.
A functionEntry causes entries to be added/manipulated on the specified dictionary given an input str...
Definition: functionEntry.H:66
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