ware/SimulatorSignature.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 /**
00035   @file
00036 
00037   @author Jean-Christophe FABRE <fabrejc@supagro.inra.fr>
00038 */
00039 
00040 #ifndef __SIMULATORSIGNATURE_HPP__
00041 #define __SIMULATORSIGNATURE_HPP__
00042 
00043 
00044 #include <openfluid/config.hpp>
00045 #include <openfluid/dllexport.hpp>
00046 #include <openfluid/core/TypeDefs.hpp>
00047 #include <openfluid/core/DateTime.hpp>
00048 #include <openfluid/ware/WareSignature.hpp>
00049 
00050 
00051 
00052 // =====================================================================
00053 // =====================================================================
00054 
00055 /**
00056   Macro for the beginning of definition of signature hook
00057 */
00058 #define BEGIN_SIMULATOR_SIGNATURE(id) \
00059   openfluid::ware::SimulatorSignature* WARESIGNATURE_PROC_DECL() \
00060   { \
00061     openfluid::ware::SimulatorSignature* Signature = new openfluid::ware::SimulatorSignature(); \
00062     Signature->setABIVersion(openfluid::config::FULL_VERSION); \
00063     Signature->ID = (id);
00064 
00065 
00066 /**
00067   Macro for the end of definition of signature hook
00068 */
00069 #define END_SIMULATOR_SIGNATURE \
00070     return Signature; \
00071   }
00072 
00073 
00074 // =====================================================================
00075 // =====================================================================
00076 
00077 
00078 /**
00079   Macro for declaration of the simulator application domain
00080 */
00081 #define DECLARE_DOMAIN(domain) Signature->Domain = domain;
00082 
00083 /**
00084   Macro for declaration of the simulator application processes
00085 */
00086 #define DECLARE_PROCESS(process) Signature->Process = process;
00087 
00088 /**
00089   Macro for declaration of the simulator application numerical method
00090 */
00091 #define DECLARE_METHOD(method) Signature->Method = method;
00092 
00093 
00094 // =====================================================================
00095 // =====================================================================
00096 
00097 
00098 /**
00099   Macro for declaration of a simulator parameter
00100   @param[in] name name of the parameter
00101   @param[in] description description of the parameter
00102   @param[in] unit unit of the parameter. Could be an empty string if there is no unit
00103 */
00104 #define DECLARE_SIMULATOR_PARAM(name,description,unit) \
00105   Signature->HandledData.SimulatorParams.push_back(openfluid::ware::SignatureHandledDataItem((name),(""),description,unit));
00106 
00107 
00108 
00109 // =====================================================================
00110 // =====================================================================
00111 
00112 
00113 /**
00114   Macro for declaration of a produced variable
00115   @param[in] name name of the variable
00116   @param[in] uclass class of the concerned units
00117   @param[in] description description of the variable
00118   @param[in] unit unit of the variable. Could be an empty string if there is no unit
00119 */
00120 #define DECLARE_PRODUCED_VAR(name,uclass,description,unit) \
00121   Signature->HandledData.ProducedVars.push_back(openfluid::ware::SignatureHandledTypedDataItem((name),uclass,description,unit));
00122 
00123 /**
00124   Macro for declaration of an updated variable
00125   @param[in] name name of the variable
00126   @param[in] uclass class of the concerned units
00127   @param[in] description description of the variable
00128   @param[in] unit unit of the variable. Could be an empty string if there is no unit
00129 */
00130 #define DECLARE_UPDATED_VAR(name,uclass,description,unit) \
00131   Signature->HandledData.UpdatedVars.push_back(openfluid::ware::SignatureHandledTypedDataItem((name),uclass,description,unit));
00132 
00133 /**
00134   Macro for declaration of a required variable
00135   @param[in] name name of the variable
00136   @param[in] uclass class of the concerned units
00137   @param[in] description description of the variable
00138   @param[in] unit unit of the variable. Could be an empty string if there is no unit
00139 */
00140 #define DECLARE_REQUIRED_VAR(name,uclass,description,unit) \
00141   Signature->HandledData.RequiredVars.push_back(openfluid::ware::SignatureHandledTypedDataItem((name),uclass,description,unit));
00142 
00143 
00144 /**
00145   Macro for declaration of an used variable
00146   @param[in] name name of the variable
00147   @param[in] uclass class of the concerned units
00148   @param[in] description description of the variable
00149   @param[in] unit unit of the variable. Could be an empty string if there is no unit
00150 */
00151 #define DECLARE_USED_VAR(name,uclass,description,unit) \
00152   Signature->HandledData.UsedVars.push_back(openfluid::ware::SignatureHandledTypedDataItem((name),uclass,description,unit));
00153 
00154 
00155 /**
00156   Macro for declaration of a produced attribute
00157   @param[in] name name of the attribute
00158   @param[in] uclass class of the concerned units
00159   @param[in] description description of the attribute
00160   @param[in] unit unit of the attribute. Could be an empty string if there is no unit
00161 */
00162 #define DECLARE_PRODUCED_ATTRIBUTE(name,uclass,description,unit) \
00163   Signature->HandledData.ProducedAttribute.push_back(openfluid::ware::SignatureHandledDataItem((name),uclass,description,unit));
00164 
00165 /**
00166   Macro for declaration of a required attribute
00167   @param[in] name name of the attribute
00168   @param[in] uclass class of the concerned units
00169   @param[in] description description of the attribute
00170   @param[in] unit unit of the attribute. Could be an empty string if there is no unit
00171 */
00172 #define DECLARE_REQUIRED_ATTRIBUTE(name,uclass,description,unit) \
00173   Signature->HandledData.RequiredAttribute.push_back(openfluid::ware::SignatureHandledDataItem((name),uclass,description,unit));
00174 
00175 /**
00176   Macro for declaration of a used attribute
00177   @param[in] name name of the attribute
00178   @param[in] uclass class of the concerned units
00179   @param[in] description description of the attribute
00180   @param[in] unit unit of the attribute. Could be an empty string if there is no unit
00181 */
00182 #define DECLARE_USED_ATTRIBUTE(name,uclass,description,unit) \
00183   Signature->HandledData.UsedAttribute.push_back(openfluid::ware::SignatureHandledDataItem((name),uclass,description,unit));
00184 
00185 /**
00186   Macro for declaration of used events
00187   @param[in] uclass class of the concerned units
00188 */
00189 #define DECLARE_USED_EVENTS(uclass) Signature->HandledData.UsedEventsOnUnits.push_back(uclass);
00190 
00191 
00192 
00193 /**
00194   Macro for declaration of units graph modification
00195   @param[in] description description of modification
00196 
00197 */
00198 #define DECLARE_UPDATED_UNITSGRAPH(description) Signature->HandledUnitsGraph.UpdatedUnitsGraph = (description);
00199 
00200 
00201 /**
00202   Macro for declaration of units class creation or update
00203   @param[in] uclass name of the created or updated class
00204   @param[in] description description of the updated class
00205 
00206 */
00207 #define DECLARE_UPDATED_UNITSCLASS(uclass,description) Signature->HandledUnitsGraph.UpdatedUnitsClass.push_back(openfluid::ware::SignatureHandledUnitsClassItem(uclass,description));
00208 
00209 
00210 /**
00211   Macro for declaration of required file
00212   @param[in] name name of the file
00213 */
00214 #define DECLARE_REQUIRED_EXTRAFILE(name) \
00215   Signature->HandledData.RequiredExtraFiles.push_back(name);
00216 
00217 /**
00218   Macro for declaration of used file
00219   @param[in] name name of the file
00220 */
00221 #define DECLARE_USED_EXTRAFILE(name) \
00222   Signature->HandledData.UsedExtraFiles.push_back(name);
00223 
00224 /**
00225   Macro for declaration of time scheduling as undefined
00226 */
00227 #define DECLARE_SCHEDULING_UNDEFINED \
00228   Signature->TimeScheduling.setAsUndefined();
00229 
00230 /**
00231   Macro for declaration of time scheduling as default delta T
00232 */
00233 #define DECLARE_SCHEDULING_DEFAULT \
00234   Signature->TimeScheduling.setAsDefaultDeltaT();
00235 
00236 /**
00237   Macro for declaration of fixed time scheduling
00238   @param[in] deltat fixed time scheduling value
00239 */
00240 #define DECLARE_SCHEDULING_FIXED(deltat) \
00241   Signature->TimeScheduling.setAsFixed(deltat);
00242 
00243 /**
00244   Macro for declaration of range of time scheduling
00245   @param[in] min minimal time scheduling value
00246   @param[in] max maximal time scheduling value
00247 */
00248 #define DECLARE_SCHEDULING_RANGE(min,max) \
00249   Signature->TimeScheduling.setAsRange(min,max);
00250 
00251 
00252 // =====================================================================
00253 // =====================================================================
00254 
00255 
00256 
00257 namespace openfluid { namespace ware {
00258 
00259 
00260 typedef std::string SimMethod_t;
00261 
00262 typedef std::string SimProcess_t;
00263 
00264 typedef std::string SimDomain_t;
00265 
00266 
00267 // =====================================================================
00268 // =====================================================================
00269 
00270 
00271 /**
00272 Class for storage of the definition of data handled by the simulator.
00273 */
00274 class DLLEXPORT SignatureHandledDataItem
00275 {
00276   public:
00277 
00278     std::string DataName;
00279     openfluid::core::UnitClass_t UnitClass;
00280     std::string Description;
00281     std::string DataUnit;
00282 
00283     SignatureHandledDataItem() :
00284       DataName(""),UnitClass(""),Description(""),DataUnit("") {}
00285 
00286     SignatureHandledDataItem(std::string DName, openfluid::core::UnitClass_t UClass,
00287         std::string DDescription, std::string DUnit) :
00288           DataName(DName),UnitClass(UClass),Description(DDescription),DataUnit(DUnit) {}
00289 
00290 };
00291 
00292 /**
00293 Class for storage of the definition of typed data handled by the simulator.
00294 */
00295 class DLLEXPORT SignatureHandledTypedDataItem : public SignatureHandledDataItem
00296 {
00297 
00298   public:
00299 
00300     static bool getVariableNameAndType(const std::string SourceStr, std::string& VarName, openfluid::core::Value::Type& VarType);
00301 
00302     openfluid::core::Value::Type DataType;
00303 
00304     SignatureHandledTypedDataItem() :
00305       SignatureHandledDataItem(), DataType(openfluid::core::Value::NONE) {}
00306 
00307     SignatureHandledTypedDataItem(std::string DName, openfluid::core::UnitClass_t UClass,
00308         std::string DDescription, std::string DUnit);
00309 };
00310 
00311 
00312 /**
00313   Class for storage of the definition of spatial units handled by the simulator.
00314 */
00315 class DLLEXPORT SignatureHandledUnitsClassItem
00316 {
00317   public:
00318 
00319     openfluid::core::UnitClass_t UnitsClass;
00320     std::string Description;
00321 
00322     SignatureHandledUnitsClassItem() :
00323       UnitsClass(""),Description("") {}
00324 
00325     SignatureHandledUnitsClassItem(openfluid::core::UnitClass_t UClass,
00326         std::string DDescription) :
00327           UnitsClass(UClass),Description(DDescription) {}
00328 };
00329 
00330 
00331 /**
00332   Class for storage of the definition of the data handled by the simulator. This is part of the signature.
00333 */
00334 class DLLEXPORT SignatureHandledData
00335 {
00336   public:
00337 
00338     std::vector<SignatureHandledTypedDataItem> ProducedVars;
00339 
00340     std::vector<SignatureHandledTypedDataItem> UpdatedVars;
00341 
00342     std::vector<SignatureHandledTypedDataItem> RequiredVars;
00343 
00344     std::vector<SignatureHandledTypedDataItem> UsedVars;
00345 
00346     std::vector<SignatureHandledDataItem> SimulatorParams;
00347 
00348     std::vector<SignatureHandledDataItem> ProducedAttribute;
00349 
00350     std::vector<SignatureHandledDataItem> RequiredAttribute;
00351 
00352     std::vector<SignatureHandledDataItem> UsedAttribute;
00353 
00354     std::vector<std::string> RequiredExtraFiles;
00355 
00356     std::vector<std::string> UsedExtraFiles;
00357 
00358     std::vector<openfluid::core::UnitClass_t> UsedEventsOnUnits;
00359 
00360 
00361     SignatureHandledData()
00362     {
00363 
00364     }
00365 
00366 };
00367 
00368 
00369 class DLLEXPORT SignatureHandledUnitsGraph
00370 {
00371   public:
00372 
00373     std::string UpdatedUnitsGraph;
00374 
00375     std::vector<SignatureHandledUnitsClassItem> UpdatedUnitsClass;
00376 
00377     SignatureHandledUnitsGraph()
00378     {
00379       UpdatedUnitsGraph.clear();
00380     }
00381 };
00382 
00383 
00384 class DLLEXPORT SignatureTimeScheduling
00385 {
00386   public:
00387 
00388     enum SchedulingType { UNDEFINED, DEFAULT, FIXED, RANGE };
00389 
00390     SchedulingType Type;
00391 
00392     openfluid::core::Duration_t Min;
00393 
00394     openfluid::core::Duration_t Max;
00395 
00396     SignatureTimeScheduling():
00397       Type(UNDEFINED), Min(0), Max(0)
00398     { }
00399 
00400     void setAsUndefined()
00401     {
00402       Type = UNDEFINED;
00403       Min = 0;
00404       Max = 0;
00405     }
00406 
00407     void setAsDefaultDeltaT()
00408     {
00409       Type = DEFAULT;
00410       Min = 0;
00411       Max = 0;
00412     }
00413 
00414     void setAsFixed(openfluid::core::Duration_t Val)
00415     {
00416       Type = FIXED;
00417       Min = Val;
00418       Max = Val;
00419     }
00420 
00421     void setAsRange(openfluid::core::Duration_t MinVal, openfluid::core::Duration_t MaxVal)
00422     {
00423       Type = RANGE;
00424       Min = MinVal;
00425       Max = MaxVal;
00426     }
00427 
00428 };
00429 
00430 
00431 /**
00432   Class encapsulating the plugin signature,
00433   returned from the plugin to the host app for registering
00434 */
00435 class DLLEXPORT SimulatorSignature : public WareSignature
00436 {
00437 
00438   public:
00439 
00440 
00441     /**
00442     Plugin domain (i.e. hydrology, pop, erosion, ...)
00443     */
00444     SimDomain_t Domain;
00445 
00446     /**
00447     Plugin simulated process (i.e. surface rainfall-runoff production, ditch infiltration, ...)
00448     */
00449     SimProcess_t Process;
00450 
00451     /**
00452     Plugin involved method (i.e. morel-seytoux, hayami, ...)
00453     */
00454     SimMethod_t Method;
00455 
00456     /**
00457     Handled data
00458     */
00459     SignatureHandledData HandledData;
00460 
00461     /**
00462     Handled units graph
00463     */
00464     SignatureHandledUnitsGraph HandledUnitsGraph;
00465 
00466     /**
00467       Time scheduling
00468     */
00469     SignatureTimeScheduling TimeScheduling;
00470 
00471     SimulatorSignature() : WareSignature(),
00472       Domain(""),Process(""),Method("")
00473       {}
00474 
00475 };
00476 
00477 
00478 
00479 } } // namespaces
00480 
00481 
00482 
00483 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines