ware/SimulationInspectorWare.hpp
Go to the documentation of this file.
00001 /*
00002 
00003   This file is part of OpenFLUID software
00004   Copyright(c) 2007, INRA - Montpellier SupAgro
00005 
00006 
00007  == GNU General Public License Usage ==
00008 
00009   OpenFLUID is free software: you can redistribute it and/or modify
00010   it under the terms of the GNU General Public License as published by
00011   the Free Software Foundation, either version 3 of the License, or
00012   (at your option) any later version.
00013 
00014   OpenFLUID is distributed in the hope that it will be useful,
00015   but WITHOUT ANY WARRANTY; without even the implied warranty of
00016   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017   GNU General Public License for more details.
00018 
00019   You should have received a copy of the GNU General Public License
00020   along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
00021 
00022 
00023  == Other Usage ==
00024 
00025   Other Usage means a use of OpenFLUID that is inconsistent with the GPL
00026   license, and requires a written agreement between You and INRA.
00027   Licensees for Other Usage of OpenFLUID may use this file in accordance
00028   with the terms contained in the written agreement between You and INRA.
00029   
00030 */
00031 
00032 
00033 /**
00034   \file SimulationInspectorWare.hpp
00035   \brief Header of ...
00036 
00037   \author Jean-Christophe FABRE <fabrejc@supagro.inra.fr>
00038  */
00039 
00040 
00041 #ifndef __SIMULATIONINSPECTORWARE_HPP__
00042 #define __SIMULATIONINSPECTORWARE_HPP__
00043 
00044 #include <openfluid/dllexport.hpp>
00045 #include <openfluid/ware/SimulationDrivenWare.hpp>
00046 #include <openfluid/core/CoreRepository.hpp>
00047 #include <openfluid/core/BooleanValue.hpp>
00048 #include <openfluid/core/MatrixValue.hpp>
00049 #include <openfluid/core/Datastore.hpp>
00050 
00051 
00052 namespace openfluid { namespace ware {
00053 
00054 
00055 class DLLEXPORT SimulationInspectorWare : public SimulationDrivenWare
00056 {
00057   private:
00058 
00059     static bool IsUnitIDInPtrList(const openfluid::core::UnitsPtrList_t* UnitsList,
00060                                   const openfluid::core::UnitID_t& ID);
00061 
00062 
00063     openfluid::core::Datastore* mp_Datastore;
00064 
00065 
00066   protected:
00067 
00068     // TODO check if const
00069     /**
00070          Pointer to the core repository (const). It should be used with care. Prefer to use the OPENFLUID_Xxxx methods.
00071      */
00072     openfluid::core::CoreRepository* mp_CoreData;
00073 
00074 
00075     virtual bool isLinked() const { return (SimulationDrivenWare::isLinked() && mp_CoreData != NULL && mp_Datastore != NULL); };
00076 
00077 
00078     /**
00079       Returns true if a distributed attribute exists, false otherwise
00080       @param[in] UnitPtr a Unit
00081       @param[in] AttrName the name of the queried attribute
00082     */
00083     bool OPENFLUID_IsAttributeExist(const openfluid::core::Unit *UnitPtr,
00084                                     const openfluid::core::AttributeName_t& AttrName) const;
00085 
00086     /**
00087       Gets attribute for a unit, as a StringValue
00088       @param[in] UnitPtr a Unit
00089       @param[in] AttrName the name of the requested attribute
00090       @param[out] Val the value of the requested attribute
00091     */
00092     void OPENFLUID_GetAttribute(const openfluid::core::Unit *UnitPtr,
00093                                 const openfluid::core::AttributeName_t& AttrName,
00094                                 openfluid::core::StringValue& Val) const;
00095 
00096     /**
00097       Gets attribute for a unit, as a DoubleValue
00098       @param[in] UnitPtr a Unit
00099       @param[in] AttrName the name of the requested attribute
00100       @param[out] Val the value of the requested attribute
00101     */
00102     void OPENFLUID_GetAttribute(const openfluid::core::Unit *UnitPtr,
00103                                 const openfluid::core::AttributeName_t& AttrName,
00104                                 openfluid::core::DoubleValue& Val) const;
00105 
00106     /**
00107       Gets attribute for a unit, as a VectorValue
00108       @param[in] UnitPtr a Unit
00109       @param[in] AttrName the name of the requested attribute
00110       @param[out] Val the value of the requested attribute
00111     */
00112     void OPENFLUID_GetAttribute(const openfluid::core::Unit *UnitPtr,
00113                                 const openfluid::core::AttributeName_t& AttrName,
00114                                 openfluid::core::VectorValue& Val) const;
00115 
00116     /**
00117       Gets attribute for a unit, as a MatrixValue
00118       @param[in] UnitPtr a Unit
00119       @param[in] AttrName the name of the requested attribute
00120       @param[out] Val the value of the requested attribute
00121     */
00122     void OPENFLUID_GetAttribute(const openfluid::core::Unit *UnitPtr,
00123                                 const openfluid::core::AttributeName_t& AttrName,
00124                                 openfluid::core::MatrixValue& Val) const;
00125 
00126     /**
00127       Gets attribute for a unit, as a double
00128       @param[in] UnitPtr a Unit
00129       @param[in] AttrName the name of the requested attribute
00130       @param[out] Val the value of the requested attribute
00131     */
00132     void OPENFLUID_GetAttribute(const openfluid::core::Unit *UnitPtr,
00133                                 const openfluid::core::AttributeName_t& AttrName,
00134                                 double& Val) const;
00135 
00136     /**
00137       Gets attribute for a unit, as a long integer
00138       @param[in] UnitPtr a Unit
00139       @param[in] AttrName the name of the requested attribute
00140       @param[out] Val the value of the requested attribute
00141     */
00142     void OPENFLUID_GetAttribute(const openfluid::core::Unit *UnitPtr,
00143                                 const openfluid::core::AttributeName_t& AttrName,
00144                                 long& Val) const;
00145 
00146     /**
00147       Gets attribute for a unit, as a string
00148       @param[in] UnitPtr a Unit
00149       @param[in] AttrName the name of the requested attribute
00150       @param[out] Val the value of the requested attribute
00151     */
00152     void OPENFLUID_GetAttribute(const openfluid::core::Unit *UnitPtr,
00153                                 const openfluid::core::AttributeName_t& AttrName,
00154                                 std::string& Val) const;
00155 
00156     /**
00157        Returns true if a distributed variable exists, false otherwise
00158        @param[in] UnitPtr a Unit
00159        @param[in] VarName the name of the requested variable
00160      */
00161      bool OPENFLUID_IsVariableExist(const openfluid::core::Unit *UnitPtr,
00162                                     const openfluid::core::VariableName_t& VarName) const;
00163 
00164     /**
00165        Returns true if a distributed variable exists and if a value has been set for the given index, false otherwise
00166        @param[in] UnitPtr a Unit
00167        @param[in] VarName the name of the requested variable
00168        @param[in] Index the time index for the value of the variable
00169      */
00170      bool OPENFLUID_IsVariableExist(const openfluid::core::Unit *UnitPtr,
00171                                     const openfluid::core::VariableName_t& VarName,
00172                                     const openfluid::core::TimeIndex_t Index) const;
00173 
00174      /**
00175         Returns true if a distributed variable exists and if a value has been set for the given index
00176         and if the value type is the given type, false otherwise
00177         @param[in] UnitPtr a Unit
00178         @param[in] VarName the name of the requested variable
00179         @param[in] Index the time index for the value of the variable
00180         @param[in] ValueType the type of the value
00181       */
00182       bool OPENFLUID_IsVariableExist(const openfluid::core::Unit *UnitPtr,
00183                                      const openfluid::core::VariableName_t& VarName,
00184                                      const openfluid::core::TimeIndex_t Index,
00185                                      const openfluid::core::Value::Type ValueType) const;
00186 
00187      /**
00188         Returns true if a distributed variable exists
00189         and if the type set for this variable is the given type, false otherwise
00190         @param[in] UnitPtr a Unit
00191         @param[in] VarName the name of the requested variable
00192         @param[in] VarType the type of the variable
00193       */
00194      bool OPENFLUID_IsTypedVariableExist(const openfluid::core::Unit *UnitPtr,
00195                                     const openfluid::core::VariableName_t& VarName,
00196                                     const openfluid::core::Value::Type VarType) const;
00197 
00198      /**
00199         Returns true if a distributed variable exists and if a value has been set for the given index
00200         and if the type set for this variable is the given type, false otherwise
00201         @param[in] UnitPtr a Unit
00202         @param[in] VarName the name of the requested variable
00203         @param[in] Index the time index for the value of the variable
00204         @param[in] VarType the type of the variable
00205       */
00206       bool OPENFLUID_IsTypedVariableExist(const openfluid::core::Unit *UnitPtr,
00207                                      const openfluid::core::VariableName_t& VarName,
00208                                      const openfluid::core::TimeIndex_t Index,
00209                                      const openfluid::core::Value::Type VarType) const;
00210 
00211       /**
00212         Gets the distributed variable value for a unit at a time index
00213         @param[in] UnitPtr a Unit
00214         @param[in] VarName the name of the requested variable
00215         @param[in] Index the time index for the value of the requested variable
00216         @param[out] Val the value of the requested variable
00217       */
00218       void OPENFLUID_GetVariable(const openfluid::core::Unit* UnitPtr,
00219                                  const openfluid::core::VariableName_t& VarName,
00220                                  const openfluid::core::TimeIndex_t Index,
00221                                  openfluid::core::Value& Val) const;
00222 
00223       /**
00224         Gets the distributed variable value for a unit at a time index
00225         @param[in] UnitPtr a Unit
00226         @param[in] VarName the name of the requested variable
00227         @param[in] Index the time index for the value of the requested variable
00228         @param[out] Val the value of the requested variable
00229       */
00230       void OPENFLUID_GetVariable(const openfluid::core::Unit* UnitPtr,
00231                                  const openfluid::core::VariableName_t& VarName,
00232                                  const openfluid::core::TimeIndex_t Index,
00233                                  double& Val) const;
00234 
00235       /**
00236         Gets the distributed variable value for a unit at a time index
00237         @param[in] UnitPtr a Unit
00238         @param[in] VarName the name of the requested variable
00239         @param[in] Index the time index for the value of the requested variable
00240         @param[out] Val the value of the requested variable
00241       */
00242       void OPENFLUID_GetVariable(const openfluid::core::Unit* UnitPtr,
00243                                  const openfluid::core::VariableName_t& VarName,
00244                                  const openfluid::core::TimeIndex_t Index,
00245                                  long& Val) const;
00246 
00247       /**
00248         Gets the distributed variable value for a unit at a time index
00249         @param[in] UnitPtr a Unit
00250         @param[in] VarName the name of the requested variable
00251         @param[in] Index the time index for the value of the requested variable
00252         @param[out] Val the value of the requested variable
00253       */
00254       void OPENFLUID_GetVariable(const openfluid::core::Unit* UnitPtr,
00255                                  const openfluid::core::VariableName_t& VarName,
00256                                  const openfluid::core::TimeIndex_t Index,
00257                                  bool& Val) const;
00258 
00259       /**
00260         Gets the distributed variable value for a unit at a time index
00261         @param[in] UnitPtr a Unit
00262         @param[in] VarName the name of the requested variable
00263         @param[in] Index the time index for the value of the requested variable
00264         @param[out] Val the value of the requested variable
00265       */
00266       void OPENFLUID_GetVariable(const openfluid::core::Unit* UnitPtr,
00267                                  const openfluid::core::VariableName_t& VarName,
00268                                  const openfluid::core::TimeIndex_t Index,
00269                                  std::string& Val) const;
00270 
00271     /**
00272       Gets the distributed variable value for a unit at the current time index
00273       @param[in] UnitPtr a Unit
00274       @param[in] VarName the name of the requested variable
00275       @param[out] Val the value of the requested variable
00276     */
00277     void OPENFLUID_GetVariable(const openfluid::core::Unit* UnitPtr,
00278                                const openfluid::core::VariableName_t& VarName,
00279                                openfluid::core::Value& Val) const;
00280 
00281     /**
00282       Gets the distributed variable value for a unit at the current time index
00283       @param[in] UnitPtr a Unit
00284       @param[in] VarName the name of the requested variable
00285       @param[out] Val the value of the requested variable
00286     */
00287     void OPENFLUID_GetVariable(const openfluid::core::Unit* UnitPtr,
00288                                const openfluid::core::VariableName_t& VarName,
00289                                double& Val) const;
00290 
00291     /**
00292       Gets the distributed variable value for a unit at the current time index
00293       @param[in] UnitPtr a Unit
00294       @param[in] VarName the name of the requested variable
00295       @param[out] Val the value of the requested variable
00296     */
00297     void OPENFLUID_GetVariable(const openfluid::core::Unit* UnitPtr,
00298                                const openfluid::core::VariableName_t& VarName,
00299                                long& Val) const;
00300 
00301     /**
00302       Gets the distributed variable value for a unit at the current time index
00303       @param[in] UnitPtr a Unit
00304       @param[in] VarName the name of the requested variable
00305       @param[out] Val the value of the requested variable
00306     */
00307     void OPENFLUID_GetVariable(const openfluid::core::Unit* UnitPtr,
00308                                const openfluid::core::VariableName_t& VarName,
00309                                bool& Val) const;
00310 
00311     /**
00312       Gets the distributed variable value for a unit at the current time index
00313       @param[in] UnitPtr a Unit
00314       @param[in] VarName the name of the requested variable
00315       @param[out] Val the value of the requested variable
00316     */
00317     void OPENFLUID_GetVariable(const openfluid::core::Unit* UnitPtr,
00318                                const openfluid::core::VariableName_t& VarName,
00319                                std::string& Val) const;
00320 
00321 
00322     /**
00323       Gets the latest available variable for a unit
00324       @param[in] UnitPtr a Unit
00325       @param[in] VarName the name of the requested variable
00326       @param[out] IndVal the value and timeindex of the requested variable
00327     */
00328     void OPENFLUID_GetLatestVariable(const openfluid::core::Unit* UnitPtr,
00329                                      const openfluid::core::VariableName_t& VarName,
00330                                      openfluid::core::IndexedValue& IndVal);
00331 
00332     /**
00333       Gets the latest available variables for a unit since the given time index
00334       @param[in] UnitPtr a Unit
00335       @param[in] VarName the name of the requested variable
00336       @param[in] BeginIndex The beginning time index of the search period
00337       @param[out] IndValList the list of time-indexed values of the requested variable
00338     */
00339     void OPENFLUID_GetLatestVariables(const openfluid::core::Unit* UnitPtr,
00340                                      const openfluid::core::VariableName_t& VarName,
00341                                      const openfluid::core::TimeIndex_t BeginIndex,
00342                                      openfluid::core::IndexedValueList& IndValList);
00343 
00344 
00345     /**
00346       Gets the available variables for a unit during a given period (between two time indexes)
00347       @param[in] UnitPtr a Unit
00348       @param[in] VarName the name of the requested variable
00349       @param[in] BeginIndex the time index for the beginning of the period
00350       @param[in] EndIndex the time index for the end of the period
00351       @param[out] IndValList the list of time-indexed values of the requested variable
00352     */
00353     void OPENFLUID_GetVariables(const openfluid::core::Unit* UnitPtr,
00354                                 const openfluid::core::VariableName_t& VarName,
00355                                 const openfluid::core::TimeIndex_t BeginIndex,
00356                                 const openfluid::core::TimeIndex_t EndIndex,
00357                                 openfluid::core::IndexedValueList& IndValList);
00358 
00359       /**
00360         Gets discrete events happening on a unit during a time period
00361         @param[in] UnitPtr a Unit
00362         @param[in] BeginDate the beginning of the time period
00363         @param[in] EndDate the ending of the time period
00364         @param[out] Events the collection of event corresponding to the request
00365       */
00366       void OPENFLUID_GetEvents(const openfluid::core::Unit *UnitPtr,
00367                                const openfluid::core::DateTime BeginDate,
00368                                const openfluid::core::DateTime EndDate,
00369                                openfluid::core::EventsCollection& Events) const;
00370 
00371       /**
00372         Returns true if the queried unit class exists
00373         @param[in] ClassName the queried class name
00374       */
00375       bool OPENFLUID_IsUnitClassExist(openfluid::core::UnitClass_t ClassName) const;
00376 
00377       /**
00378         Returns true if the queried unit exists
00379         @param[in] ClassName the class of the queried unit
00380         @param[in] ID the ID of the queried unit
00381       */
00382       bool OPENFLUID_IsUnitExist(openfluid::core::UnitClass_t ClassName,
00383                                  openfluid::core::UnitID_t ID) const;
00384 
00385       /**
00386         Returns the total number of units
00387         @param[out] UnitsCount the queried class name
00388       */
00389       void OPENFLUID_GetUnitsCount(unsigned int& UnitsCount) const;
00390 
00391       /**
00392         Returns the number of units of the class if the queried unit class exists
00393         @param[in] ClassName the queried class name
00394         @param[out] UnitsCount the queried class name
00395         @return false if the unit class does not exist
00396       */
00397       bool OPENFLUID_GetUnitsCount(const openfluid::core::UnitClass_t ClassName,
00398                                    unsigned int& UnitsCount) const;
00399 
00400       /**
00401         Returns a pointer to the queried unit if exists
00402         @param[in] ClassName the queried class name
00403         @param[in] ID the queried unit ID
00404         @param[out] aUnit a pointer to the requested Unit, NULL if the unit does not exist
00405         @return false if the unit does not exist
00406       */
00407       bool OPENFLUID_GetUnit(const openfluid::core::UnitClass_t& ClassName,
00408                              const openfluid::core::UnitID_t& ID,
00409                              openfluid::core::Unit* aUnit) const;
00410 
00411       openfluid::core::Unit* OPENFLUID_GetUnit(const openfluid::core::UnitClass_t& ClassName,
00412                                                const openfluid::core::UnitID_t& ID) const;
00413 
00414       /**
00415         Returns true if a given unit is connected "to" another unit
00416         @param[in] aUnit the given unit
00417         @param[in] ClassNameTo the class name of the other unit to test
00418         @param[in] IDTo the ID of the other unit to test
00419         @return true if the given unit is connected "to" the other unit
00420       */
00421       bool OPENFLUID_IsUnitConnectedTo(openfluid::core::Unit* aUnit,
00422                                        const openfluid::core::UnitClass_t& ClassNameTo,
00423                                        const openfluid::core::UnitID_t& IDTo) const;
00424 
00425 
00426       /**
00427         Returns true if a given unit is connected "from" another unit
00428         @param[in] aUnit the given unit
00429         @param[in] ClassNameFrom the class name of the other unit to test
00430         @param[in] IDFrom the ID of the other unit to test
00431         @return true if the given unit is connected "from" the other unit
00432       */
00433       bool OPENFLUID_IsUnitConnectedFrom(openfluid::core::Unit* aUnit,
00434                                          const openfluid::core::UnitClass_t& ClassNameFrom,
00435                                          const openfluid::core::UnitID_t& IDFrom) const;
00436 
00437 
00438       /**
00439         Returns true if a given unit is "a child of" another unit
00440         @param[in] aUnit the given unit
00441         @param[in] ClassNameParent the class name of the other unit to test
00442         @param[in] IDParent the ID of the other unit to test
00443         @return true if the given unit is "a child of" the other unit
00444       */
00445       bool OPENFLUID_IsUnitChildOf(openfluid::core::Unit* aUnit,
00446                                    const openfluid::core::UnitClass_t& ClassNameParent,
00447                                    const openfluid::core::UnitID_t& IDParent) const;
00448 
00449 
00450       /**
00451         Returns true if a given unit is "parent of" another unit
00452         @param[in] aUnit the given unit
00453         @param[in] ClassNameChild the class name of the other unit to test
00454         @param[in] IDChild the ID of the other unit to test
00455         @return true if the given unit is "parent of" the other unit
00456       */
00457       bool OPENFLUID_IsUnitParentOf(openfluid::core::Unit* aUnit,
00458                                     const openfluid::core::UnitClass_t& ClassNameChild,
00459                                     const openfluid::core::UnitID_t& IDChild) const;
00460 
00461 
00462       SimulationInspectorWare(WareType WType) : SimulationDrivenWare(WType), mp_Datastore(NULL), mp_CoreData(NULL)
00463       {};
00464 
00465 
00466   public:
00467 
00468     virtual ~SimulationInspectorWare() {};
00469 
00470     void linkToCoreRepository(openfluid::core::CoreRepository* CoreRepos)
00471     {
00472       mp_CoreData = CoreRepos;
00473     };
00474 
00475     void linkToDatastore(openfluid::core::Datastore* DStore)
00476     {
00477       mp_Datastore = DStore;
00478     };
00479 
00480 };
00481 
00482 
00483 
00484 } } // openfluid::ware
00485 
00486 
00487 #endif /* __SIMULATIONINSPECTORWARE_HPP__ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines