Engine.hpp
Go to the documentation of this file.
1 /*
2 
3  This file is part of OpenFLUID software
4  Copyright(c) 2007, INRA - Montpellier SupAgro
5 
6 
7  == GNU General Public License Usage ==
8 
9  OpenFLUID is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  OpenFLUID is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
21 
22 
23  == Other Usage ==
24 
25  Other Usage means a use of OpenFLUID that is inconsistent with the GPL
26  license, and requires a written agreement between You and INRA.
27  Licensees for Other Usage of OpenFLUID may use this file in accordance
28  with the terms contained in the written agreement between You and INRA.
29 
30 */
31 
32 
33 /**
34  @file Engine.hpp
35 
36  @author Jean-Christophe FABRE <jean-christophe.fabre@inra.fr>
37 */
38 
39 
40 #ifndef __OPENFLUID_MACHINE_ENGINE_HPP__
41 #define __OPENFLUID_MACHINE_ENGINE_HPP__
42 
43 
44 #include <openfluid/dllexport.hpp>
45 #include <openfluid/core/TypeDefs.hpp>
47 
48 
49 namespace openfluid {
50 namespace base {
51 class SimulationStatus;
52 }
53 namespace core {
54 class Value;
55 class DateTime;
56 }
57 }
58 
59 
60 namespace openfluid { namespace machine {
61 
62 class ModelInstance;
63 class MonitoringInstance;
64 class MachineListener;
65 class SimulationBlob;
66 
67 
68 // =====================================================================
69 // =====================================================================
70 
71 
72 /**
73  Computation engine class
74 */
76 {
77 
78  private:
79 
80  SimulationBlob& m_SimulationBlob;
81 
83 
84  MachineListener* mp_MachineListener;
85 
86  ModelInstance& m_ModelInstance;
87 
88  MonitoringInstance& m_MonitoringInstance;
89 
91 
92 
93  void checkSimulationVarsProduction(int ExpectedVarsCount);
94 
95  void checkParametersConsistency();
96 
97  void checkModelConsistency();
98 
99  void checkAttributesConsistency();
100 
101  void checkExtraFilesConsistency();
102 
103  void checkExistingVariable(const openfluid::core::VariableName_t& VarName,
104  const openfluid::core::Value::Type& VarType,
105  const openfluid::core::UnitsClass_t& ClassName,
106  const std::string& SimulatorID);
107 
108  void createVariable(const openfluid::core::VariableName_t& VarName,
109  const openfluid::core::Value::Type& VarType,
110  const openfluid::core::UnitsClass_t& ClassName,
111  bool UpdateMode,
112  const std::string& SimulatorID);
113 
114  void checkExistingAttribute(const openfluid::core::AttributeName_t AttrName,
115  const openfluid::core::UnitsClass_t ClassName,
116  const std::string& SimulatorID);
117 
118  void createAttribute(const openfluid::core::AttributeName_t AttrName,
119  const openfluid::core::UnitsClass_t ClassName,
120  const std::string& SimulatorID);
121 
122  void prepareOutputDir();
123 
124 
125  public:
126 
127  Engine() = delete;
128 
129  /**
130  Constructor
131  */
132  Engine(SimulationBlob& SimBlob,
133  ModelInstance& MInstance, MonitoringInstance& OLInstance,
135 
136  /**
137  Destructor
138  */
139  ~Engine();
140 
141  /**
142  Initializes the simulation engine
143  */
144  void initialize();
145 
146  /**
147  Executes the initParams() method of each item of the model
148  */
149  void initParams();
150 
151  /**
152  Executes the prepareData() method of each item of the model
153  */
154  void prepareData();
155 
156  /**
157  Executes the checkConsistency() method of each item of the model
158  */
159  void checkConsistency();
160 
161  /**
162  Executes the initializeRun(), runStep() and finalizeRun() methods of each item of the model
163  */
164  void run();
165 
166  /**
167  Finalizes the simulation engine
168  */
169  void finalize();
170 
172  {
173  return mp_SimStatus;
174  }
175 
177  {
178  return &m_SimulationBlob;
179  }
180 
181  MachineListener* machineListener()
182  {
183  return mp_MachineListener;
184  }
185 
187  {
188  return &m_ModelInstance;
189  }
190 
191  unsigned int getWarningsCount() const
192  {
193  return mp_SimLogger->getWarningsCount();
194  }
195 };
196 
197 
198 } } //namespaces
199 
200 
201 #endif
202 
const openfluid::base::SimulationStatus * simulationStatus()
Definition: Engine.hpp:171
unsigned int getWarningsCount() const
Definition: Engine.hpp:191
MachineListener * machineListener()
Definition: Engine.hpp:181
unsigned int getWarningsCount() const
Definition: FileLogger.hpp:93
Definition: SimulationBlob.hpp:53
Definition: MonitoringInstance.hpp:58
Definition: SimulationLogger.hpp:57
Definition: Engine.hpp:75
SimulationBlob * simulationBlob()
Definition: Engine.hpp:176
Definition: ModelInstance.hpp:65
std::string UnitsClass_t
Definition: TypeDefs.hpp:98
Definition: SimulationStatus.hpp:55
ModelInstance * modelInstance()
Definition: Engine.hpp:186
Definition: ApplicationException.hpp:47
std::string AttributeName_t
Definition: TypeDefs.hpp:117
Type
Definition: Value.hpp:68
Definition: MachineListener.hpp:54
std::string VariableName_t
Definition: TypeDefs.hpp:131
#define OPENFLUID_API
Definition: dllexport.hpp:86