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 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 
94  void checkSimulationVarsProduction(int ExpectedVarsCount);
95 
96  void checkParametersConsistency();
97 
98  void checkModelConsistency();
99 
100  void checkAttributesConsistency();
101 
102  void checkExtraFilesConsistency();
103 
104  void checkExistingVariable(const openfluid::core::VariableName_t& VarName,
105  const openfluid::core::Value::Type& VarType,
106  const openfluid::core::UnitsClass_t& ClassName,
107  const std::string& SimulatorID);
108 
109  void createVariable(const openfluid::core::VariableName_t& VarName,
110  const openfluid::core::Value::Type& VarType,
111  const openfluid::core::UnitsClass_t& ClassName,
112  bool UpdateMode,
113  const std::string& SimulatorID);
114 
115  void checkExistingAttribute(const openfluid::core::AttributeName_t AttrName,
116  const openfluid::core::UnitsClass_t ClassName,
117  const std::string& SimulatorID);
118 
119  void createAttribute(const openfluid::core::AttributeName_t AttrName,
120  const openfluid::core::UnitsClass_t ClassName,
121  const std::string& SimulatorID);
122 
123  void prepareOutputDir();
124 
125 
126  public:
127  /**
128  Constructor
129  */
130  Engine(SimulationBlob& SimBlob,
131  ModelInstance& MInstance, MonitoringInstance& OLInstance,
133 
134  /**
135  Destructor
136  */
137  ~Engine();
138 
139 
140  void initialize();
141 
142  void initParams();
143 
144  void prepareData();
145 
146  void checkConsistency();
147 
148  void run();
149 
150  void finalize();
151 
153  { return mp_SimStatus; };
154 
156  { return &m_SimulationBlob; };
157 
158  MachineListener* machineListener()
159  { return mp_MachineListener; };
160 
162  { return &m_ModelInstance; };
163 
164  unsigned int getWarningsCount() const
165  { return mp_SimLogger->getWarningsCount(); };
166 };
167 
168 
169 } } //namespaces
170 
171 
172 #endif
173 
174 
175 
176 
177 
178 
179 
std::string UnitsClass_t
Definition: TypeDefs.hpp:71
std::string VariableName_t
Definition: TypeDefs.hpp:86
unsigned int getWarningsCount() const
Definition: FileLogger.hpp:90
Definition: SimulationLogger.hpp:59
Definition: MonitoringInstance.hpp:57
MachineListener * machineListener()
Definition: Engine.hpp:158
Definition: SimulationBlob.hpp:52
ModelInstance * modelInstance()
Definition: Engine.hpp:161
SimulationBlob * simulationBlob()
Definition: Engine.hpp:155
unsigned int getWarningsCount() const
Definition: Engine.hpp:164
Definition: Engine.hpp:75
Definition: SimulationStatus.hpp:55
Type
Definition: Value.hpp:68
const openfluid::base::SimulationStatus * simulationStatus()
Definition: Engine.hpp:152
Definition: ApplicationException.hpp:47
std::string AttributeName_t
Definition: TypeDefs.hpp:81
Definition: MachineListener.hpp:55
#define OPENFLUID_API
Definition: dllexport.hpp:87
Definition: ModelInstance.hpp:68