All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ModelInstance.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 __MODELINSTANCE_HPP__
42 #define __MODELINSTANCE_HPP__
43 
44 #include <list>
45 
46 #include <openfluid/dllexport.hpp>
51 
52 
53 
54 namespace openfluid { namespace ware {
55 
56 class PluggableSimulator;
57 
58 } }
59 
60 
61 namespace openfluid { namespace machine {
62 
63 class MachineListener;
64 class SimulationBlob;
65 class ModelItemInstance;
66 
67 
69 {
70  private:
71 
72  std::list<ModelItemInstance*> m_ModelItems;
73 
75 
77 
79 
80  openfluid::machine::SimulationBlob& m_SimulationBlob;
81 
82  std::list<ExecutionTimePoint> m_TimePointList;
83 
84  openfluid::ware::WareParams_t m_GlobalParams;
85 
86  bool m_Initialized;
87 
88  void appendItemToTimePoint(openfluid::core::TimeIndex_t TimeIndex, openfluid::machine::ModelItemInstance* Item);
89 
90  void checkDeltaTMode(openfluid::base::SchedulingRequest& SReq, const openfluid::ware::WareID_t& ID);
91 
92  protected:
93 
94  openfluid::ware::WareParams_t mergeParamsWithGlobalParams(const openfluid::ware::WareParams_t& Params) const;
95 
96 
97  public:
98 
101 
102  ~ModelInstance();
103 
104  void appendItem(ModelItemInstance* ItemInstance);
105 
106  /**
107  Insert a ModelItemInstance before the given postion (positions starts at index 0)
108  @param[in] ItemInstance the ModelItemInstance to insert
109  @param[in] Position the position
110  */
111  void insertItem(ModelItemInstance* ItemInstance, unsigned int Position);
112 
113  /**
114  Delete the ModelItemInstance located at the given postion (positions starts at index 0), and remove it from the ModelInstance
115  @param[in] Position the position
116  */
117  void deleteItem(unsigned int Position);
118 
119  void clear();
120 
121  unsigned int getItemsCount() const { return m_ModelItems.size(); };
122 
123  openfluid::ware::WareParams_t& getGlobalParameters() { return m_GlobalParams; };
124 
125  void setGlobalParameter(const openfluid::ware::WareParamKey_t& Key, const openfluid::ware::WareParamValue_t& Value);
126 
127  void setGlobalParameters(const openfluid::ware::WareParams_t& Params) { m_GlobalParams = Params; };
128 
129  const std::list<ModelItemInstance*>& getItems() const { return m_ModelItems; };
130 
131  void initialize(openfluid::base::SimulationLogger* SimLogger);
132 
133  void finalize();
134 
135  void call_initParams() const;
136 
137  void call_prepareData() const;
138 
139  void call_checkConsistency() const;
140 
141  void call_initializeRun();
142 
143  inline bool hasTimePointToProcess() const
144  { return !m_TimePointList.empty(); };
145 
146  void processNextTimePoint();
147 
149  {
150  if (m_TimePointList.empty()) return -2;
151  return m_TimePointList.front().getTimeIndex();
152  }
153 
154  void call_finalizeRun() const;
155 
156  void resetInitialized() { m_Initialized = false; }
157 
158 };
159 
160 
161 } } //namespaces
162 
163 
164 #endif /* __MODELINSTANCE_H__ */
unsigned long long TimeIndex_t
Definition: DateTime.hpp:62
Definition: StringValue.hpp:91
std::map< WareParamKey_t, WareParamValue_t > WareParams_t
Definition: PluggableWare.hpp:82
openfluid::core::Duration_t getNextTimePointIndex() const
Definition: ModelInstance.hpp:148
Definition: ModelInstance.hpp:68
openfluid::ware::WareParams_t & getGlobalParameters()
Definition: ModelInstance.hpp:123
Abstract class for simulator plugin.
Definition: PluggableSimulator.hpp:113
Definition: SimulationLogger.hpp:61
Definition: SchedulingRequest.hpp:53
bool hasTimePointToProcess() const
Definition: ModelInstance.hpp:143
Definition: ModelItemInstance.hpp:88
Definition: MachineListener.hpp:55
std::string WareID_t
Definition: WareSignature.hpp:86
unsigned int getItemsCount() const
Definition: ModelInstance.hpp:121
const std::list< ModelItemInstance * > & getItems() const
Definition: ModelInstance.hpp:129
void resetInitialized()
Definition: ModelInstance.hpp:156
void setGlobalParameters(const openfluid::ware::WareParams_t &Params)
Definition: ModelInstance.hpp:127
unsigned long long Duration_t
Definition: DateTime.hpp:68
std::string WareParamKey_t
Definition: PluggableWare.hpp:79
Definition: SimulationBlob.hpp:51
Header of ...
Definition: SimulationProfiler.hpp:63
#define DLLEXPORT
Definition: dllexport.hpp:51