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 /**
35  @file
36 
37  @author Jean-Christophe FABRE <fabrejc@supagro.inra.fr>
38 */
39 
40 #ifndef __SIMULATORSIGNATURE_HPP__
41 #define __SIMULATORSIGNATURE_HPP__
42 
43 
44 #include <openfluid/config.hpp>
45 #include <openfluid/dllexport.hpp>
49 
50 
51 
52 // =====================================================================
53 // =====================================================================
54 
55 /**
56  Macro for the beginning of definition of signature hook
57 */
58 #define BEGIN_SIMULATOR_SIGNATURE(id) \
59  openfluid::ware::SimulatorSignature* WARESIGNATURE_PROC_DECL() \
60  { \
61  openfluid::ware::SimulatorSignature* Signature = new openfluid::ware::SimulatorSignature(); \
62  Signature->setABIVersion(openfluid::config::FULL_VERSION); \
63  Signature->ID = (id);
64 
65 
66 /**
67  Macro for the end of definition of signature hook
68 */
69 #define END_SIMULATOR_SIGNATURE \
70  return Signature; \
71  }
72 
73 
74 // =====================================================================
75 // =====================================================================
76 
77 
78 /**
79  Macro for declaration of the simulator application domain
80 */
81 #define DECLARE_DOMAIN(domain) Signature->Domain = domain;
82 
83 /**
84  Macro for declaration of the simulator application processes
85 */
86 #define DECLARE_PROCESS(process) Signature->Process = process;
87 
88 /**
89  Macro for declaration of the simulator application numerical method
90 */
91 #define DECLARE_METHOD(method) Signature->Method = method;
92 
93 
94 // =====================================================================
95 // =====================================================================
96 
97 
98 /**
99  Macro for declaration of a simulator parameter
100  @param[in] name name of the parameter
101  @param[in] description description of the parameter
102  @param[in] unit unit of the parameter. Could be an empty string if there is no unit
103 */
104 #define DECLARE_SIMULATOR_PARAM(name,description,unit) \
105  Signature->HandledData.SimulatorParams.push_back(openfluid::ware::SignatureHandledDataItem((name),(""),description,unit));
106 
107 
108 
109 // =====================================================================
110 // =====================================================================
111 
112 
113 /**
114  Macro for declaration of a produced variable
115  @param[in] name name of the variable
116  @param[in] uclass class of the concerned units
117  @param[in] description description of the variable
118  @param[in] unit unit of the variable. Could be an empty string if there is no unit
119 */
120 #define DECLARE_PRODUCED_VAR(name,uclass,description,unit) \
121  Signature->HandledData.ProducedVars.push_back(openfluid::ware::SignatureHandledTypedDataItem((name),uclass,description,unit));
122 
123 /**
124  Macro for declaration of an updated variable
125  @param[in] name name of the variable
126  @param[in] uclass class of the concerned units
127  @param[in] description description of the variable
128  @param[in] unit unit of the variable. Could be an empty string if there is no unit
129 */
130 #define DECLARE_UPDATED_VAR(name,uclass,description,unit) \
131  Signature->HandledData.UpdatedVars.push_back(openfluid::ware::SignatureHandledTypedDataItem((name),uclass,description,unit));
132 
133 /**
134  Macro for declaration of a required variable
135  @param[in] name name of the variable
136  @param[in] uclass class of the concerned units
137  @param[in] description description of the variable
138  @param[in] unit unit of the variable. Could be an empty string if there is no unit
139 */
140 #define DECLARE_REQUIRED_VAR(name,uclass,description,unit) \
141  Signature->HandledData.RequiredVars.push_back(openfluid::ware::SignatureHandledTypedDataItem((name),uclass,description,unit));
142 
143 
144 /**
145  Macro for declaration of an used variable
146  @param[in] name name of the variable
147  @param[in] uclass class of the concerned units
148  @param[in] description description of the variable
149  @param[in] unit unit of the variable. Could be an empty string if there is no unit
150 */
151 #define DECLARE_USED_VAR(name,uclass,description,unit) \
152  Signature->HandledData.UsedVars.push_back(openfluid::ware::SignatureHandledTypedDataItem((name),uclass,description,unit));
153 
154 
155 /**
156  Macro for declaration of a produced attribute
157  @param[in] name name of the attribute
158  @param[in] uclass class of the concerned units
159  @param[in] description description of the attribute
160  @param[in] unit unit of the attribute. Could be an empty string if there is no unit
161 */
162 #define DECLARE_PRODUCED_ATTRIBUTE(name,uclass,description,unit) \
163  Signature->HandledData.ProducedAttribute.push_back(openfluid::ware::SignatureHandledDataItem((name),uclass,description,unit));
164 
165 /**
166  Macro for declaration of a required attribute
167  @param[in] name name of the attribute
168  @param[in] uclass class of the concerned units
169  @param[in] description description of the attribute
170  @param[in] unit unit of the attribute. Could be an empty string if there is no unit
171 */
172 #define DECLARE_REQUIRED_ATTRIBUTE(name,uclass,description,unit) \
173  Signature->HandledData.RequiredAttribute.push_back(openfluid::ware::SignatureHandledDataItem((name),uclass,description,unit));
174 
175 /**
176  Macro for declaration of a used attribute
177  @param[in] name name of the attribute
178  @param[in] uclass class of the concerned units
179  @param[in] description description of the attribute
180  @param[in] unit unit of the attribute. Could be an empty string if there is no unit
181 */
182 #define DECLARE_USED_ATTRIBUTE(name,uclass,description,unit) \
183  Signature->HandledData.UsedAttribute.push_back(openfluid::ware::SignatureHandledDataItem((name),uclass,description,unit));
184 
185 /**
186  Macro for declaration of used events
187  @param[in] uclass class of the concerned units
188 */
189 #define DECLARE_USED_EVENTS(uclass) Signature->HandledData.UsedEventsOnUnits.push_back(uclass);
190 
191 
192 
193 /**
194  Macro for declaration of units graph modification
195  @param[in] description description of modification
196 
197 */
198 #define DECLARE_UPDATED_UNITSGRAPH(description) Signature->HandledUnitsGraph.UpdatedUnitsGraph = (description);
199 
200 
201 /**
202  Macro for declaration of units class creation or update
203  @param[in] uclass name of the created or updated class
204  @param[in] description description of the updated class
205 
206 */
207 #define DECLARE_UPDATED_UNITSCLASS(uclass,description) Signature->HandledUnitsGraph.UpdatedUnitsClass.push_back(openfluid::ware::SignatureHandledUnitsClassItem(uclass,description));
208 
209 
210 /**
211  Macro for declaration of required file
212  @param[in] name name of the file
213 */
214 #define DECLARE_REQUIRED_EXTRAFILE(name) \
215  Signature->HandledData.RequiredExtraFiles.push_back(name);
216 
217 /**
218  Macro for declaration of used file
219  @param[in] name name of the file
220 */
221 #define DECLARE_USED_EXTRAFILE(name) \
222  Signature->HandledData.UsedExtraFiles.push_back(name);
223 
224 /**
225  Macro for declaration of time scheduling as undefined
226 */
227 #define DECLARE_SCHEDULING_UNDEFINED \
228  Signature->TimeScheduling.setAsUndefined();
229 
230 /**
231  Macro for declaration of time scheduling as default delta T
232 */
233 #define DECLARE_SCHEDULING_DEFAULT \
234  Signature->TimeScheduling.setAsDefaultDeltaT();
235 
236 /**
237  Macro for declaration of fixed time scheduling
238  @param[in] deltat fixed time scheduling value
239 */
240 #define DECLARE_SCHEDULING_FIXED(deltat) \
241  Signature->TimeScheduling.setAsFixed(deltat);
242 
243 /**
244  Macro for declaration of range of time scheduling
245  @param[in] min minimal time scheduling value
246  @param[in] max maximal time scheduling value
247 */
248 #define DECLARE_SCHEDULING_RANGE(min,max) \
249  Signature->TimeScheduling.setAsRange(min,max);
250 
251 
252 // =====================================================================
253 // =====================================================================
254 
255 
256 
257 namespace openfluid { namespace ware {
258 
259 
260 typedef std::string SimMethod_t;
261 
262 typedef std::string SimProcess_t;
263 
264 typedef std::string SimDomain_t;
265 
266 
267 // =====================================================================
268 // =====================================================================
269 
270 
271 /**
272 Class for storage of the definition of data handled by the simulator.
273 */
275 {
276  public:
277 
278  std::string DataName;
280  std::string Description;
281  std::string DataUnit;
282 
284  DataName(""),UnitClass(""),Description(""),DataUnit("") {}
285 
287  std::string DDescription, std::string DUnit) :
288  DataName(DName),UnitClass(UClass),Description(DDescription),DataUnit(DUnit) {}
289 
290 };
291 
292 /**
293 Class for storage of the definition of typed data handled by the simulator.
294 */
296 {
297 
298  public:
299 
300  static bool getVariableNameAndType(const std::string SourceStr, std::string& VarName, openfluid::core::Value::Type& VarType);
301 
303 
305  SignatureHandledDataItem(), DataType(openfluid::core::Value::NONE) {}
306 
308  std::string DDescription, std::string DUnit);
309 };
310 
311 
312 /**
313  Class for storage of the definition of spatial units handled by the simulator.
314 */
316 {
317  public:
318 
320  std::string Description;
321 
323  UnitsClass(""),Description("") {}
324 
326  std::string DDescription) :
327  UnitsClass(UClass),Description(DDescription) {}
328 };
329 
330 
331 /**
332  Class for storage of the definition of the data handled by the simulator. This is part of the signature.
333 */
335 {
336  public:
337 
338  std::vector<SignatureHandledTypedDataItem> ProducedVars;
339 
340  std::vector<SignatureHandledTypedDataItem> UpdatedVars;
341 
342  std::vector<SignatureHandledTypedDataItem> RequiredVars;
343 
344  std::vector<SignatureHandledTypedDataItem> UsedVars;
345 
346  std::vector<SignatureHandledDataItem> SimulatorParams;
347 
348  std::vector<SignatureHandledDataItem> ProducedAttribute;
349 
350  std::vector<SignatureHandledDataItem> RequiredAttribute;
351 
352  std::vector<SignatureHandledDataItem> UsedAttribute;
353 
354  std::vector<std::string> RequiredExtraFiles;
355 
356  std::vector<std::string> UsedExtraFiles;
357 
358  std::vector<openfluid::core::UnitClass_t> UsedEventsOnUnits;
359 
360 
362  {
363 
364  }
365 
366 };
367 
368 
370 {
371  public:
372 
373  std::string UpdatedUnitsGraph;
374 
375  std::vector<SignatureHandledUnitsClassItem> UpdatedUnitsClass;
376 
378  {
379  UpdatedUnitsGraph.clear();
380  }
381 };
382 
383 
385 {
386  public:
387 
388  enum SchedulingType { UNDEFINED, DEFAULT, FIXED, RANGE };
389 
391 
393 
395 
397  Type(UNDEFINED), Min(0), Max(0)
398  { }
399 
401  {
402  Type = UNDEFINED;
403  Min = 0;
404  Max = 0;
405  }
406 
408  {
409  Type = DEFAULT;
410  Min = 0;
411  Max = 0;
412  }
413 
415  {
416  Type = FIXED;
417  Min = Val;
418  Max = Val;
419  }
420 
422  {
423  Type = RANGE;
424  Min = MinVal;
425  Max = MaxVal;
426  }
427 
428 };
429 
430 
431 /**
432  Class encapsulating the plugin signature,
433  returned from the plugin to the host app for registering
434 */
436 {
437 
438  public:
439 
440 
441  /**
442  Plugin domain (i.e. hydrology, pop, erosion, ...)
443  */
445 
446  /**
447  Plugin simulated process (i.e. surface rainfall-runoff production, ditch infiltration, ...)
448  */
450 
451  /**
452  Plugin involved method (i.e. morel-seytoux, hayami, ...)
453  */
455 
456  /**
457  Handled data
458  */
460 
461  /**
462  Handled units graph
463  */
465 
466  /**
467  Time scheduling
468  */
470 
472  Domain(""),Process(""),Method("")
473  {}
474 
475 };
476 
477 
478 
479 } } // namespaces
480 
481 
482 
483 #endif
std::vector< std::string > UsedExtraFiles
Definition: SimulatorSignature.hpp:356
std::string SimProcess_t
Definition: SimulatorSignature.hpp:262
SignatureHandledDataItem(std::string DName, openfluid::core::UnitClass_t UClass, std::string DDescription, std::string DUnit)
Definition: SimulatorSignature.hpp:286
SignatureHandledTypedDataItem()
Definition: SimulatorSignature.hpp:304
Definition: WareSignature.hpp:119
SimProcess_t Process
Definition: SimulatorSignature.hpp:449
std::vector< SignatureHandledDataItem > UsedAttribute
Definition: SimulatorSignature.hpp:352
std::string Description
Definition: SimulatorSignature.hpp:320
std::vector< openfluid::core::UnitClass_t > UsedEventsOnUnits
Definition: SimulatorSignature.hpp:358
std::string SimMethod_t
Definition: SimulatorSignature.hpp:260
void setAsDefaultDeltaT()
Definition: SimulatorSignature.hpp:407
SignatureTimeScheduling TimeScheduling
Definition: SimulatorSignature.hpp:469
Definition: SimulatorSignature.hpp:384
std::string SimDomain_t
Definition: SimulatorSignature.hpp:264
SimDomain_t Domain
Definition: SimulatorSignature.hpp:444
std::vector< SignatureHandledDataItem > RequiredAttribute
Definition: SimulatorSignature.hpp:350
std::string DataUnit
Definition: SimulatorSignature.hpp:281
SignatureHandledUnitsGraph()
Definition: SimulatorSignature.hpp:377
SignatureHandledUnitsClassItem()
Definition: SimulatorSignature.hpp:322
SignatureHandledUnitsClassItem(openfluid::core::UnitClass_t UClass, std::string DDescription)
Definition: SimulatorSignature.hpp:325
SignatureHandledDataItem()
Definition: SimulatorSignature.hpp:283
SimMethod_t Method
Definition: SimulatorSignature.hpp:454
SchedulingType
Definition: SimulatorSignature.hpp:388
std::string UnitClass_t
Definition: TypeDefs.hpp:69
Definition: SimulatorSignature.hpp:388
openfluid::core::Duration_t Max
Definition: SimulatorSignature.hpp:394
std::vector< SignatureHandledTypedDataItem > ProducedVars
Definition: SimulatorSignature.hpp:338
Definition: SimulatorSignature.hpp:369
std::vector< SignatureHandledTypedDataItem > RequiredVars
Definition: SimulatorSignature.hpp:342
SignatureHandledData()
Definition: SimulatorSignature.hpp:361
std::vector< SignatureHandledTypedDataItem > UsedVars
Definition: SimulatorSignature.hpp:344
std::vector< SignatureHandledDataItem > ProducedAttribute
Definition: SimulatorSignature.hpp:348
openfluid::core::UnitClass_t UnitClass
Definition: SimulatorSignature.hpp:279
std::vector< SignatureHandledUnitsClassItem > UpdatedUnitsClass
Definition: SimulatorSignature.hpp:375
std::string UpdatedUnitsGraph
Definition: SimulatorSignature.hpp:373
Type
Definition: Value.hpp:68
SchedulingType Type
Definition: SimulatorSignature.hpp:390
openfluid::core::Value::Type DataType
Definition: SimulatorSignature.hpp:302
openfluid::core::UnitClass_t UnitsClass
Definition: SimulatorSignature.hpp:319
SimulatorSignature()
Definition: SimulatorSignature.hpp:471
void setAsRange(openfluid::core::Duration_t MinVal, openfluid::core::Duration_t MaxVal)
Definition: SimulatorSignature.hpp:421
Definition: SimulatorSignature.hpp:315
Definition: SimulatorSignature.hpp:274
Header of ...
SignatureTimeScheduling()
Definition: SimulatorSignature.hpp:396
SignatureHandledUnitsGraph HandledUnitsGraph
Definition: SimulatorSignature.hpp:464
SignatureHandledData HandledData
Definition: SimulatorSignature.hpp:459
Definition: SimulatorSignature.hpp:435
unsigned long long Duration_t
Definition: DateTime.hpp:68
std::vector< SignatureHandledTypedDataItem > UpdatedVars
Definition: SimulatorSignature.hpp:340
void setAsFixed(openfluid::core::Duration_t Val)
Definition: SimulatorSignature.hpp:414
void setAsUndefined()
Definition: SimulatorSignature.hpp:400
std::string DataName
Definition: SimulatorSignature.hpp:278
std::string Description
Definition: SimulatorSignature.hpp:280
openfluid::core::Duration_t Min
Definition: SimulatorSignature.hpp:392
Definition: SimulatorSignature.hpp:295
std::vector< SignatureHandledDataItem > SimulatorParams
Definition: SimulatorSignature.hpp:346
Definition: SimulatorSignature.hpp:334
std::vector< std::string > RequiredExtraFiles
Definition: SimulatorSignature.hpp:354
#define DLLEXPORT
Definition: dllexport.hpp:51