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@supagro.inra.fr>
37  */
38 
39 
40 #ifndef __OPENFLUID_WARE_SIMULATIONCONTRIBUTORWARE_HPP__
41 #define __OPENFLUID_WARE_SIMULATIONCONTRIBUTORWARE_HPP__
42 
43 #include <openfluid/dllexport.hpp>
45 
46 
47 namespace openfluid { namespace ware {
48 
49 
51 {
52  private:
53 
54  protected:
55 
56  /**
57  Sets attribute for a unit
58  @param[in] UnitPtr a Unit
59  @param[in] AttrName the name of the set attribute
60  @param[in] Val the value of the set attribute
61  */
62  void OPENFLUID_SetAttribute(openfluid::core::SpatialUnit *UnitPtr,
63  const openfluid::core::AttributeName_t& AttrName,
64  const openfluid::core::Value& Val);
65 
66  /**
67  Sets attribute for a unit, as a double
68  @param[in] UnitPtr a Unit
69  @param[in] AttrName the name of the set attribute
70  @param[in] Val the value of the set attribute
71  */
72  void OPENFLUID_SetAttribute(openfluid::core::SpatialUnit *UnitPtr,
73  const openfluid::core::AttributeName_t& AttrName,
74  const double& Val);
75 
76  /**
77  Sets attribute for a unit, as a boolean
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  bool Val);
85 
86  /**
87  Sets attribute for a unit, as a long integer
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  const long& Val);
95 
96  /**
97  Sets attribute for a unit, as a string
98  @param[in] UnitPtr a Unit
99  @param[in] AttrName the name of the set attribute
100  @param[out] 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 std::string& Val);
105 
106 
107  /**
108  Initializes a distributed variable value for a unit
109  @param[in] UnitPtr a Unit
110  @param[in] VarName the name of the variable
111  @param[in] Val the added value of the variable
112  */
113  void OPENFLUID_InitializeVariable(openfluid::core::SpatialUnit *UnitPtr,
114  const openfluid::core::VariableName_t& VarName,
115  const openfluid::core::Value& Val);
116 
117  /**
118  Initializes a distributed variable value for a unit
119  @param[in] aUnit 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& aUnit,
124  const openfluid::core::VariableName_t& VarName,
125  const openfluid::core::Value& Val);
126 
127  /**
128  Initializes a distributed double variable value for a unit
129  @param[in] UnitPtr a Unit
130  @param[in] VarName the name of the variable
131  @param[in] Val the added value of the variable (double)
132  */
133  void OPENFLUID_InitializeVariable(openfluid::core::SpatialUnit *UnitPtr,
134  const openfluid::core::VariableName_t& VarName,
135  const double& Val);
136 
137  /**
138  Initializes a distributed long variable value for a unit
139  @param[in] UnitPtr a Unit
140  @param[in] VarName the name of the variable
141  @param[in] Val the added value of the variable (long)
142  */
143  void OPENFLUID_InitializeVariable(openfluid::core::SpatialUnit *UnitPtr,
144  const openfluid::core::VariableName_t& VarName,
145  const long& Val);
146 
147  /**
148  Initializes a distributed boolean variable value for a unit
149  @param[in] UnitPtr a Unit
150  @param[in] VarName the name of the variable
151  @param[in] Val the added value of the variable (bool)
152  */
153  void OPENFLUID_InitializeVariable(openfluid::core::SpatialUnit *UnitPtr,
154  const openfluid::core::VariableName_t& VarName,
155  const bool& Val);
156 
157  /**
158  Initializes a distributed string variable value for a unit
159  @param[in] UnitPtr a Unit
160  @param[in] VarName the name of the variable
161  @param[in] Val the added value of the variable (string)
162  @warning Use std::string("text") instead of "text" as a value for the Val parameter
163  to avoid the automatic overloading between char* and bool types
164  */
165  void OPENFLUID_InitializeVariable(openfluid::core::SpatialUnit *UnitPtr,
166  const openfluid::core::VariableName_t& VarName,
167  const std::string& Val);
168 
169  /**
170  Appends a distributed variable value for a unit at the end
171  of the previously added values for this variable
172  @param[in] UnitPtr a Unit
173  @param[in] VarName the name of the variable
174  @param[in] Val the added value of the variable
175  */
176  void OPENFLUID_AppendVariable(openfluid::core::SpatialUnit *UnitPtr,
177  const openfluid::core::VariableName_t& VarName,
178  const openfluid::core::Value& Val);
179 
180  /**
181  Appends a distributed variable value for a unit at the end
182  of the previously added values for this variable
183  @param[in] aUnit a Unit
184  @param[in] VarName the name of the variable
185  @param[in] Val the added value of the variable
186  */
187  void OPENFLUID_AppendVariable(openfluid::core::SpatialUnit& aUnit,
188  const openfluid::core::VariableName_t& VarName,
189  const openfluid::core::Value& Val);
190 
191  /**
192  Appends a distributed double variable value for a unit at the end
193  of the previously added values for this variable
194  @param[in] UnitPtr a Unit
195  @param[in] VarName the name of the variable
196  @param[in] Val the added value of the variable (double)
197  */
198  void OPENFLUID_AppendVariable(openfluid::core::SpatialUnit *UnitPtr,
199  const openfluid::core::VariableName_t& VarName,
200  const double& Val);
201 
202  /**
203  Appends a distributed long variable value for a unit at the end
204  of the previously added values for this variable
205  @param[in] UnitPtr a Unit
206  @param[in] VarName the name of the variable
207  @param[in] Val the added value of the variable (long)
208  */
209  void OPENFLUID_AppendVariable(openfluid::core::SpatialUnit *UnitPtr,
210  const openfluid::core::VariableName_t& VarName,
211  const long& Val);
212 
213  /**
214  Appends a distributed boolean variable value for a unit at the end
215  of the previously added values for this variable
216  @param[in] UnitPtr a Unit
217  @param[in] VarName the name of the variable
218  @param[in] Val the added value of the variable (bool)
219  */
220  void OPENFLUID_AppendVariable(openfluid::core::SpatialUnit *UnitPtr,
221  const openfluid::core::VariableName_t& VarName,
222  const bool& Val);
223 
224  /**
225  Appends a distributed string variable value for a unit at the end
226  of the previously added values for this variable
227  @param[in] UnitPtr a Unit
228  @param[in] VarName the name of the variable
229  @param[in] Val the added value of the variable (string)
230  @warning Use std::string("text") instead of "text" as a value for the Val parameter
231  to avoid the automatic overloading between char* and bool types
232  */
233  void OPENFLUID_AppendVariable(openfluid::core::SpatialUnit *UnitPtr,
234  const openfluid::core::VariableName_t& VarName,
235  const std::string& Val);
236 
237 
238  /**
239  Sets a distributed variable value for a unit at the current time index
240  @param[in] UnitPtr a Unit
241  @param[in] VarName the name of the variable
242  @param[in] Val the added value of the variable
243  */
244  void OPENFLUID_SetVariable(openfluid::core::SpatialUnit *UnitPtr,
245  const openfluid::core::VariableName_t& VarName,
246  const openfluid::core::Value& Val);
247 
248  /**
249  Sets a distributed double variable value for a unit at the current time index
250  @param[in] UnitPtr a Unit
251  @param[in] VarName the name of the variable
252  @param[in] Val the added value of the variable (double)
253  */
254  void OPENFLUID_SetVariable(openfluid::core::SpatialUnit *UnitPtr,
255  const openfluid::core::VariableName_t& VarName,
256  const double& Val);
257 
258  /**
259  Sets a distributed double variable value for a unit at the current time index
260  @param[in] UnitPtr a Unit
261  @param[in] VarName the name of the variable
262  @param[in] Val the added value of the variable (long)
263  */
264  void OPENFLUID_SetVariable(openfluid::core::SpatialUnit *UnitPtr,
265  const openfluid::core::VariableName_t& VarName,
266  const long& Val);
267 
268  /**
269  Sets a distributed double variable value for a unit at the current time index
270  @param[in] UnitPtr a Unit
271  @param[in] VarName the name of the variable
272  @param[in] Val the added value of the variable (bool)
273  */
274  void OPENFLUID_SetVariable(openfluid::core::SpatialUnit *UnitPtr,
275  const openfluid::core::VariableName_t& VarName,
276  const bool& Val);
277 
278  /**
279  Sets a distributed double variable value for a unit at the current time index
280  @param[in] UnitPtr a Unit
281  @param[in] VarName the name of the variable
282  @param[in] Val the added value of the variable (string)
283  */
284  void OPENFLUID_SetVariable(openfluid::core::SpatialUnit *UnitPtr,
285  const openfluid::core::VariableName_t& VarName,
286  const std::string& Val);
287 
288  /**
289  Appends an event on a unit
290  @param[in] UnitPtr a Unit
291  @param[in] Ev the event to append
292  */
293  void OPENFLUID_AppendEvent(openfluid::core::SpatialUnit *UnitPtr,
295 
296 
297  /**
298  Adds a unit to the set of units if not already exists
299  @param[in] ClassName class name of the added unit
300  @param[in] ID ID of the added unit
301  @param[in] PcsOrder Process order of the added unit
302  */
303  void OPENFLUID_AddUnit(const openfluid::core::UnitsClass_t& ClassName,
305  openfluid::core::PcsOrd_t PcsOrder);
306 
307  /**
308  Deletes a unit from the set of units if exists
309  @param[in] ClassName class name of the removed unit
310  @param[in] ID ID of the added unit
311  @return true if the unit has been correctly deleted
312  */
313  void OPENFLUID_DeleteUnit(const openfluid::core::UnitsClass_t& ClassName,
315 
316 
317  /**
318  Adds a from-to connection between two units
319  @param[in] ClassNameFrom class name of the "from" unit
320  @param[in] IDFrom ID of the "from" unit
321  @param[in] ClassNameTo class name of the "to" unit
322  @param[in] IDTo ID of the "to" unit
323  @return false if the unit connection already exists
324  */
325  bool OPENFLUID_AddFromToConnection(const openfluid::core::UnitsClass_t& ClassNameFrom,
327  const openfluid::core::UnitsClass_t& ClassNameTo,
329 
330  /**
331  Adds a from-to connection between two units
332  @param[in] FromUnit pointer to the "from" unit
333  @param[in] ToUnit pointer to the "to" unit
334  @return false if the connection already exists
335  */
336  bool OPENFLUID_AddFromToConnection(openfluid::core::SpatialUnit* FromUnit,
338 
339  /**
340  Removes a from-to connection between two units
341  @param[in] ClassNameFrom class name of the "from" unit
342  @param[in] IDFrom ID of the "from" unit
343  @param[in] ClassNameTo class name of the "to" unit
344  @param[in] IDTo ID of the "to" unit
345  @return false if the unit connection does not exist
346  */
347  bool OPENFLUID_RemoveFromToConnection(const openfluid::core::UnitsClass_t& ClassNameFrom,
349  const openfluid::core::UnitsClass_t& ClassNameTo,
351 
352  /**
353  Removes a from-to connection between two units
354  @param[in] FromUnit pointer to the "from" unit
355  @param[in] ToUnit pointer to the "to" unit
356  @return false if the connection does not exist
357  */
358  bool OPENFLUID_RemoveFromToConnection(openfluid::core::SpatialUnit* FromUnit,
360 
361 
362  /**
363  Adds a child-parent connection between two units
364  @param[in] ClassNameChild class name of the "child" unit
365  @param[in] IDChild ID of the "child" unit
366  @param[in] ClassNameParent class name of the "parent" unit
367  @param[in] IDParent ID of the "parent" unit
368  @return false if the connection already exists
369  */
370  bool OPENFLUID_AddChildParentConnection(const openfluid::core::UnitsClass_t& ClassNameChild,
372  const openfluid::core::UnitsClass_t& ClassNameParent,
373  openfluid::core::UnitID_t IDParent);
374 
375  /**
376  Adds a child-parent connection between two units
377  @param[in] ChildUnit pointer to the "child" unit
378  @param[in] ParentUnit pointer to the "parent" unit
379  @return false if the connection already exists
380  */
381  bool OPENFLUID_AddChildParentConnection(openfluid::core::SpatialUnit* ChildUnit,
382  openfluid::core::SpatialUnit* ParentUnit);
383 
384 
385  /**
386  Removes a child-parent connection between two units
387  @param[in] ClassNameChild class name of the "child" unit
388  @param[in] IDChild ID of the "child" unit
389  @param[in] ClassNameParent class name of the "parent" unit
390  @param[in] IDParent ID of the "parent" unit
391  @return false if the connection does not exist
392  */
393  bool OPENFLUID_RemoveChildParentConnection(const openfluid::core::UnitsClass_t& ClassNameChild,
395  const openfluid::core::UnitsClass_t& ClassNameParent,
396  openfluid::core::UnitID_t IDParent);
397 
398  /**
399  Removes a child-parent connection between two units
400  @param[in] ChildUnit pointer to the "child" unit
401  @param[in] ParentUnit pointer to the "parent" unit
402  @return false if the connection does not exist
403  */
404  bool OPENFLUID_RemoveChildParentConnection(openfluid::core::SpatialUnit* ChildUnit,
405  openfluid::core::SpatialUnit* ParentUnit);
406 
407  /**
408  Builds a ColsNbr x RowsNbr unix matrix with bi-directionnal connections
409  @param[in] UnitsClass the name of units class
410  @param[in] ColsNbr the number of units on the X axis
411  @param[in] RowsNbr the number of units on the Y axis
412  */
413  void OPENFLUID_BuildUnitsMatrix(const openfluid::core::UnitsClass_t& UnitsClass,
414  const unsigned int& ColsNbr,
415  const unsigned int& RowsNbr);
416 
418  {};
419 
420 
421  public:
422 
423 
425 
426 
427 };
428 
429 
430 
431 } } // openfluid::ware
432 
433 
434 
435 #endif /* __OPENFLUID_WARE_SIMULATIONCONTRIBUTORWARE_HPP__ */
SimulationContributorWare(WareType WType)
Definition: SimulationContributorWare.hpp:417
Definition: Value.hpp:64
std::string UnitsClass_t
Definition: TypeDefs.hpp:71
std::string VariableName_t
Definition: TypeDefs.hpp:86
virtual ~SimulationContributorWare()
Definition: SimulationContributorWare.hpp:424
Definition: SimulationContributorWare.hpp:50
Definition: SpatialUnit.hpp:107
Definition: ApplicationException.hpp:47
std::string AttributeName_t
Definition: TypeDefs.hpp:81
WareType
Definition: TypeDefs.hpp:62
#define OPENFLUID_API
Definition: dllexport.hpp:87
Definition: Event.hpp:59
int PcsOrd_t
Definition: TypeDefs.hpp:66
unsigned int UnitID_t
Definition: TypeDefs.hpp:61
Definition: SimulationInspectorWare.hpp:54