runTimeCondition.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2015 OpenFOAM Foundation
9  Copyright (C) 2016 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::functionObjects::runTimeControls::runTimeCondition
29 
30 Description
31  Base class for run time conditions
32 
33 SourceFiles
34  runTimeCondition.C
35  runTimeConditionNew.C
36  runTimeCondition.H
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef functionObjects_runTimeControls_runTimeCondition_H
41 #define functionObjects_runTimeControls_runTimeCondition_H
42 
43 #include "stateFunctionObject.H"
44 #include "dictionary.H"
45 #include "autoPtr.H"
46 #include "runTimeSelectionTables.H"
47 #include "Switch.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 namespace functionObjects
54 {
55 namespace runTimeControls
56 {
57 
58 /*---------------------------------------------------------------------------*\
59  Class runTimeCondition Declaration
60 \*---------------------------------------------------------------------------*/
61 
62 class runTimeCondition
63 {
64 
65 protected:
66 
67  // Protected data
68 
69  //- Condition name
70  word name_;
71 
72  //- Reference to the object registry
73  const objectRegistry& obr_;
74 
75  //- State
77 
78  //- On/off switch
79  bool active_;
80 
81  //- Reference to the condition dictionary
83 
84  //- Group index - if applied, all conditions in a group must be
85  // satisfied before condition is met
86  label groupID_;
87 
88 
89  // Protected Member Functions
90 
91  //- Set the condition dictionary (create if necessary)
93 
94  //- Return const access to the conditions dictionary
95  const dictionary& conditionDict() const;
96 
97  //- Return non-const access to the conditions dictionary
99 
100 
101 public:
102 
103  //- Runtime type information
104  TypeName("runTimeCondition");
105 
106  //- Declare runtime constructor selection table
108  (
109  autoPtr,
111  dictionary,
112  (
113  const word& name,
114  const objectRegistry& obr,
115  const dictionary& dict,
116  stateFunctionObject& state
117  ),
118  (name, obr, dict, state)
119  );
120 
121 
122  //- Constructor
124  (
125  const word& name,
126  const objectRegistry& obr,
127  const dictionary& dict,
128  stateFunctionObject& state
129  );
130 
131  //- Destructor
132  virtual ~runTimeCondition() = default;
133 
134  //- Selector
136  (
137  const word& conditionName,
138  const objectRegistry& obr,
139  const dictionary& dict,
140  stateFunctionObject& state
141  );
142 
143  // Public Data
144 
145  //- Switch to send output to Info
146  Switch log;
147 
148 
149  // Public Member Functions
150 
151  //- Return the condition name
152  virtual const word& name() const;
153 
154  //- Return the active flag
155  virtual bool active() const;
156 
157  //- Return the group index
158  virtual label groupID() const;
159 
160  //- Apply the condition
161  virtual bool apply() = 0;
162 
163  //- Write
164  virtual void write() = 0;
165 };
166 
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 } // End namespace runTimeControls
171 } // End namespace functionObjects
172 } // End namespace Foam
173 
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 
176 #endif
177 
178 // ************************************************************************* //
Foam::functionObjects::runTimeControls::runTimeCondition::name
virtual const word & name() const
Return the condition name.
Definition: runTimeCondition.C:98
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:77
Foam::functionObjects::runTimeControls::runTimeCondition
Base class for run time conditions.
Definition: runTimeCondition.H:61
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::functionObjects::runTimeControls::runTimeCondition::active_
bool active_
On/off switch.
Definition: runTimeCondition.H:78
Foam::functionObjects::stateFunctionObject
Base class for function objects, adding functionality to read/write state information (data required ...
Definition: stateFunctionObject.H:69
Foam::functionObjects::runTimeControls::runTimeCondition::~runTimeCondition
virtual ~runTimeCondition()=default
Destructor.
Foam::functionObjects::runTimeControls::runTimeCondition::state_
stateFunctionObject & state_
State.
Definition: runTimeCondition.H:75
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
Foam::functionObjects::runTimeControls::runTimeCondition::conditionDict
const dictionary & conditionDict() const
Return const access to the conditions dictionary.
Definition: runTimeCondition.C:62
Foam::functionObjects::runTimeControls::runTimeCondition::New
static autoPtr< runTimeCondition > New(const word &conditionName, const objectRegistry &obr, const dictionary &dict, stateFunctionObject &state)
Selector.
Definition: runTimeConditionNew.C:35
Foam::functionObjects::runTimeControls::runTimeCondition::obr_
const objectRegistry & obr_
Reference to the object registry.
Definition: runTimeCondition.H:72
Foam::functionObjects::runTimeControls::runTimeCondition::groupID_
label groupID_
Group index - if applied, all conditions in a group must be.
Definition: runTimeCondition.H:85
Switch.H
Foam::functionObjects::runTimeControls::runTimeCondition::setConditionDict
dictionary & setConditionDict()
Set the condition dictionary (create if necessary)
Definition: runTimeCondition.C:48
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::functionObjects::runTimeControls::runTimeCondition::runTimeCondition
runTimeCondition(const word &name, const objectRegistry &obr, const dictionary &dict, stateFunctionObject &state)
Constructor.
Definition: runTimeCondition.C:78
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::runTimeControls::runTimeCondition::conditionDict_
dictionary & conditionDict_
Reference to the condition dictionary.
Definition: runTimeCondition.H:81
Foam::functionObjects::runTimeControls::runTimeCondition::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, runTimeCondition, dictionary,(const word &name, const objectRegistry &obr, const dictionary &dict, stateFunctionObject &state),(name, obr, dict, state))
Declare runtime constructor selection table.
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
runTimeSelectionTables.H
Macros to ease declaration of run-time selection tables.
dictionary.H
stateFunctionObject.H
Foam::functionObjects::runTimeControls::runTimeCondition::write
virtual void write()=0
Write.
Foam::functionObjects::runTimeControls::runTimeCondition::groupID
virtual label groupID() const
Return the group index.
Definition: runTimeCondition.C:111
Foam::functionObjects::runTimeControls::runTimeCondition::name_
word name_
Condition name.
Definition: runTimeCondition.H:69
Foam::functionObjects::runTimeControls::runTimeCondition::active
virtual bool active() const
Return the active flag.
Definition: runTimeCondition.C:104
Foam::functionObjects::runTimeControls::runTimeCondition::TypeName
TypeName("runTimeCondition")
Runtime type information.
Foam::functionObjects::runTimeControls::runTimeCondition::log
Switch log
Switch to send output to Info.
Definition: runTimeCondition.H:145
autoPtr.H
Foam::functionObjects::runTimeControls::runTimeCondition::apply
virtual bool apply()=0
Apply the condition.