Manual for OpenFLUID 2.1.11

SimulationContributorWare.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 SimulationContributorWare.hpp
35 
36  @author Jean-Christophe FABRE <jean-christophe.fabre@inra.fr>
37 */
38 
39 
40 #ifndef __OPENFLUID_WARE_SIMULATIONCONTRIBUTORWARE_HPP__
41 #define __OPENFLUID_WARE_SIMULATIONCONTRIBUTORWARE_HPP__
42 
43 
44 #include <openfluid/dllexport.hpp>
46 
47 
48 namespace openfluid { namespace ware {
49 
50 
52 {
53  private:
54 
55  protected:
56 
57  /**
58  Sets attribute for a unit
59  @param[in] UnitPtr a Unit
60  @param[in] AttrName the name of the set attribute
61  @param[in] Val the value of the set attribute
62 
63  @cond OpenFLUID:completion
64  {
65  "contexts" : ["SIMULATOR"],
66  "menupath" : ["Compute code", "Attributes"],
67  "title" : "Set attribute value",
68  "text" : "OPENFLUID_SetAttribute(%%SEL_START%%UnitPtr%%SEL_END%%,\"attrname\",Val)"
69  }
70  @endcond
71  */
72  void OPENFLUID_SetAttribute(openfluid::core::SpatialUnit *UnitPtr,
73  const openfluid::core::AttributeName_t& AttrName,
74  const openfluid::core::Value& Val);
75 
76  /**
77  Sets attribute for a unit, as a double
78  @param[in] UnitPtr a Unit
79  @param[in] AttrName the name of the set attribute
80  @param[in] Val the value of the set attribute
81  */
82  void OPENFLUID_SetAttribute(openfluid::core::SpatialUnit *UnitPtr,
83  const openfluid::core::AttributeName_t& AttrName,
84  const double& Val);
85 
86  /**
87  Sets attribute for a unit, as a boolean
88  @param[in] UnitPtr a Unit
89  @param[in] AttrName the name of the set attribute
90  @param[in] Val the value of the set attribute
91  */
92  void OPENFLUID_SetAttribute(openfluid::core::SpatialUnit *UnitPtr,
93  const openfluid::core::AttributeName_t& AttrName,
94  bool Val);
95 
96  /**
97  Sets attribute for a unit, as a long integer
98  @param[in] UnitPtr a Unit
99  @param[in] AttrName the name of the set attribute
100  @param[in] Val the value of the set attribute
101  */
102  void OPENFLUID_SetAttribute(openfluid::core::SpatialUnit *UnitPtr,
103  const openfluid::core::AttributeName_t& AttrName,
104  const long& Val);
105 
106  /**
107  Sets attribute for a unit, as a string
108  @param[in] UnitPtr a Unit
109  @param[in] AttrName the name of the set attribute
110  @param[out] Val the value of the set attribute
111  */
112  void OPENFLUID_SetAttribute(openfluid::core::SpatialUnit *UnitPtr,
113  const openfluid::core::AttributeName_t& AttrName,
114  const std::string& Val);
115 
116 
117  /**
118  Initializes a distributed variable value for a unit
119  @param[in] UnitPtr a Unit
120  @param[in] VarName the name of the variable
121  @param[in] Val the added value of the variable
122  */
123  void OPENFLUID_InitializeVariable(openfluid::core::SpatialUnit *UnitPtr,
124  const openfluid::core::VariableName_t& VarName,
125  const openfluid::core::Value& Val);
126 
127  /**
128  Initializes a distributed variable value for a unit
129  @param[in] aUnit a Unit
130  @param[in] VarName the name of the variable
131  @param[in] Val the added value of the variable
132 
133  @cond OpenFLUID:completion
134  {
135  "contexts" : ["SIMULATOR"],
136  "menupath" : ["Compute code", "Variables"],
137  "title" : "Initialize variable with value",
138  "text" : "OPENFLUID_InitializeVariable(%%SEL_START%%UnitPtr%%SEL_END%%,\"varname\",Val)"
139  }
140  @endcond
141  */
142  void OPENFLUID_InitializeVariable(openfluid::core::SpatialUnit& aUnit,
143  const openfluid::core::VariableName_t& VarName,
144  const openfluid::core::Value& Val);
145 
146  /**
147  Initializes a distributed double variable value for a unit
148  @param[in] UnitPtr a Unit
149  @param[in] VarName the name of the variable
150  @param[in] Val the added value of the variable (double)
151  */
152  void OPENFLUID_InitializeVariable(openfluid::core::SpatialUnit *UnitPtr,
153  const openfluid::core::VariableName_t& VarName,
154  const double& Val);
155 
156  /**
157  Initializes a distributed long variable value for a unit
158  @param[in] UnitPtr a Unit
159  @param[in] VarName the name of the variable
160  @param[in] Val the added value of the variable (long)
161  */
162  void OPENFLUID_InitializeVariable(openfluid::core::SpatialUnit *UnitPtr,
163  const openfluid::core::VariableName_t& VarName,
164  const long& Val);
165 
166  /**
167  Initializes a distributed boolean variable value for a unit
168  @param[in] UnitPtr a Unit
169  @param[in] VarName the name of the variable
170  @param[in] Val the added value of the variable (bool)
171  */
172  void OPENFLUID_InitializeVariable(openfluid::core::SpatialUnit *UnitPtr,
173  const openfluid::core::VariableName_t& VarName,
174  const bool& Val);
175 
176  /**
177  Initializes a distributed string variable value for a unit
178  @param[in] UnitPtr a Unit
179  @param[in] VarName the name of the variable
180  @param[in] Val the added value of the variable (string)
181  @warning Use std::string("text") instead of "text" as a value for the Val parameter
182  to avoid the automatic overloading between char* and bool types
183  */
184  void OPENFLUID_InitializeVariable(openfluid::core::SpatialUnit *UnitPtr,
185  const openfluid::core::VariableName_t& VarName,
186  const std::string& Val);
187 
188  /**
189  Appends a distributed variable value for a unit at the end
190  of the previously added values for this variable
191  @param[in] UnitPtr a Unit
192  @param[in] VarName the name of the variable
193  @param[in] Val the added value of the variable
194 
195  @cond OpenFLUID:completion
196  {
197  "contexts" : ["SIMULATOR"],
198  "menupath" : ["Compute code", "Variables"],
199  "title" : "Append value to a variable",
200  "text" : "OPENFLUID_AppendVariable(%%SEL_START%%UnitPtr%%SEL_END%%,\"varname\",Val)"
201  }
202  @endcond
203  */
204  void OPENFLUID_AppendVariable(openfluid::core::SpatialUnit *UnitPtr,
205  const openfluid::core::VariableName_t& VarName,
206  const openfluid::core::Value& Val);
207 
208  /**
209  Appends a distributed variable value for a unit at the end
210  of the previously added values for this variable
211  @param[in] aUnit a Unit
212  @param[in] VarName the name of the variable
213  @param[in] Val the added value of the variable
214  */
215  void OPENFLUID_AppendVariable(openfluid::core::SpatialUnit& aUnit,
216  const openfluid::core::VariableName_t& VarName,
217  const openfluid::core::Value& Val);
218 
219  /**
220  Appends a distributed double variable value for a unit at the end
221  of the previously added values for this variable
222  @param[in] UnitPtr a Unit
223  @param[in] VarName the name of the variable
224  @param[in] Val the added value of the variable (double)
225  */
226  void OPENFLUID_AppendVariable(openfluid::core::SpatialUnit *UnitPtr,
227  const openfluid::core::VariableName_t& VarName,
228  const double& Val);
229 
230  /**
231  Appends a distributed long variable value for a unit at the end
232  of the previously added values for this variable
233  @param[in] UnitPtr a Unit
234  @param[in] VarName the name of the variable
235  @param[in] Val the added value of the variable (long)
236  */
237  void OPENFLUID_AppendVariable(openfluid::core::SpatialUnit *UnitPtr,
238  const openfluid::core::VariableName_t& VarName,
239  const long& Val);
240 
241  /**
242  Appends a distributed boolean variable value for a unit at the end
243  of the previously added values for this variable
244  @param[in] UnitPtr a Unit
245  @param[in] VarName the name of the variable
246  @param[in] Val the added value of the variable (bool)
247  */
248  void OPENFLUID_AppendVariable(openfluid::core::SpatialUnit *UnitPtr,
249  const openfluid::core::VariableName_t& VarName,
250  const bool& Val);
251 
252  /**
253  Appends a distributed string variable value for a unit at the end
254  of the previously added values for this variable
255  @param[in] UnitPtr a Unit
256  @param[in] VarName the name of the variable
257  @param[in] Val the added value of the variable (string)
258  @warning Use std::string("text") instead of "text" as a value for the Val parameter
259  to avoid the automatic overloading between char* and bool types
260  */
261  void OPENFLUID_AppendVariable(openfluid::core::SpatialUnit *UnitPtr,
262  const openfluid::core::VariableName_t& VarName,
263  const std::string& Val);
264 
265 
266  /**
267  Sets a distributed variable value for a unit at the current time index
268  @param[in] UnitPtr a Unit
269  @param[in] VarName the name of the variable
270  @param[in] Val the added value of the variable
271 
272  @cond OpenFLUID:completion
273  {
274  "contexts" : ["SIMULATOR"],
275  "menupath" : ["Compute code", "Variables"],
276  "title" : "Update current value of a variable",
277  "text" : "OPENFLUID_SetVariable(%%SEL_START%%UnitPtr%%SEL_END%%,\"varname\",Val)"
278  }
279  @endcond
280  */
281  void OPENFLUID_SetVariable(openfluid::core::SpatialUnit *UnitPtr,
282  const openfluid::core::VariableName_t& VarName,
283  const openfluid::core::Value& Val);
284 
285  /**
286  Sets a distributed double variable value for a unit at the current time index
287  @param[in] UnitPtr a Unit
288  @param[in] VarName the name of the variable
289  @param[in] Val the added value of the variable (double)
290  */
291  void OPENFLUID_SetVariable(openfluid::core::SpatialUnit *UnitPtr,
292  const openfluid::core::VariableName_t& VarName,
293  const double& Val);
294 
295  /**
296  Sets a distributed double variable value for a unit at the current time index
297  @param[in] UnitPtr a Unit
298  @param[in] VarName the name of the variable
299  @param[in] Val the added value of the variable (long)
300  */
301  void OPENFLUID_SetVariable(openfluid::core::SpatialUnit *UnitPtr,
302  const openfluid::core::VariableName_t& VarName,
303  const long& Val);
304 
305  /**
306  Sets a distributed double variable value for a unit at the current time index
307  @param[in] UnitPtr a Unit
308  @param[in] VarName the name of the variable
309  @param[in] Val the added value of the variable (bool)
310  */
311  void OPENFLUID_SetVariable(openfluid::core::SpatialUnit *UnitPtr,
312  const openfluid::core::VariableName_t& VarName,
313  const bool& Val);
314 
315  /**
316  Sets a distributed double variable value for a unit at the current time index
317  @param[in] UnitPtr a Unit
318  @param[in] VarName the name of the variable
319  @param[in] Val the added value of the variable (string)
320  */
321  void OPENFLUID_SetVariable(openfluid::core::SpatialUnit *UnitPtr,
322  const openfluid::core::VariableName_t& VarName,
323  const std::string& Val);
324 
325  /**
326  Appends an event on a unit
327  @param[in] UnitPtr a Unit
328  @param[in] Ev the event to append
329 
330  @cond OpenFLUID:completion
331  {
332  "contexts" : ["SIMULATOR"],
333  "menupath" : ["Compute code", "Events"],
334  "title" : "Append an event",
335  "text" : "OPENFLUID_AppendEvent(%%SEL_START%%UnitPtr%%SEL_END%%,Event)"
336  }
337  @endcond
338  */
339  void OPENFLUID_AppendEvent(openfluid::core::SpatialUnit *UnitPtr,
341 
342 
343  /**
344  Adds a unit to the set of units if not already exists
345  @param[in] ClassName class name of the added unit
346  @param[in] ID ID of the added unit
347  @param[in] PcsOrder Process order of the added unit
348 
349  @cond OpenFLUID:completion
350  {
351  "contexts" : ["SIMULATOR"],
352  "menupath" : ["Compute code", "Spatial structure"],
353  "title" : "Add a spatial unit to the spatial graph",
354  "text" : "OPENFLUID_AddUnit(%%SEL_START%%ClassName%%SEL_END%%,UnitID,PcsOrder)"
355  }
356  @endcond
357  */
358  void OPENFLUID_AddUnit(const openfluid::core::UnitsClass_t& ClassName,
360  openfluid::core::PcsOrd_t PcsOrder);
361 
362  /**
363  Deletes a unit from the set of units if exists
364  @param[in] ClassName class name of the removed unit
365  @param[in] ID ID of the added unit
366  @return true if the unit has been correctly deleted
367 
368  @cond OpenFLUID:completion
369  {
370  "contexts" : ["SIMULATOR"],
371  "menupath" : ["Compute code", "Spatial structure"],
372  "title" : "Delete a spatial unit of the spatial graph",
373  "text" : "OPENFLUID_DeleteUnit(%%SEL_START%%ClassName%%SEL_END%%,ID)"
374  }
375  @endcond
376  */
377  void OPENFLUID_DeleteUnit(const openfluid::core::UnitsClass_t& ClassName,
379 
380 
381  /**
382  Adds a from-to connection between two units
383  @param[in] ClassNameFrom class name of the "from" unit
384  @param[in] IDFrom ID of the "from" unit
385  @param[in] ClassNameTo class name of the "to" unit
386  @param[in] IDTo ID of the "to" unit
387  @return false if the unit connection already exists
388 
389  @cond OpenFLUID:completion
390  {
391  "contexts" : ["SIMULATOR"],
392  "menupath" : ["Compute code", "Spatial structure"],
393  "title" : "Add a From-To connection using classes names and IDs",
394  "text" : "OPENFLUID_AddFromToConnection(%%SEL_START%%ClassNameFrom%%SEL_END%%,UnitIDFrom,ClassNameTo,UnitIDTo)"
395  }
396  @endcond
397  */
398  bool OPENFLUID_AddFromToConnection(const openfluid::core::UnitsClass_t& ClassNameFrom,
400  const openfluid::core::UnitsClass_t& ClassNameTo,
402 
403  /**
404  Adds a from-to connection between two units
405  @param[in] FromUnit pointer to the "from" unit
406  @param[in] ToUnit pointer to the "to" unit
407  @return false if the connection already exists
408 
409  @cond OpenFLUID:completion
410  {
411  "contexts" : ["SIMULATOR"],
412  "menupath" : ["Compute code", "Spatial structure"],
413  "title" : "Add a From-To connection using pointers to spatial units",
414  "text" : "OPENFLUID_AddFromToConnection(%%SEL_START%%FromUnitPtr%%SEL_END%%,ToUnitPtr)"
415  }
416  @endcond
417  */
418  bool OPENFLUID_AddFromToConnection(openfluid::core::SpatialUnit* FromUnit,
420 
421  /**
422  Removes a from-to connection between two units
423  @param[in] ClassNameFrom class name of the "from" unit
424  @param[in] IDFrom ID of the "from" unit
425  @param[in] ClassNameTo class name of the "to" unit
426  @param[in] IDTo ID of the "to" unit
427  @return false if the unit connection does not exist
428 
429  @cond OpenFLUID:completion
430  {
431  "contexts" : ["SIMULATOR"],
432  "menupath" : ["Compute code", "Spatial structure"],
433  "title" : "Remove a From-To connection using classes names and IDs",
434  "text" : ["OPENFLUID_RemoveFromToConnection(%%SEL_START%%ClassNameFrom%%SEL_END%%,",
435  "UnitIDFrom,ClassNameTo,UnitIDTo)"]
436  }
437  @endcond
438  */
439  bool OPENFLUID_RemoveFromToConnection(const openfluid::core::UnitsClass_t& ClassNameFrom,
441  const openfluid::core::UnitsClass_t& ClassNameTo,
443 
444  /**
445  Removes a from-to connection between two units
446  @param[in] FromUnit pointer to the "from" unit
447  @param[in] ToUnit pointer to the "to" unit
448  @return false if the connection does not exist
449 
450  @cond OpenFLUID:completion
451  {
452  "contexts" : ["SIMULATOR"],
453  "menupath" : ["Compute code", "Spatial structure"],
454  "title" : "Remove a From-To connection using spatial units pointers",
455  "text" : "OPENFLUID_RemoveFromToConnection(%%SEL_START%%FromUnitPtr%%SEL_END%%,ToUnitPtr)"
456  }
457  @endcond
458  */
459  bool OPENFLUID_RemoveFromToConnection(openfluid::core::SpatialUnit* FromUnit,
461 
462 
463  /**
464  Adds a child-parent connection between two units
465  @param[in] ClassNameChild class name of the "child" unit
466  @param[in] IDChild ID of the "child" unit
467  @param[in] ClassNameParent class name of the "parent" unit
468  @param[in] IDParent ID of the "parent" unit
469  @return false if the connection already exists
470 
471  @cond OpenFLUID:completion
472  {
473  "contexts" : ["SIMULATOR"],
474  "menupath" : ["Compute code", "Spatial structure"],
475  "title" : "Add a Child-parent connection using classes names and IDs",
476  "text" : ["OPENFLUID_AddChildParentConnection(%%SEL_START%%ClassNameChild%%SEL_END%%,",
477  "UnitIDChild,ClassNameParent,UnitIDParent)"]
478  }
479  @endcond
480  */
481  bool OPENFLUID_AddChildParentConnection(const openfluid::core::UnitsClass_t& ClassNameChild,
483  const openfluid::core::UnitsClass_t& ClassNameParent,
484  openfluid::core::UnitID_t IDParent);
485 
486  /**
487  Adds a child-parent connection between two units
488  @param[in] ChildUnit pointer to the "child" unit
489  @param[in] ParentUnit pointer to the "parent" unit
490  @return false if the connection already exists
491 
492  @cond OpenFLUID:completion
493  {
494  "contexts" : ["SIMULATOR"],
495  "menupath" : ["Compute code", "Spatial structure"],
496  "title" : "Add a Child-parent connection using pointers to spatial units",
497  "text" : "OPENFLUID_AddChildParentConnection(%%SEL_START%%ChildUnitPtr%%SEL_END%%,ParentUnitPtr)"
498  }
499  @endcond
500  */
501  bool OPENFLUID_AddChildParentConnection(openfluid::core::SpatialUnit* ChildUnit,
502  openfluid::core::SpatialUnit* ParentUnit);
503 
504 
505  /**
506  Removes a child-parent connection between two units
507  @param[in] ClassNameChild class name of the "child" unit
508  @param[in] IDChild ID of the "child" unit
509  @param[in] ClassNameParent class name of the "parent" unit
510  @param[in] IDParent ID of the "parent" unit
511  @return false if the connection does not exist
512 
513  @cond OpenFLUID:completion
514  {
515  "contexts" : ["SIMULATOR"],
516  "menupath" : ["Compute code", "Spatial structure"],
517  "title" : "Remove a Child-parent connection using classes names and IDs",
518  "text" : ["OPENFLUID_RemoveChildParentConnection(%%SEL_START%%ClassNameChild%%SEL_END%%,",
519  "UnitIDChild,ClassNameParent,UnitIDParent)"]
520  }
521  @endcond
522  */
523  bool OPENFLUID_RemoveChildParentConnection(const openfluid::core::UnitsClass_t& ClassNameChild,
525  const openfluid::core::UnitsClass_t& ClassNameParent,
526  openfluid::core::UnitID_t IDParent);
527 
528  /**
529  Removes a child-parent connection between two units
530  @param[in] ChildUnit pointer to the "child" unit
531  @param[in] ParentUnit pointer to the "parent" unit
532  @return false if the connection does not exist
533 
534  @cond OpenFLUID:completion
535  {
536  "contexts" : ["SIMULATOR"],
537  "menupath" : ["Compute code", "Spatial structure"],
538  "title" : "Remove a Child-parent connection using pointers to spatial units",
539  "text" : "OPENFLUID_RemoveChildParentConnection(%%SEL_START%%ChildUnitPtr%%SEL_END%%,ParentUnitPtr)"
540  }
541  @endcond
542  */
543  bool OPENFLUID_RemoveChildParentConnection(openfluid::core::SpatialUnit* ChildUnit,
544  openfluid::core::SpatialUnit* ParentUnit);
545 
546  /**
547  Builds a ColsNbr x RowsNbr unix matrix with bi-directionnal connections
548  @param[in] UnitsClass the name of units class
549  @param[in] ColsNbr the number of units on the X axis
550  @param[in] RowsNbr the number of units on the Y axis
551 
552  @cond OpenFLUID:completion
553  {
554  "contexts" : ["SIMULATOR"],
555  "menupath" : ["Compute code", "Spatial structure"],
556  "title" : "Build a matrix of spatial units",
557  "text" : "OPENFLUID_BuildUnitsMatrix(%%SEL_START%%ClassName%%SEL_END%%,ColsNbr,RowsNbr)"
558  }
559  @endcond
560  */
561  void OPENFLUID_BuildUnitsMatrix(const openfluid::core::UnitsClass_t& UnitsClass,
562  const unsigned int& ColsNbr,
563  const unsigned int& RowsNbr);
564 
566  { }
567 
568 
569  public:
570 
572  { }
573 
574 };
575 
576 
577 } } // openfluid::ware
578 
579 
580 #endif /* __OPENFLUID_WARE_SIMULATIONCONTRIBUTORWARE_HPP__ */
openfluid::core::Event
Definition: Event.hpp:68
openfluid::core::SpatialUnit
Definition: SpatialUnit.hpp:110
SimulationInspectorWare.hpp
openfluid::core::Value
Definition: Value.hpp:62
OPENFLUID_API
#define OPENFLUID_API
Definition: dllexport.hpp:86
openfluid::core::AttributeName_t
std::string AttributeName_t
Definition: TypeDefs.hpp:117
openfluid::ware::WareType
WareType
Definition: TypeDefs.hpp:60
openfluid::ware::SimulationContributorWare::~SimulationContributorWare
virtual ~SimulationContributorWare()
Definition: SimulationContributorWare.hpp:571
openfluid::ware::SimulationContributorWare::SimulationContributorWare
SimulationContributorWare(WareType WType)
Definition: SimulationContributorWare.hpp:565
openfluid::ware::SimulationInspectorWare
Definition: SimulationInspectorWare.hpp:55
openfluid::core::UnitID_t
unsigned int UnitID_t
Definition: TypeDefs.hpp:70
openfluid
Definition: ApplicationException.hpp:47
openfluid::core::VariableName_t
std::string VariableName_t
Definition: TypeDefs.hpp:131
openfluid::core::UnitsClass_t
std::string UnitsClass_t
Definition: TypeDefs.hpp:98
openfluid::core::PcsOrd_t
int PcsOrd_t
Definition: TypeDefs.hpp:84
openfluid::ware::SimulationContributorWare
Definition: SimulationContributorWare.hpp:51
dllexport.hpp