includeEntry.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::functionEntries::includeEntry
26 
27 Description
28  Specify an include file when reading dictionaries.
29 
30  The file name is provided as a string in order to support the '/' directory
31  separator and unusual characters as well as the usual expansion of
32  environment variables and other constructs
33  (eg, the \c ~OpenFOAM/ expansion).
34 
35  e.g. to include the file \c includeFile from the \c include directory:
36  \verbatim
37  #include "include/includeFile"
38  \endverbatim
39 
40  Additionally optional arguments may be specified which are available for
41  substitution in the included file e.g.
42  \verbatim
43  #include "regionFunctions"(region = heatedWall)
44  \endverbatim
45 
46  will substitute \c heatedWall for \c $region in the \c regionFunctions file
47 
48  \verbatim
49  #includeFunc sample(region = $region)
50  \endverbatim
51 
52 See also
53  fileName
54 
55 SourceFiles
56  includeEntry.C
57 
58 \*---------------------------------------------------------------------------*/
59 
60 #ifndef includeEntry_H
61 #define includeEntry_H
62 
63 #include "functionEntry.H"
64 
65 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
66 
67 namespace Foam
68 {
69 namespace functionEntries
70 {
71 
72 /*---------------------------------------------------------------------------*\
73  Class includeEntry Declaration
74 \*---------------------------------------------------------------------------*/
75 
76 class includeEntry
77 :
78  public functionEntry
79 {
80  // Private Member Functions
81 
82  //- Return the optional named arguments
83  // temporarily inserted into parentDict
84  static List<Tuple3<word, string, label>> insertNamedArgs
85  (
86  dictionary& parentDict,
87  Istream& is
88  );
89 
90  //- Remove named argument entries from parentDict
91  // renaming any existing entries which had the same name
92  static void removeInsertNamedArgs
93  (
94  dictionary& parentDict,
95  const List<Tuple3<word, string, label>>& namedArgs
96  );
97 
98 
99 protected:
100 
101  // Protected Member Functions
102 
103  //- Read the include fileName from Istream, expand and return
104  static fileName includeFileName(Istream&, const dictionary&);
105 
106  //- Expand include fileName and return
108  (
109  const fileName& dir,
110  const fileName&,
111  const dictionary&
112  );
113 
114 
115 public:
116 
117  // Static Data Members
118 
119  //- Report which file is included to stdout
120  static bool log;
121 
122 
123  //- Runtime type information
124  ClassName("include");
125 
126 
127  // Constructors
128 
129  //- Disallow default bitwise copy construction
130  includeEntry(const includeEntry&) = delete;
131 
132 
133  // Member Functions
134 
135  //- Execute the functionEntry in a sub-dict context
136  static bool execute(dictionary& parentDict, Istream&);
137 
138  //- Execute the functionEntry in a primitiveEntry context
139  static bool execute
140  (
141  const dictionary& parentDict,
143  Istream&
144  );
145 
146 
147  // Member Operators
148 
149  //- Disallow default bitwise assignment
150  void operator=(const includeEntry&) = delete;
151 };
152 
153 
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 
156 } // End namespace functionEntries
157 } // End namespace Foam
158 
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160 
161 #endif
162 
163 // ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:91
A 3-tuple for storing three objects of different types.
Definition: Tuple3.H:60
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
A class for handling file names.
Definition: fileName.H:82
Specify an include file when reading dictionaries.
Definition: includeEntry.H:78
static bool execute(dictionary &parentDict, Istream &)
Execute the functionEntry in a sub-dict context.
Definition: includeEntry.C:205
ClassName("include")
Runtime type information.
includeEntry(const includeEntry &)=delete
Disallow default bitwise copy construction.
static fileName includeFileName(Istream &, const dictionary &)
Read the include fileName from Istream, expand and return.
Definition: includeEntry.C:156
void operator=(const includeEntry &)=delete
Disallow default bitwise assignment.
static bool log
Report which file is included to stdout.
Definition: includeEntry.H:119
A functionEntry causes entries to be added/manipulated on the specified dictionary given an input str...
Definition: functionEntry.H:66
A keyword and a list of tokens is a 'primitiveEntry'. An primitiveEntry can be read,...
Namespace for OpenFOAM.