Documentation for OpenFLUID 2.2.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SimulatorSignature.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 SimulatorSignature.hpp
35 
36  @author Jean-Christophe FABRE <jean-christophe.fabre@inra.fr>
37 */
38 
39 #ifndef __OPENFLUID_WARE_SIMULATORSIGNATURE_HPP__
40 #define __OPENFLUID_WARE_SIMULATORSIGNATURE_HPP__
41 
42 
43 #include <string>
44 
45 #include <openfluid/config.hpp>
46 #include <openfluid/dllexport.hpp>
47 #include <openfluid/core/TypeDefs.hpp>
50 
51 
52 namespace openfluid { namespace ware {
53 
54 
55 /**
56  Class for storage of the definition of the data handled by the simulator. This is part of the signature.
57 */
59 {
60  public:
61 
62 
63  std::vector<SignatureSpatialDataItem> ProducedVars;
64 
65  std::vector<SignatureSpatialDataItem> UpdatedVars;
66 
67  std::vector<SignatureSpatialDataItem> ProducedAttributes;
68 
69  std::vector<openfluid::core::UnitsClass_t> UsedEventsOnUnits; // TODO add description to units class events?
70 
71 
73  {
74  clear();
75  }
76 
77 
78  void clear()
79  {
80  ProducedVars.clear();
81  UpdatedVars.clear();
82  ProducedAttributes.clear();
83  UsedEventsOnUnits.clear();
84  }
85 
86 };
87 
88 
89 // =====================================================================
90 // =====================================================================
91 
92 
93 /**
94  Class for storage of the definition of spatial units handled by the simulator.
95 */
97 {
98  public:
99 
101 
102  std::string Description;
103 
105  UnitsClass(""),Description("")
106  { }
107 
108  SignatureUnitsClassItem(const openfluid::core::UnitsClass_t& UClass,const std::string& DDescription) :
109  UnitsClass(UClass),Description(DDescription)
110  { }
111 };
112 
113 
114 // =====================================================================
115 // =====================================================================
116 
117 
119 {
120  public:
121 
122  std::string UpdatedUnitsGraph;
123 
124  std::vector<SignatureUnitsClassItem> UpdatedUnitsClasses;
125 
126 
128  {
129  clear();
130  }
131 
132 
133  void clear()
134  {
135  UpdatedUnitsGraph.clear();
136  UpdatedUnitsClasses.clear();
137  }
138 };
139 
140 
141 // =====================================================================
142 // =====================================================================
143 
144 
146 {
147  public:
148 
149  enum class SchedulingType { UNDEFINED, DEFAULT, FIXED, RANGE };
150 
152 
154 
156 
157 
159  {
160  setAsUndefined();
161  }
162 
164  {
165  Type = SchedulingType::UNDEFINED;
166  Min = 0;
167  Max = 0;
168  }
169 
171  {
172  Type = SchedulingType::DEFAULT;
173  Min = 0;
174  Max = 0;
175  }
176 
178  {
179  Type = SchedulingType::FIXED;
180  Min = Val;
181  Max = Val;
182  }
183 
185  {
186  Type = SchedulingType::RANGE;
187  Min = MinVal;
188  Max = MaxVal;
189  }
190 
191  std::string getTypeAsString() const
192  {
193  if (Type == SchedulingType::DEFAULT)
194  {
195  return "default";
196  }
197  else if (Type == SchedulingType::FIXED)
198  {
199  return "fixed";
200  }
201  else if (Type == SchedulingType::RANGE)
202  {
203  return "range";
204  }
205  return "undefined";
206  }
207 
208  void setTypeFromString(const std::string& ST)
209  {
210  Type = SchedulingType::UNDEFINED;
211 
212  if (ST == "default")
213  {
214  Type = SchedulingType::DEFAULT;
215  }
216  else if (ST == "fixed")
217  {
218  Type = SchedulingType::FIXED;
219  }
220  else if (ST == "range")
221  {
222  Type = SchedulingType::RANGE;
223  }
224  }
225 };
226 
227 
228 // =====================================================================
229 // =====================================================================
230 
231 
232 /**
233  Class encapsulating the plugin signature,
234  returned from the plugin to the host app for registering
235 */
237 {
238 
239  public:
240 
242 
243  virtual WareType getType() const
244  {
245  return WareType::SIMULATOR;
246  }
247 
248  /**
249  Handled units graph
250  */
252 
253  /**
254  Time scheduling
255  */
257 
258 
260  {
261  clear();
262  }
263 
264  virtual ~SimulatorSignature() = default;
265 
266  void clear()
267  {
269  HandledUnitsGraph.clear();
270  TimeScheduling.setAsUndefined();
271  }
272 };
273 
274 
275 } } // namespaces
276 
277 
278 #endif /* __OPENFLUID_WARE_SIMULATORSIGNATURE_HPP__ */
Definition: WareSignature.hpp:331
void clear()
Definition: WareSignature.hpp:338
Definition: SimulatorSignature.hpp:146
void setAsFixed(openfluid::core::Duration_t Val)
Definition: SimulatorSignature.hpp:177
std::string getTypeAsString() const
Definition: SimulatorSignature.hpp:191
void setAsDefaultDeltaT()
Definition: SimulatorSignature.hpp:170
SignatureTimeScheduling()
Definition: SimulatorSignature.hpp:158
void setTypeFromString(const std::string &ST)
Definition: SimulatorSignature.hpp:208
openfluid::core::Duration_t Min
Definition: SimulatorSignature.hpp:153
SchedulingType
Definition: SimulatorSignature.hpp:149
void setAsRange(openfluid::core::Duration_t MinVal, openfluid::core::Duration_t MaxVal)
Definition: SimulatorSignature.hpp:184
openfluid::core::Duration_t Max
Definition: SimulatorSignature.hpp:155
SchedulingType Type
Definition: SimulatorSignature.hpp:151
void setAsUndefined()
Definition: SimulatorSignature.hpp:163
Definition: SimulatorSignature.hpp:97
openfluid::core::UnitsClass_t UnitsClass
Definition: SimulatorSignature.hpp:100
SignatureUnitsClassItem(const openfluid::core::UnitsClass_t &UClass, const std::string &DDescription)
Definition: SimulatorSignature.hpp:108
SignatureUnitsClassItem()
Definition: SimulatorSignature.hpp:104
std::string Description
Definition: SimulatorSignature.hpp:102
Definition: SimulatorSignature.hpp:119
std::string UpdatedUnitsGraph
Definition: SimulatorSignature.hpp:122
void clear()
Definition: SimulatorSignature.hpp:133
std::vector< SignatureUnitsClassItem > UpdatedUnitsClasses
Definition: SimulatorSignature.hpp:124
SignatureUnitsGraph()
Definition: SimulatorSignature.hpp:127
Definition: SimulatorSignature.hpp:59
std::vector< SignatureSpatialDataItem > ProducedVars
Definition: SimulatorSignature.hpp:63
std::vector< SignatureSpatialDataItem > UpdatedVars
Definition: SimulatorSignature.hpp:65
std::vector< SignatureSpatialDataItem > ProducedAttributes
Definition: SimulatorSignature.hpp:67
void clear()
Definition: SimulatorSignature.hpp:78
std::vector< openfluid::core::UnitsClass_t > UsedEventsOnUnits
Definition: SimulatorSignature.hpp:69
SimulatorSignatureHandledData()
Definition: SimulatorSignature.hpp:72
Definition: SimulatorSignature.hpp:237
SignatureTimeScheduling TimeScheduling
Definition: SimulatorSignature.hpp:256
virtual WareType getType() const
Definition: SimulatorSignature.hpp:243
SimulatorSignatureHandledData SimulatorHandledData
Definition: SimulatorSignature.hpp:241
SimulatorSignature()
Definition: SimulatorSignature.hpp:259
void clear()
Definition: SimulatorSignature.hpp:266
SignatureUnitsGraph HandledUnitsGraph
Definition: SimulatorSignature.hpp:251
#define OPENFLUID_API
Definition: dllexport.hpp:86
std::uint64_t Duration_t
Definition: TypeDefs.hpp:312
std::string UnitsClass_t
Definition: TypeDefs.hpp:98
WareType
Definition: TypeDefs.hpp:61
Definition: ApplicationException.hpp:47