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
36 
37  @author Jean-Christophe FABRE <fabrejc@supagro.inra.fr>
38 */
39 
40 
41 #ifndef __ENGINE_HPP__
42 #define __ENGINE_HPP__
43 
44 
45 #include <openfluid/dllexport.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 checkModelConsistency();
100 
101  void checkAttributesConsistency();
102 
103  void checkExtraFilesConsistency();
104 
105  void checkExistingVariable(const openfluid::core::VariableName_t& VarName,
106  const openfluid::core::Value::Type& VarType,
107  const openfluid::core::UnitClass_t& ClassName,
108  const std::string& SimulatorID);
109 
110  void createVariable(const openfluid::core::VariableName_t& VarName,
111  const openfluid::core::Value::Type& VarType,
112  const openfluid::core::UnitClass_t& ClassName,
113  bool UpdateMode,
114  const std::string& SimulatorID);
115 
116  void checkExistingAttribute(openfluid::core::AttributeName_t AttrName,
118  const std::string& SimulatorID);
119 
120  void createAttribute(openfluid::core::AttributeName_t AttrName,
122  const std::string& SimulatorID);
123 
124  void prepareOutputDir();
125 
126 
127  public:
128  /**
129  Constructor
130  */
131  Engine(SimulationBlob& SimBlob,
132  ModelInstance& MInstance, MonitoringInstance& OLInstance,
134 
135  /**
136  Destructor
137  */
138  ~Engine();
139 
140 
141  void initialize();
142 
143  void initParams();
144 
145  void prepareData();
146 
147  void checkConsistency();
148 
149  void run();
150 
151  void finalize();
152 
153  const openfluid::base::SimulationStatus* getSimulationStatus() { return mp_SimStatus; };
154 
155  SimulationBlob* getSimulationBlob() { return &m_SimulationBlob; };
156 
157  MachineListener* getMachineListener() { return mp_MachineListener; };
158 
159  ModelInstance* getModelInstance() { return &m_ModelInstance; };
160 
161  unsigned int getWarningsCount() const { return mp_SimLogger->getWarningsCount(); };
162 };
163 
164 
165 } } //namespaces
166 
167 
168 #endif
169 
170 
171 
172 
173 
174 
175 
std::string AttributeName_t
Definition: TypeDefs.hpp:74
Definition: ModelInstance.hpp:68
Definition: SimulationLogger.hpp:61
Definition: Engine.hpp:76
std::string UnitClass_t
Definition: TypeDefs.hpp:69
const openfluid::base::SimulationStatus * getSimulationStatus()
Definition: Engine.hpp:153
SimulationBlob * getSimulationBlob()
Definition: Engine.hpp:155
unsigned int getWarningsCount() const
Definition: Engine.hpp:161
Definition: MachineListener.hpp:55
Type
Definition: Value.hpp:68
ModelInstance * getModelInstance()
Definition: Engine.hpp:159
Definition: RuntimeEnv.hpp:63
Definition: SimulationStatus.hpp:56
std::string VariableName_t
Definition: TypeDefs.hpp:79
Definition: MonitoringInstance.hpp:56
Definition: SimulationBlob.hpp:51
MachineListener * getMachineListener()
Definition: Engine.hpp:157
#define DLLEXPORT
Definition: dllexport.hpp:51