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