All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SimulationInspectorWare.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 SimulationInspectorWare.hpp
35  \brief Header of ...
36 
37  \author Jean-Christophe FABRE <fabrejc@supagro.inra.fr>
38  */
39 
40 
41 #ifndef __SIMULATIONINSPECTORWARE_HPP__
42 #define __SIMULATIONINSPECTORWARE_HPP__
43 
44 #include <openfluid/dllexport.hpp>
50 
51 
52 namespace openfluid { namespace ware {
53 
54 
56 {
57  private:
58 
59  static bool IsUnitIDInPtrList(const openfluid::core::UnitsPtrList_t* UnitsList,
60  const openfluid::core::UnitID_t& ID);
61 
62 
63  openfluid::core::Datastore* mp_Datastore;
64 
65 
66  protected:
67 
68  // TODO check if const
69  /**
70  Pointer to the core repository (const). It should be used with care. Prefer to use the OPENFLUID_Xxxx methods.
71  */
73 
74 
75  virtual bool isLinked() const { return (SimulationDrivenWare::isLinked() && mp_CoreData != NULL && mp_Datastore != NULL); };
76 
77 
78  /**
79  Returns true if a distributed attribute exists, false otherwise
80  @param[in] UnitPtr a Unit
81  @param[in] AttrName the name of the queried attribute
82  */
83  bool OPENFLUID_IsAttributeExist(const openfluid::core::Unit *UnitPtr,
84  const openfluid::core::AttributeName_t& AttrName) const;
85 
86  /**
87  Gets attribute for a unit, as a StringValue
88  @param[in] UnitPtr a Unit
89  @param[in] AttrName the name of the requested attribute
90  @param[out] Val the value of the requested attribute
91  */
92  void OPENFLUID_GetAttribute(const openfluid::core::Unit *UnitPtr,
93  const openfluid::core::AttributeName_t& AttrName,
94  openfluid::core::StringValue& Val) const;
95 
96  /**
97  Gets attribute for a unit, as a DoubleValue
98  @param[in] UnitPtr a Unit
99  @param[in] AttrName the name of the requested attribute
100  @param[out] Val the value of the requested attribute
101  */
102  void OPENFLUID_GetAttribute(const openfluid::core::Unit *UnitPtr,
103  const openfluid::core::AttributeName_t& AttrName,
104  openfluid::core::DoubleValue& Val) const;
105 
106  /**
107  Gets attribute for a unit, as a VectorValue
108  @param[in] UnitPtr a Unit
109  @param[in] AttrName the name of the requested attribute
110  @param[out] Val the value of the requested attribute
111  */
112  void OPENFLUID_GetAttribute(const openfluid::core::Unit *UnitPtr,
113  const openfluid::core::AttributeName_t& AttrName,
114  openfluid::core::VectorValue& Val) const;
115 
116  /**
117  Gets attribute for a unit, as a MatrixValue
118  @param[in] UnitPtr a Unit
119  @param[in] AttrName the name of the requested attribute
120  @param[out] Val the value of the requested attribute
121  */
122  void OPENFLUID_GetAttribute(const openfluid::core::Unit *UnitPtr,
123  const openfluid::core::AttributeName_t& AttrName,
124  openfluid::core::MatrixValue& Val) const;
125 
126  /**
127  Gets attribute for a unit, as a double
128  @param[in] UnitPtr a Unit
129  @param[in] AttrName the name of the requested attribute
130  @param[out] Val the value of the requested attribute
131  */
132  void OPENFLUID_GetAttribute(const openfluid::core::Unit *UnitPtr,
133  const openfluid::core::AttributeName_t& AttrName,
134  double& Val) const;
135 
136  /**
137  Gets attribute for a unit, as a long integer
138  @param[in] UnitPtr a Unit
139  @param[in] AttrName the name of the requested attribute
140  @param[out] Val the value of the requested attribute
141  */
142  void OPENFLUID_GetAttribute(const openfluid::core::Unit *UnitPtr,
143  const openfluid::core::AttributeName_t& AttrName,
144  long& Val) const;
145 
146  /**
147  Gets attribute for a unit, as a string
148  @param[in] UnitPtr a Unit
149  @param[in] AttrName the name of the requested attribute
150  @param[out] Val the value of the requested attribute
151  */
152  void OPENFLUID_GetAttribute(const openfluid::core::Unit *UnitPtr,
153  const openfluid::core::AttributeName_t& AttrName,
154  std::string& Val) const;
155 
156  /**
157  Returns true if a distributed variable exists, false otherwise
158  @param[in] UnitPtr a Unit
159  @param[in] VarName the name of the requested variable
160  */
161  bool OPENFLUID_IsVariableExist(const openfluid::core::Unit *UnitPtr,
162  const openfluid::core::VariableName_t& VarName) const;
163 
164  /**
165  Returns true if a distributed variable exists and if a value has been set for the given index, false otherwise
166  @param[in] UnitPtr a Unit
167  @param[in] VarName the name of the requested variable
168  @param[in] Index the time index for the value of the variable
169  */
170  bool OPENFLUID_IsVariableExist(const openfluid::core::Unit *UnitPtr,
171  const openfluid::core::VariableName_t& VarName,
172  const openfluid::core::TimeIndex_t Index) const;
173 
174  /**
175  Returns true if a distributed variable exists and if a value has been set for the given index
176  and if the value type is the given type, false otherwise
177  @param[in] UnitPtr a Unit
178  @param[in] VarName the name of the requested variable
179  @param[in] Index the time index for the value of the variable
180  @param[in] ValueType the type of the value
181  */
182  bool OPENFLUID_IsVariableExist(const openfluid::core::Unit *UnitPtr,
183  const openfluid::core::VariableName_t& VarName,
184  const openfluid::core::TimeIndex_t Index,
185  const openfluid::core::Value::Type ValueType) const;
186 
187  /**
188  Returns true if a distributed variable exists
189  and if the type set for this variable is the given type, false otherwise
190  @param[in] UnitPtr a Unit
191  @param[in] VarName the name of the requested variable
192  @param[in] VarType the type of the variable
193  */
194  bool OPENFLUID_IsTypedVariableExist(const openfluid::core::Unit *UnitPtr,
195  const openfluid::core::VariableName_t& VarName,
196  const openfluid::core::Value::Type VarType) const;
197 
198  /**
199  Returns true if a distributed variable exists and if a value has been set for the given index
200  and if the type set for this variable is the given type, false otherwise
201  @param[in] UnitPtr a Unit
202  @param[in] VarName the name of the requested variable
203  @param[in] Index the time index for the value of the variable
204  @param[in] VarType the type of the variable
205  */
206  bool OPENFLUID_IsTypedVariableExist(const openfluid::core::Unit *UnitPtr,
207  const openfluid::core::VariableName_t& VarName,
208  const openfluid::core::TimeIndex_t Index,
209  const openfluid::core::Value::Type VarType) const;
210 
211  /**
212  Gets the distributed variable value for a unit at a time index
213  @param[in] UnitPtr a Unit
214  @param[in] VarName the name of the requested variable
215  @param[in] Index the time index for the value of the requested variable
216  @param[out] Val the value of the requested variable
217  */
218  void OPENFLUID_GetVariable(const openfluid::core::Unit* UnitPtr,
219  const openfluid::core::VariableName_t& VarName,
220  const openfluid::core::TimeIndex_t Index,
221  openfluid::core::Value& Val) const;
222 
223  /**
224  Gets the distributed variable value for a unit at a time index
225  @param[in] UnitPtr a Unit
226  @param[in] VarName the name of the requested variable
227  @param[in] Index the time index for the value of the requested variable
228  @param[out] Val the value of the requested variable
229  */
230  void OPENFLUID_GetVariable(const openfluid::core::Unit* UnitPtr,
231  const openfluid::core::VariableName_t& VarName,
232  const openfluid::core::TimeIndex_t Index,
233  double& Val) const;
234 
235  /**
236  Gets the distributed variable value for a unit at a time index
237  @param[in] UnitPtr a Unit
238  @param[in] VarName the name of the requested variable
239  @param[in] Index the time index for the value of the requested variable
240  @param[out] Val the value of the requested variable
241  */
242  void OPENFLUID_GetVariable(const openfluid::core::Unit* UnitPtr,
243  const openfluid::core::VariableName_t& VarName,
244  const openfluid::core::TimeIndex_t Index,
245  long& Val) const;
246 
247  /**
248  Gets the distributed variable value for a unit at a time index
249  @param[in] UnitPtr a Unit
250  @param[in] VarName the name of the requested variable
251  @param[in] Index the time index for the value of the requested variable
252  @param[out] Val the value of the requested variable
253  */
254  void OPENFLUID_GetVariable(const openfluid::core::Unit* UnitPtr,
255  const openfluid::core::VariableName_t& VarName,
256  const openfluid::core::TimeIndex_t Index,
257  bool& Val) const;
258 
259  /**
260  Gets the distributed variable value for a unit at a time index
261  @param[in] UnitPtr a Unit
262  @param[in] VarName the name of the requested variable
263  @param[in] Index the time index for the value of the requested variable
264  @param[out] Val the value of the requested variable
265  */
266  void OPENFLUID_GetVariable(const openfluid::core::Unit* UnitPtr,
267  const openfluid::core::VariableName_t& VarName,
268  const openfluid::core::TimeIndex_t Index,
269  std::string& Val) const;
270 
271  /**
272  Gets the distributed variable value for a unit at the current time index
273  @param[in] UnitPtr a Unit
274  @param[in] VarName the name of the requested variable
275  @param[out] Val the value of the requested variable
276  */
277  void OPENFLUID_GetVariable(const openfluid::core::Unit* UnitPtr,
278  const openfluid::core::VariableName_t& VarName,
279  openfluid::core::Value& Val) const;
280 
281  /**
282  Gets the distributed variable value for a unit at the current time index
283  @param[in] UnitPtr a Unit
284  @param[in] VarName the name of the requested variable
285  @param[out] Val the value of the requested variable
286  */
287  void OPENFLUID_GetVariable(const openfluid::core::Unit* UnitPtr,
288  const openfluid::core::VariableName_t& VarName,
289  double& Val) const;
290 
291  /**
292  Gets the distributed variable value for a unit at the current time index
293  @param[in] UnitPtr a Unit
294  @param[in] VarName the name of the requested variable
295  @param[out] Val the value of the requested variable
296  */
297  void OPENFLUID_GetVariable(const openfluid::core::Unit* UnitPtr,
298  const openfluid::core::VariableName_t& VarName,
299  long& Val) const;
300 
301  /**
302  Gets the distributed variable value for a unit at the current time index
303  @param[in] UnitPtr a Unit
304  @param[in] VarName the name of the requested variable
305  @param[out] Val the value of the requested variable
306  */
307  void OPENFLUID_GetVariable(const openfluid::core::Unit* UnitPtr,
308  const openfluid::core::VariableName_t& VarName,
309  bool& Val) const;
310 
311  /**
312  Gets the distributed variable value for a unit at the current time index
313  @param[in] UnitPtr a Unit
314  @param[in] VarName the name of the requested variable
315  @param[out] Val the value of the requested variable
316  */
317  void OPENFLUID_GetVariable(const openfluid::core::Unit* UnitPtr,
318  const openfluid::core::VariableName_t& VarName,
319  std::string& Val) const;
320 
321 
322  /**
323  Gets the latest available variable for a unit
324  @param[in] UnitPtr a Unit
325  @param[in] VarName the name of the requested variable
326  @param[out] IndVal the value and timeindex of the requested variable
327  */
328  void OPENFLUID_GetLatestVariable(const openfluid::core::Unit* UnitPtr,
329  const openfluid::core::VariableName_t& VarName,
331 
332  /**
333  Gets the latest available variables for a unit since the given time index
334  @param[in] UnitPtr a Unit
335  @param[in] VarName the name of the requested variable
336  @param[in] BeginIndex The beginning time index of the search period
337  @param[out] IndValList the list of time-indexed values of the requested variable
338  */
339  void OPENFLUID_GetLatestVariables(const openfluid::core::Unit* UnitPtr,
340  const openfluid::core::VariableName_t& VarName,
341  const openfluid::core::TimeIndex_t BeginIndex,
343 
344 
345  /**
346  Gets the available variables for a unit during a given period (between two time indexes)
347  @param[in] UnitPtr a Unit
348  @param[in] VarName the name of the requested variable
349  @param[in] BeginIndex the time index for the beginning of the period
350  @param[in] EndIndex the time index for the end of the period
351  @param[out] IndValList the list of time-indexed values of the requested variable
352  */
353  void OPENFLUID_GetVariables(const openfluid::core::Unit* UnitPtr,
354  const openfluid::core::VariableName_t& VarName,
355  const openfluid::core::TimeIndex_t BeginIndex,
356  const openfluid::core::TimeIndex_t EndIndex,
358 
359  /**
360  Gets discrete events happening on a unit during a time period
361  @param[in] UnitPtr a Unit
362  @param[in] BeginDate the beginning of the time period
363  @param[in] EndDate the ending of the time period
364  @param[out] Events the collection of event corresponding to the request
365  */
366  void OPENFLUID_GetEvents(const openfluid::core::Unit *UnitPtr,
367  const openfluid::core::DateTime BeginDate,
368  const openfluid::core::DateTime EndDate,
369  openfluid::core::EventsCollection& Events) const;
370 
371  /**
372  Returns true if the queried unit class exists
373  @param[in] ClassName the queried class name
374  */
375  bool OPENFLUID_IsUnitClassExist(openfluid::core::UnitClass_t ClassName) const;
376 
377  /**
378  Returns true if the queried unit exists
379  @param[in] ClassName the class of the queried unit
380  @param[in] ID the ID of the queried unit
381  */
382  bool OPENFLUID_IsUnitExist(openfluid::core::UnitClass_t ClassName,
383  openfluid::core::UnitID_t ID) const;
384 
385  /**
386  Returns the total number of units
387  @param[out] UnitsCount the queried class name
388  */
389  void OPENFLUID_GetUnitsCount(unsigned int& UnitsCount) const;
390 
391  /**
392  Returns the number of units of the class if the queried unit class exists
393  @param[in] ClassName the queried class name
394  @param[out] UnitsCount the queried class name
395  @return false if the unit class does not exist
396  */
397  bool OPENFLUID_GetUnitsCount(const openfluid::core::UnitClass_t ClassName,
398  unsigned int& UnitsCount) const;
399 
400  /**
401  Returns a pointer to the queried unit if exists
402  @param[in] ClassName the queried class name
403  @param[in] ID the queried unit ID
404  @param[out] aUnit a pointer to the requested Unit, NULL if the unit does not exist
405  @return false if the unit does not exist
406  */
407  bool OPENFLUID_GetUnit(const openfluid::core::UnitClass_t& ClassName,
408  const openfluid::core::UnitID_t& ID,
409  openfluid::core::Unit* aUnit) const;
410 
411  openfluid::core::Unit* OPENFLUID_GetUnit(const openfluid::core::UnitClass_t& ClassName,
412  const openfluid::core::UnitID_t& ID) const;
413 
414  /**
415  Returns true if a given unit is connected "to" another unit
416  @param[in] aUnit the given unit
417  @param[in] ClassNameTo the class name of the other unit to test
418  @param[in] IDTo the ID of the other unit to test
419  @return true if the given unit is connected "to" the other unit
420  */
421  bool OPENFLUID_IsUnitConnectedTo(openfluid::core::Unit* aUnit,
422  const openfluid::core::UnitClass_t& ClassNameTo,
423  const openfluid::core::UnitID_t& IDTo) const;
424 
425 
426  /**
427  Returns true if a given unit is connected "from" another unit
428  @param[in] aUnit the given unit
429  @param[in] ClassNameFrom the class name of the other unit to test
430  @param[in] IDFrom the ID of the other unit to test
431  @return true if the given unit is connected "from" the other unit
432  */
433  bool OPENFLUID_IsUnitConnectedFrom(openfluid::core::Unit* aUnit,
434  const openfluid::core::UnitClass_t& ClassNameFrom,
435  const openfluid::core::UnitID_t& IDFrom) const;
436 
437 
438  /**
439  Returns true if a given unit is "a child of" another unit
440  @param[in] aUnit the given unit
441  @param[in] ClassNameParent the class name of the other unit to test
442  @param[in] IDParent the ID of the other unit to test
443  @return true if the given unit is "a child of" the other unit
444  */
445  bool OPENFLUID_IsUnitChildOf(openfluid::core::Unit* aUnit,
446  const openfluid::core::UnitClass_t& ClassNameParent,
447  const openfluid::core::UnitID_t& IDParent) const;
448 
449 
450  /**
451  Returns true if a given unit is "parent of" another unit
452  @param[in] aUnit the given unit
453  @param[in] ClassNameChild the class name of the other unit to test
454  @param[in] IDChild the ID of the other unit to test
455  @return true if the given unit is "parent of" the other unit
456  */
457  bool OPENFLUID_IsUnitParentOf(openfluid::core::Unit* aUnit,
458  const openfluid::core::UnitClass_t& ClassNameChild,
459  const openfluid::core::UnitID_t& IDChild) const;
460 
461 
462  SimulationInspectorWare(WareType WType) : SimulationDrivenWare(WType), mp_Datastore(NULL), mp_CoreData(NULL)
463  {};
464 
465 
466  public:
467 
469 
471  {
472  mp_CoreData = CoreRepos;
473  };
474 
476  {
477  mp_Datastore = DStore;
478  };
479 
480 };
481 
482 
483 
484 } } // openfluid::ware
485 
486 
487 #endif /* __SIMULATIONINSPECTORWARE_HPP__ */
std::list< Unit * > UnitsPtrList_t
Definition: Unit.hpp:72
unsigned long long TimeIndex_t
Definition: DateTime.hpp:62
std::string AttributeName_t
Definition: TypeDefs.hpp:74
Definition: StringValue.hpp:91
Header of ...
virtual ~SimulationInspectorWare()
Definition: SimulationInspectorWare.hpp:468
std::list< IndexedValue > IndexedValueList
Definition: ValuesBuffer.hpp:118
virtual bool isLinked() const
Definition: SimulationDrivenWare.hpp:88
Class for management of date and time information.
Definition: DateTime.hpp:131
Definition: DoubleValue.hpp:103
SimulationInspectorWare(WareType WType)
Definition: SimulationInspectorWare.hpp:462
Definition: SimulationDrivenWare.hpp:70
std::string UnitClass_t
Definition: TypeDefs.hpp:69
WareType
Definition: PluggableWare.hpp:93
Container class for holding information about additional resources relating to a project.
Definition: Datastore.hpp:54
Definition: SimulationInspectorWare.hpp:55
openfluid::core::CoreRepository * mp_CoreData
Definition: SimulationInspectorWare.hpp:72
Type
Definition: Value.hpp:68
unsigned int UnitID_t
Definition: TypeDefs.hpp:59
Definition: MatrixValue.hpp:115
Definition: Value.hpp:64
Definition: CoreRepository.hpp:48
Class defining a collection of discrete events.
Definition: EventsColl.hpp:59
std::string VariableName_t
Definition: TypeDefs.hpp:79
void linkToCoreRepository(openfluid::core::CoreRepository *CoreRepos)
Definition: SimulationInspectorWare.hpp:470
Definition: ValuesBuffer.hpp:57
Definition: Unit.hpp:107
Header of ...
Header of ...
Definition: VectorValue.hpp:119
virtual bool isLinked() const
Definition: SimulationInspectorWare.hpp:75
void linkToDatastore(openfluid::core::Datastore *DStore)
Definition: SimulationInspectorWare.hpp:475
#define DLLEXPORT
Definition: dllexport.hpp:51