Documentation for OpenFLUID 2.2.0
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  @file ModelInstance.hpp
35 
36  @author Jean-Christophe FABRE <jean-christophe.fabre@inra.fr>
37  */
38 
39 
40 #ifndef __OPENFLUID_MACHINE_MODELINSTANCE_HPP__
41 #define __OPENFLUID_MACHINE_MODELINSTANCE_HPP__
42 
43 
44 #include <list>
45 
46 #include <openfluid/dllexport.hpp>
51 
52 
53 namespace openfluid { namespace ware {
54 class PluggableSimulator;
55 } }
56 
57 
58 namespace openfluid { namespace machine {
59 
60 class MachineListener;
61 class SimulationBlob;
62 class ModelItemInstance;
63 
64 
66 {
67  private:
68 
69  std::list<ModelItemInstance*> m_ModelItems;
70 
72 
74 
76 
77  openfluid::machine::SimulationBlob& m_SimulationBlob;
78 
79  std::list<ExecutionTimePoint> m_TimePointList;
80 
81  openfluid::ware::WareParams_t m_GlobalParams;
82 
83  bool m_Initialized;
84 
85  void appendItemToTimePoint(openfluid::core::TimeIndex_t TimeIndex, openfluid::machine::ModelItemInstance* Item);
86 
87  void checkDeltaTMode(openfluid::base::SchedulingRequest& SReq, const openfluid::ware::WareID_t& ID);
88 
89 
90  protected:
91 
93 
94 
95  public:
96 
99 
101 
102  void appendItem(ModelItemInstance* ItemInstance);
103 
104  /**
105  Insert a ModelItemInstance before the given postion (positions starts at index 0)
106  @param[in] ItemInstance the ModelItemInstance to insert
107  @param[in] Position the position
108  */
109  void insertItem(ModelItemInstance* ItemInstance, unsigned int Position);
110 
111  /**
112  Delete the ModelItemInstance located at the given postion (positions starts at index 0),
113  and remove it from the ModelInstance
114  @param[in] Position the position
115  */
116  void deleteItem(unsigned int Position);
117 
118  void clear();
119 
120  unsigned int getItemsCount() const
121  {
122  return m_ModelItems.size();
123  }
124 
126  {
127  return m_GlobalParams;
128  }
129 
131 
133  {
134  m_GlobalParams = Params;
135  }
136 
137  const std::list<ModelItemInstance*>& items() const
138  {
139  return m_ModelItems;
140  }
141 
143 
144  void finalize();
145 
146  void call_initParams() const;
147 
148  void call_prepareData() const;
149 
150  void call_checkConsistency() const;
151 
153 
154  inline bool hasTimePointToProcess() const
155  {
156  return !m_TimePointList.empty();
157  }
158 
160 
162  {
163  if (m_TimePointList.empty())
164  {
165  return -2;
166  }
167  return m_TimePointList.front().getTimeIndex();
168  }
169 
170  void call_finalizeRun() const;
171 
173  {
174  m_Initialized = false;
175  }
176 
177 };
178 
179 
180 } } //namespaces
181 
182 
183 #endif /* __OPENFLUID_MACHINE_MODELINSTANCE_HPP__ */
Definition: SchedulingRequest.hpp:54
Definition: SimulationLogger.hpp:58
Definition: StringValue.hpp:83
Definition: MachineListener.hpp:55
Definition: ModelInstance.hpp:66
bool hasTimePointToProcess() const
Definition: ModelInstance.hpp:154
unsigned int getItemsCount() const
Definition: ModelInstance.hpp:120
void appendItem(ModelItemInstance *ItemInstance)
void insertItem(ModelItemInstance *ItemInstance, unsigned int Position)
ModelInstance(openfluid::machine::SimulationBlob &SimulationBlob, openfluid::machine::MachineListener *Listener)
void deleteItem(unsigned int Position)
openfluid::ware::WareParams_t mergeParamsWithGlobalParams(const openfluid::ware::WareParams_t &Params) const
void resetInitialized()
Definition: ModelInstance.hpp:172
void initialize(openfluid::base::SimulationLogger *SimLogger)
openfluid::ware::WareParams_t & globalParameters()
Definition: ModelInstance.hpp:125
const std::list< ModelItemInstance * > & items() const
Definition: ModelInstance.hpp:137
void setGlobalParameter(const openfluid::ware::WareParamKey_t &Key, const openfluid::ware::WareParamValue_t &Value)
openfluid::core::Duration_t getNextTimePointIndex() const
Definition: ModelInstance.hpp:161
void setGlobalParameters(const openfluid::ware::WareParams_t &Params)
Definition: ModelInstance.hpp:132
Definition: ModelItemInstance.hpp:61
Definition: SimulationBlob.hpp:54
Definition: SimulationProfiler.hpp:57
Abstract class for simulator plugin.
Definition: PluggableSimulator.hpp:105
#define OPENFLUID_API
Definition: dllexport.hpp:86
std::uint64_t Duration_t
Definition: TypeDefs.hpp:312
std::uint64_t TimeIndex_t
Definition: TypeDefs.hpp:298
std::string WareID_t
Definition: TypeDefs.hpp:49
std::string WareParamKey_t
Definition: TypeDefs.hpp:142
std::map< WareParamKey_t, WareParamValue_t > WareParams_t
Definition: TypeDefs.hpp:146
Definition: ApplicationException.hpp:47