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 | Copyright (C) 2015 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::runTimeCondition
26 
27 Description
28  Base class for run time conditions
29 
30 SourceFiles
31  runTimeCondition.C
32  runTimeConditionNew.C
33  runTimeCondition.H
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef runTimeCondition_H
38 #define runTimeCondition_H
39 
40 #include "functionObjectState.H"
41 #include "dictionary.H"
42 #include "autoPtr.H"
43 #include "runTimeSelectionTables.H"
44 #include "Switch.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class runTimeCondition Declaration
53 \*---------------------------------------------------------------------------*/
54 
55 class runTimeCondition
56 {
57 
58 protected:
59 
60  // Protected data
61 
62  //- Condition name
63  word name_;
64 
65  //- Reference to the object registry
66  const objectRegistry& obr_;
67 
68  //- State
70 
71  //- On/off switch
72  bool active_;
73 
74  //- Reference to the condition dictionary
76 
77  //- Switch to send output to Info
78  Switch log_;
79 
80  //- Group index - if applied, all conditions in a group must be
81  // satisfield before condition is met
83 
84 
85  // Protected Member Functions
86 
87  //- Set the condition dictionary (create if necessary)
89 
90  //- Return const access to the conditions dictionary
91  const dictionary& conditionDict() const;
92 
93  //- Return non-const access to the conditions dictionary
95 
96 
97 public:
98 
99  //- Runtime type information
100  TypeName("runTimeCondition");
101 
102  //- Declare runtime constructor selection table
104  (
105  autoPtr,
107  dictionary,
108  (
109  const word& name,
110  const objectRegistry& obr,
111  const dictionary& dict,
112  functionObjectState& state
113  ),
114  (name, obr, dict, state)
115  );
116 
117 
118  //- Constructor
120  (
121  const word& name,
122  const objectRegistry& obr,
123  const dictionary& dict,
124  functionObjectState& state
125  );
126 
127  //- Destructor
128  virtual ~runTimeCondition();
129 
130  //- Selector
132  (
133  const word& conditionName,
134  const objectRegistry& obr,
135  const dictionary& dict,
136  functionObjectState& state
137  );
138 
139 
140  // Public Member Functions
141 
142  //- Return the condition name
143  virtual const word& name() const;
144 
145  //- Return the active flag
146  virtual bool active() const;
147 
148  //- Return the group index
149  virtual label groupID() const;
150 
151  //- Apply the condition
152  virtual bool apply() = 0;
153 
154  //- Write
155  virtual void write() = 0;
156 };
157 
158 
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160 
161 } // End namespace Foam
162 
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164 
165 #endif
166 
167 // ************************************************************************* //
Foam::runTimeCondition
Base class for run time conditions.
Definition: runTimeCondition.H:54
Foam::runTimeCondition::New
static autoPtr< runTimeCondition > New(const word &conditionName, const objectRegistry &obr, const dictionary &dict, functionObjectState &state)
Selector.
Definition: runTimeConditionNew.C:31
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:60
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::functionObjectState
Base class for function objects, adding functionality to read/write state information (data required ...
Definition: functionObjectState.H:54
Foam::runTimeCondition::setConditionDict
dictionary & setConditionDict()
Set the condition dictionary (create if necessary)
Definition: runTimeCondition.C:39
Foam::runTimeCondition::name_
word name_
Condition name.
Definition: runTimeCondition.H:62
functionObjectState.H
Foam::runTimeCondition::obr_
const objectRegistry & obr_
Reference to the object registry.
Definition: runTimeCondition.H:65
Foam::runTimeCondition::conditionDict
const dictionary & conditionDict() const
Return const access to the conditions dictionary.
Definition: runTimeCondition.C:52
Foam::runTimeCondition::write
virtual void write()=0
Write.
Foam::runTimeCondition::TypeName
TypeName("runTimeCondition")
Runtime type information.
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::runTimeCondition::name
virtual const word & name() const
Return the condition name.
Definition: runTimeCondition.C:92
Foam::runTimeCondition::runTimeCondition
runTimeCondition(const word &name, const objectRegistry &obr, const dictionary &dict, functionObjectState &state)
Constructor.
Definition: runTimeCondition.C:67
Foam::label
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
Foam::runTimeCondition::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, runTimeCondition, dictionary,(const word &name, const objectRegistry &obr, const dictionary &dict, functionObjectState &state),(name, obr, dict, state))
Declare runtime constructor selection table.
Switch.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::runTimeCondition::state_
functionObjectState & state_
State.
Definition: runTimeCondition.H:68
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::runTimeCondition::active_
bool active_
On/off switch.
Definition: runTimeCondition.H:71
Foam::runTimeCondition::~runTimeCondition
virtual ~runTimeCondition()
Destructor.
Definition: runTimeCondition.C:86
Foam::runTimeCondition::groupID_
label groupID_
Group index - if applied, all conditions in a group must be.
Definition: runTimeCondition.H:81
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
runTimeSelectionTables.H
Macros to ease declaration of run-time selection tables.
Foam::runTimeCondition::active
virtual bool active() const
Return the active flag.
Definition: runTimeCondition.C:98
dictionary.H
Foam::runTimeCondition::log_
Switch log_
Switch to send output to Info.
Definition: runTimeCondition.H:77
Foam::runTimeCondition::apply
virtual bool apply()=0
Apply the condition.
Foam::runTimeCondition::conditionDict_
dictionary & conditionDict_
Reference to the condition dictionary.
Definition: runTimeCondition.H:74
Foam::runTimeCondition::groupID
virtual label groupID() const
Return the group index.
Definition: runTimeCondition.C:104
autoPtr.H