All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 /**
35  @file Engine.hpp
36 
37  @author Jean-Christophe FABRE <jean-christophe.fabre@supagro.inra.fr>
38 */
39 
40 
41 #ifndef __OPENFLUID_MACHINE_ENGINE_HPP__
42 #define __OPENFLUID_MACHINE_ENGINE_HPP__
43 
44 
45 #include <openfluid/dllexport.hpp>
46 #include <openfluid/core/TypeDefs.hpp>
48 
49 namespace openfluid {
50 namespace base {
51 class RuntimeEnvironment;
52 class SimulationStatus;
53 }
54 namespace core {
55 class Value;
56 class DateTime;
57 }
58 }
59 
60 
61 namespace openfluid { namespace machine {
62 
63 class ModelInstance;
64 class MonitoringInstance;
65 class MachineListener;
66 class SimulationBlob;
67 
68 
69 // =====================================================================
70 // =====================================================================
71 
72 
73 /**
74  Computation engine class
75 */
77 {
78 
79  private:
80 
81  SimulationBlob& m_SimulationBlob;
82 
84 
86 
87  MachineListener* mp_MachineListener;
88 
89  ModelInstance& m_ModelInstance;
90 
91  MonitoringInstance& m_MonitoringInstance;
92 
94 
95 
96 
97  void checkSimulationVarsProduction(int ExpectedVarsCount);
98 
99  void checkParametersConsistency();
100 
101  void checkModelConsistency();
102 
103  void checkAttributesConsistency();
104 
105  void checkExtraFilesConsistency();
106 
107  void checkExistingVariable(const openfluid::core::VariableName_t& VarName,
108  const openfluid::core::Value::Type& VarType,
109  const openfluid::core::UnitsClass_t& ClassName,
110  const std::string& SimulatorID);
111 
112  void createVariable(const openfluid::core::VariableName_t& VarName,
113  const openfluid::core::Value::Type& VarType,
114  const openfluid::core::UnitsClass_t& ClassName,
115  bool UpdateMode,
116  const std::string& SimulatorID);
117 
118  void checkExistingAttribute(openfluid::core::AttributeName_t AttrName,
120  const std::string& SimulatorID);
121 
122  void createAttribute(openfluid::core::AttributeName_t AttrName,
124  const std::string& SimulatorID);
125 
126  void prepareOutputDir();
127 
128 
129  public:
130  /**
131  Constructor
132  */
133  Engine(SimulationBlob& SimBlob,
134  ModelInstance& MInstance, MonitoringInstance& OLInstance,
136 
137  /**
138  Destructor
139  */
140  ~Engine();
141 
142 
143  void initialize();
144 
145  void initParams();
146 
147  void prepareData();
148 
149  void checkConsistency();
150 
151  void run();
152 
153  void finalize();
154 
155  const openfluid::base::SimulationStatus* simulationStatus() { return mp_SimStatus; };
156 
157  SimulationBlob* simulationBlob() { return &m_SimulationBlob; };
158 
159  MachineListener* machineListener() { return mp_MachineListener; };
160 
161  ModelInstance* modelInstance() { return &m_ModelInstance; };
162 
163  unsigned int getWarningsCount() const { return mp_SimLogger->getWarningsCount(); };
164 };
165 
166 
167 } } //namespaces
168 
169 
170 #endif
171 
172 
173 
174 
175 
176 
177 
std::string VariableName_t
Definition: TypeDefs.hpp:86
std::string UnitsClass_t
Definition: TypeDefs.hpp:71
Definition: ModelInstance.hpp:68
Definition: SimulationStatus.hpp:55
Definition: SimulationLogger.hpp:59
MachineListener * machineListener()
Definition: Engine.hpp:159
ModelInstance * modelInstance()
Definition: Engine.hpp:161
Definition: SimulationBlob.hpp:50
Definition: RuntimeEnv.hpp:63
Definition: MonitoringInstance.hpp:55
unsigned int getWarningsCount() const
Definition: Engine.hpp:163
std::string AttributeName_t
Definition: TypeDefs.hpp:81
SimulationBlob * simulationBlob()
Definition: Engine.hpp:157
Type
Definition: Value.hpp:68
Definition: MachineListener.hpp:55
const openfluid::base::SimulationStatus * simulationStatus()
Definition: Engine.hpp:155
Definition: Engine.hpp:76
#define OPENFLUID_API
Definition: dllexport.hpp:87