includeFuncEntry.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) 2016-2025 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::includeFuncEntry
26 
27 Description
28  Specify a functionObject dictionary file to include, expects the
29  functionObject name to follow with option arguments (without quotes).
30 
31  Searches for functionObject dictionary file in user/group/shipped
32  directories allowing for version-specific and version-independent files
33  using the following hierarchy:
34  - \b user settings:
35  - ~/.OpenFOAM/<VERSION>/caseDicts/functions
36  - ~/.OpenFOAM/caseDicts/functions
37  - \b group (site) settings (when $WM_PROJECT_SITE is set):
38  - $WM_PROJECT_SITE/<VERSION>/etc/caseDicts/functions
39  - $WM_PROJECT_SITE/etc/caseDicts/functions
40  - \b group (site) settings (when $WM_PROJECT_SITE is not set):
41  - $WM_PROJECT_INST_DIR/site/<VERSION>/etc/caseDicts/functions
42  - $WM_PROJECT_INST_DIR/site/etc/caseDicts/functions
43  - \b other (shipped) settings:
44  - $WM_PROJECT_DIR/etc/caseDicts/functions
45 
46  The optional field arguments included in the name are inserted in 'field' or
47  'fields' entries in the functionObject dictionary and included in the name
48  of the functionObject entry to avoid conflict.
49 
50  Examples:
51  \verbatim
52  #includeFunc Q
53  #includeFunc components(U)
54  #includeFunc mag(Ux)
55  #includeFunc mag(p)
56  \endverbatim
57 
58  Other dictionary entries may also be specified using named arguments.
59 
60 SourceFiles
61  includeFuncEntry.C
62 
63 \*---------------------------------------------------------------------------*/
64 
65 #ifndef includeFuncEntry_H
66 #define includeFuncEntry_H
67 
68 #include "functionEntry.H"
69 
70 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
71 
72 namespace Foam
73 {
74 namespace functionEntries
75 {
76 
77 /*---------------------------------------------------------------------------*\
78  Class includeFuncEntry Declaration
79 \*---------------------------------------------------------------------------*/
80 
81 class includeFuncEntry
82 :
83  public functionEntry
84 {
85 protected:
86 
87  //- Return the function name + arguments string
88  // for processing by readConfigFile
90  {
91  Tuple2<string, label> fNameArgs
92  (
93  operator[](0).wordToken(),
94  operator[](0).lineNumber()
95  );
96 
97  if (size() > 1)
98  {
99  fNameArgs.first() +=
100  char(operator[](1).pToken())
101  + operator[](2).stringToken()
102  + char(operator[](3).pToken());
103  }
104 
105  return fNameArgs;
106  }
107 
108 
109 public:
110 
111  //- Runtime type information
112  FunctionTypeName("#includeFunc");
113 
114 
115  // Constructors
116 
117  //- Construct from functionType, dictionary and Istream
119  (
120  const functionName& functionType,
121  const label lineNumber,
122  const dictionary& parentDict,
123  Istream& is
124  );
125 
126  //- Construct from line number, dictionary and Istream
128  (
129  const label lineNumber,
130  const dictionary& parentDict,
131  Istream& is
132  );
133 
134  //- Copy construct
135  includeFuncEntry(const includeFuncEntry&) = default;
136 
137  //- Clone
138  virtual autoPtr<entry> clone(const dictionary&) const
139  {
140  return autoPtr<entry>(new includeFuncEntry(*this));
141  }
142 
143 
144  // Static Data Members
145 
146  //- Default relative path to the directory structure
147  // containing the functionObject dictionary files
149 
150  //- Default relative path to the directory structure
151  // containing the functionObject template files
153 
154 
155  // Member Functions
156 
157  //- Expand the functionEntry into the contextDict
158  virtual bool execute(dictionary& contextDict, Istream&);
159 };
160 
161 
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163 
164 } // End namespace functionEntries
165 } // End namespace Foam
166 
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 
169 #endif
170 
171 // ************************************************************************* //
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
label size() const
Return the number of elements in the UList.
Definition: ListI.H:171
A 2-tuple for storing two objects of different types.
Definition: Tuple2.H:66
const Type1 & first() const
Return first.
Definition: Tuple2.H:119
T & operator[](const label)
Return element of UList.
Definition: UListI.H:167
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
A class for handling file names.
Definition: fileName.H:82
Specify a functionObject dictionary file to include, expects the functionObject name to follow with o...
includeFuncEntry(const functionName &functionType, const label lineNumber, const dictionary &parentDict, Istream &is)
Construct from functionType, dictionary and Istream.
static fileName functionObjectTemplatePath
Default relative path to the directory structure.
FunctionTypeName("#includeFunc")
Runtime type information.
virtual bool execute(dictionary &contextDict, Istream &)
Expand the functionEntry into the contextDict.
static fileName functionObjectDictPath
Default relative path to the directory structure.
Tuple2< string, label > funcNameArgs() const
Return the function name + arguments string.
A functionEntry causes entries to be added/manipulated on the specified dictionary given an input str...
Definition: functionEntry.H:66
A functionName is a word starting with '#'.
Definition: functionName.H:60
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