inputModeEntry.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-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::inputModeEntry
26 
27 Description
28  Specify the input mode when reading dictionaries, expects
29  a single word to follow.
30 
31  An example of \c \#inputMode directive:
32  \verbatim
33  #inputMode merge
34  \endverbatim
35 
36  The possible input modes:
37  - \par merge merge sub-dictionaries when possible
38  - \par overwrite keep last entry and silently remove previous ones
39  - \par protect keep initial entry and silently ignore subsequent ones
40  - \par warn keep initial entry and warn about subsequent ones
41  - \par error issue a FatalError for duplicate entries
42  - \par default currently identical to merge
43 
44 SourceFiles
45  inputModeEntry.C
46 
47 \*---------------------------------------------------------------------------*/
48 
49 #ifndef inputModeEntry_H
50 #define inputModeEntry_H
51 
52 #include "functionEntry.H"
53 
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56 namespace Foam
57 {
58 namespace functionEntries
59 {
60 
61 /*---------------------------------------------------------------------------*\
62  Class inputModeEntry Declaration
63 \*---------------------------------------------------------------------------*/
64 
65 class inputModeEntry
66 :
67  public functionEntry
68 {
69  //- The input mode options
70  enum inputMode
71  {
72  MERGE,
73  OVERWRITE,
74  PROTECT,
75  WARN,
76  ERROR
77  };
78 
79  //- The current input mode
80  static inputMode mode_;
81 
82 
83 public:
84 
85  //- Runtime type information
86  FunctionTypeName("#inputMode");
87 
88 
89  // Constructors
90 
91  //- Construct from line number, dictionary and Istream
93  (
94  const label lineNumber,
95  const dictionary& parentDict,
96  Istream& is
97  );
98 
99  //- Copy construct
100  inputModeEntry(const inputModeEntry&) = default;
101 
102  //- Clone
103  virtual autoPtr<entry> clone(const dictionary&) const
104  {
105  return autoPtr<entry>(new inputModeEntry(*this));
106  }
107 
108 
109  // Member Functions
110 
111  //- Reset the inputMode to %default (ie, %merge)
112  static void clear();
113 
114  //- Return true if the inputMode is %merge
115  static bool merge();
116 
117  //- Return true if the inputMode is %overwrite
118  static bool overwrite();
119 
120  //- Return true if the inputMode is %protect
121  static bool protect();
122 
123  //- Return true if the inputMode is %error
124  static bool error();
125 
126  //- Expand the functionEntry into the contextDict
127  virtual bool execute(dictionary& contextDict, Istream&);
128 
129 
130  // Member Operators
131 
132  //- Disallow default bitwise assignment
133  void operator=(const inputModeEntry&) = delete;
134 };
135 
136 
137 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
138 
139 } // End namespace functionEntries
140 } // End namespace Foam
141 
142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 
144 #endif
145 
146 // ************************************************************************* //
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
Specify the input mode when reading dictionaries, expects a single word to follow.
static bool overwrite()
Return true if the inputMode is overwrite.
static bool protect()
Return true if the inputMode is protect.
static bool merge()
Return true if the inputMode is merge.
static bool error()
Return true if the inputMode is error.
FunctionTypeName("#inputMode")
Runtime type information.
static void clear()
Reset the inputMode to default (ie, merge)
virtual bool execute(dictionary &contextDict, Istream &)
Expand the functionEntry into the contextDict.
void operator=(const inputModeEntry &)=delete
Disallow default bitwise assignment.
inputModeEntry(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