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  void initialize();
143 
144  void initParams();
145 
146  void prepareData();
147 
148  void checkConsistency();
149 
150  void run();
151 
152  void finalize();
153 
155  {
156  return mp_SimStatus;
157  }
158 
160  {
161  return &m_SimulationBlob;
162  }
163 
164  MachineListener* machineListener()
165  {
166  return mp_MachineListener;
167  }
168 
170  {
171  return &m_ModelInstance;
172  }
173 
174  unsigned int getWarningsCount() const
175  {
176  return mp_SimLogger->getWarningsCount();
177  }
178 };
179 
180 
181 } } //namespaces
182 
183 
184 #endif
185 
Definition: MonitoringInstance.hpp:58
Definition: SimulationLogger.hpp:57
Definition: SimulationBlob.hpp:53
SimulationBlob * simulationBlob()
Definition: Engine.hpp:159
Definition: Engine.hpp:75
Type
Definition: Value.hpp:68
std::string AttributeName_t
Definition: TypeDefs.hpp:81
unsigned int getWarningsCount() const
Definition: FileLogger.hpp:93
Definition: ModelInstance.hpp:65
MachineListener * machineListener()
Definition: Engine.hpp:164
ModelInstance * modelInstance()
Definition: Engine.hpp:169
Definition: ApplicationException.hpp:47
const openfluid::base::SimulationStatus * simulationStatus()
Definition: Engine.hpp:154
std::string VariableName_t
Definition: TypeDefs.hpp:86
std::string UnitsClass_t
Definition: TypeDefs.hpp:71
Definition: SimulationStatus.hpp:55
unsigned int getWarningsCount() const
Definition: Engine.hpp:174
#define OPENFLUID_API
Definition: dllexport.hpp:86
Definition: MachineListener.hpp:54