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-2019 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  // Private Member Functions
84 
85  //- Read the mode as a word and set enum appropriately
86  static void setMode(Istream&);
87 
88 
89 public:
90 
91  //- Runtime type information
92  ClassName("inputMode");
93 
94 
95  // Constructors
96 
97  //- Disallow default bitwise copy construction
98  inputModeEntry(const inputModeEntry&) = delete;
99 
100 
101  // Member Functions
102 
103  //- Execute the functionEntry in a sub-dict context
104  static bool execute(dictionary& parentDict, Istream&);
105 
106  //- Reset the inputMode to %default (ie, %merge)
107  static void clear();
108 
109  //- Return true if the inputMode is %merge
110  static bool merge();
111 
112  //- Return true if the inputMode is %overwrite
113  static bool overwrite();
114 
115  //- Return true if the inputMode is %protect
116  static bool protect();
117 
118  //- Return true if the inputMode is %error
119  static bool error();
120 
121 
122  // Member Operators
123 
124  //- Disallow default bitwise assignment
125  void operator=(const inputModeEntry&) = delete;
126 };
127 
128 
129 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
130 
131 } // End namespace functionEntries
132 } // End namespace Foam
133 
134 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
135 
136 #endif
137 
138 // ************************************************************************* //
static bool execute(dictionary &parentDict, Istream &)
Execute the functionEntry in a sub-dict context.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
static bool protect()
Return true if the inputMode is protect.
void operator=(const inputModeEntry &)=delete
Disallow default bitwise assignment.
A functionEntry causes entries to be added/manipulated on the specified dictionary given an input str...
Definition: functionEntry.H:63
static void clear()
Reset the inputMode to default (ie, merge)
inputModeEntry(const inputModeEntry &)=delete
Disallow default bitwise copy construction.
ClassName("inputMode")
Runtime type information.
Specify the input mode when reading dictionaries, expects a single word to follow.
static bool merge()
Return true if the inputMode is merge.
static bool overwrite()
Return true if the inputMode is overwrite.
static bool error()
Return true if the inputMode is error.
Namespace for OpenFOAM.