base/PlugFunction.hpp
Go to the documentation of this file.
00001 /*
00002   This file is part of OpenFLUID software
00003   Copyright (c) 2007-2010 INRA-Montpellier SupAgro
00004 
00005 
00006  == GNU General Public License Usage ==
00007 
00008   OpenFLUID is free software: you can redistribute it and/or modify
00009   it under the terms of the GNU General Public License as published by
00010   the Free Software Foundation, either version 3 of the License, or
00011   (at your option) any later version.
00012 
00013   OpenFLUID is distributed in the hope that it will be useful,
00014   but WITHOUT ANY WARRANTY; without even the implied warranty of
00015   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016   GNU General Public License for more details.
00017 
00018   You should have received a copy of the GNU General Public License
00019   along with OpenFLUID.  If not, see <http://www.gnu.org/licenses/>.
00020 
00021   In addition, as a special exception, INRA gives You the additional right
00022   to dynamically link the code of OpenFLUID with code not covered
00023   under the GNU General Public License ("Non-GPL Code") and to distribute
00024   linked combinations including the two, subject to the limitations in this
00025   paragraph. Non-GPL Code permitted under this exception must only link to
00026   the code of OpenFLUID dynamically through the OpenFLUID libraries
00027   interfaces, and only for building OpenFLUID plugins. The files of
00028   Non-GPL Code may be link to the OpenFLUID libraries without causing the
00029   resulting work to be covered by the GNU General Public License. You must
00030   obey the GNU General Public License in all respects for all of the
00031   OpenFLUID code and other code used in conjunction with OpenFLUID
00032   except the Non-GPL Code covered by this exception. If you modify
00033   this OpenFLUID, you may extend this exception to your version of the file,
00034   but you are not obligated to do so. If you do not wish to provide this
00035   exception without modification, you must delete this exception statement
00036   from your version and license this OpenFLUID solely under the GPL without
00037   exception.
00038 
00039 
00040  == Other Usage ==
00041 
00042   Other Usage means a use of OpenFLUID that is inconsistent with the GPL
00043   license, and requires a written agreement between You and INRA.
00044   Licensees for Other Usage of OpenFLUID may use this file in accordance
00045   with the terms contained in the written agreement between You and INRA.
00046 */
00047 
00048 
00071 #ifndef __PLUGFUNCTION_HPP__
00072 #define __PLUGFUNCTION_HPP__
00073 
00074 #include <string>
00075 #include <boost/filesystem/path.hpp>
00076 #include <glibmm/threadpool.h>
00077 
00078 #include <openfluid/dllexport.hpp>
00079 #include <openfluid/base/FuncSignature.hpp>
00080 #include <openfluid/base/StdoutFileOStream.hpp>
00081 #include <openfluid/base/ExecMsgs.hpp>
00082 #include <openfluid/base/EnvProperties.hpp>
00083 #include <openfluid/base/SimStatus.hpp>
00084 #include <openfluid/core/TypeDefs.hpp>
00085 #include <openfluid/core/DateTime.hpp>
00086 #include <openfluid/core/Unit.hpp>
00087 #include <openfluid/core/CoreRepository.hpp>
00088 #include <openfluid/core/Event.hpp>
00089 #include <openfluid/core/EventsColl.hpp>
00090 
00091 
00092 // =====================================================================
00093 // =====================================================================
00094 
00098 #define PLUGFUNCTION_PROC_NAME "GetPlugFunction"
00099 
00103 #define PLUGSIGNATURE_PROC_NAME "GetPlugSignature"
00104 
00108 #define PLUGSDKVERSION_PROC_NAME "GetPlugSDKVersion"
00109 
00110 
00111 
00115 #define DECLARE_PLUGIN_HOOKS \
00116   extern "C" \
00117   { \
00118     DLLEXPORT std::string GetPlugSDKVersion(); \
00119     DLLEXPORT openfluid::base::PluggableFunction* GetPlugFunction(); \
00120     DLLEXPORT openfluid::base::FunctionSignature* GetPlugSignature(); \
00121   }
00122 
00123 
00124 
00125 
00126 // =====================================================================
00127 // =====================================================================
00128 
00129 
00134 #define DEFINE_FUNCTION_HOOK(pluginclassname) \
00135   std::string GetPlugSDKVersion() \
00136   { \
00137     return std::string(openfluid::config::FULL_VERSION); \
00138   } \
00139   \
00140   openfluid::base::PluggableFunction* GetPlugFunction() \
00141   { \
00142     return new pluginclassname(); \
00143   }
00144 
00145 
00146 
00147 // =====================================================================
00148 // =====================================================================
00149 
00154 #define DECLARE_UNITS_ORDERED_LOOP(loopid) \
00155   openfluid::core::UnitsList_t::iterator _M_##loopid##_ordit;\
00156   openfluid::core::UnitsList_t* _M_##loopid##_UList;
00157 
00158 
00163 #define DECLARE_GLOBAL_UNITS_ORDERED_LOOP(loopid) \
00164   openfluid::core::UnitsPtrList_t::iterator _M_##loopid##_ordit;\
00165   openfluid::core::UnitsPtrList_t* _M_##loopid##_GUList;
00166 
00167 
00174 #define BEGIN_UNITS_ORDERED_LOOP(loopid,unitclass,unit) \
00175   _M_##loopid##_UList = mp_CoreData->getUnits(unitclass)->getList(); \
00176   if (_M_##loopid##_UList != NULL) \
00177     { \
00178     for (_M_##loopid##_ordit = _M_##loopid##_UList->begin();_M_##loopid##_ordit != _M_##loopid##_UList->end();++_M_##loopid##_ordit) \
00179     { \
00180       unit = &(*_M_##loopid##_ordit);
00181 
00182 
00188 #define BEGIN_GLOBAL_UNITS_ORDERED_LOOP(loopid,unit) \
00189   { \
00190     _M_##loopid##_GUList = mp_CoreData->getUnitsGlobally(); \
00191     for (_M_##loopid##_ordit = _M_##loopid##_GUList->begin();_M_##loopid##_ordit != _M_##loopid##_GUList->end();++_M_##loopid##_ordit) \
00192     { \
00193       unit = (*_M_##loopid##_ordit);
00194 
00195 
00203 #define APPLY_UNITS_ORDERED_LOOP_THREADED(loopid,unitclass,funcptr,...) \
00204   _M_##loopid##_UList = mp_CoreData->getUnits(unitclass)->getList(); \
00205   if (_M_##loopid##_UList != NULL) \
00206   { \
00207     _M_##loopid##_ordit = _M_##loopid##_UList->begin(); \
00208     if (_M_##loopid##_ordit != _M_##loopid##_UList->end()) \
00209     { \
00210       openfluid::core::PcsOrd_t _M_##loopid##_pcsord = _M_##loopid##_ordit->getProcessOrder(); \
00211       while (_M_##loopid##_ordit != _M_##loopid##_UList->end()) \
00212       { \
00213         Glib::ThreadPool _M_##loopid##_pool(OPENFLUID_GetFunctionMaxThreads(),true); \
00214         while (_M_##loopid##_ordit != _M_##loopid##_UList->end() && _M_##loopid##_ordit->getProcessOrder() == _M_##loopid##_pcsord) \
00215         { \
00216           openfluid::core::Unit* _M_##loopid##_unit = &(*_M_##loopid##_ordit); \
00217           _M_##loopid##_pool.push(sigc::bind(sigc::mem_fun(*this,&funcptr),_M_##loopid##_unit, ## __VA_ARGS__)); \
00218           ++_M_##loopid##_ordit; \
00219         } \
00220         _M_##loopid##_pool.shutdown(); \
00221         if (_M_##loopid##_ordit != _M_##loopid##_UList->end()) _M_##loopid##_pcsord = _M_##loopid##_ordit->getProcessOrder(); \
00222       } \
00223     } \
00224   }
00225 
00226 
00233 #define APPLY_GLOBAL_UNITS_ORDERED_LOOP_THREADED(loopid,funcptr,...) \
00234   _M_##loopid##_GUList = mp_CoreData->getUnitsGlobally(); \
00235   if (_M_##loopid##_GUList != NULL) \
00236   { \
00237     _M_##loopid##_ordit = _M_##loopid##_GUList->begin(); \
00238     if (_M_##loopid##_ordit != _M_##loopid##_GUList->end()) \
00239     { \
00240       openfluid::core::PcsOrd_t _M_##loopid##_pcsord = (*_M_##loopid##_ordit)->getProcessOrder(); \
00241       while (_M_##loopid##_ordit != _M_##loopid##_GUList->end()) \
00242       { \
00243         Glib::ThreadPool _M_##loopid##_pool(OPENFLUID_GetFunctionMaxThreads(),true); \
00244         while (_M_##loopid##_ordit != _M_##loopid##_GUList->end() && (*_M_##loopid##_ordit)->getProcessOrder() == _M_##loopid##_pcsord) \
00245         { \
00246           openfluid::core::Unit* _M_##loopid##_unit = (*_M_##loopid##_ordit); \
00247           _M_##loopid##_pool.push(sigc::bind(sigc::mem_fun(*this,&funcptr),_M_##loopid##_unit, ## __VA_ARGS__)); \
00248           ++_M_##loopid##_ordit; \
00249         } \
00250         _M_##loopid##_pool.shutdown(); \
00251         if (_M_##loopid##_ordit != _M_##loopid##_GUList->end()) _M_##loopid##_pcsord = (*_M_##loopid##_ordit)->getProcessOrder(); \
00252       } \
00253     } \
00254   }
00255 
00256 
00257 
00262 #define DECLARE_UNITS_LIST_LOOP(loopid) \
00263   openfluid::core::UnitsPtrList_t::iterator _M_##loopid##_lstit;\
00264 
00265 
00272 #define BEGIN_UNITS_LIST_LOOP(loopid,ulist,unit) \
00273   if ((ulist) != NULL) \
00274   { \
00275     for(_M_##loopid##_lstit=ulist->begin(); _M_##loopid##_lstit != ulist->end(); _M_##loopid##_lstit++) \
00276     { \
00277       unit = *_M_##loopid##_lstit; \
00278 
00279 
00283 #define DECLARE_EVENT_COLLECTION_LOOP \
00284   openfluid::core::EventsList_t::iterator _M_EvListiter;
00285 
00291 #define BEGIN_EVENT_COLLECTION_LOOP(evlist,evobj) \
00292   { \
00293     for(_M_EvListiter=(evlist)->begin(); _M_EvListiter != (evlist)->end(); _M_EvListiter++) \
00294     { \
00295       evobj = &(*_M_EvListiter);
00296 
00300 #define END_LOOP \
00301     } \
00302   }
00303 
00304 
00305 
00306 
00307 // =====================================================================
00308 // =====================================================================
00309 
00310 
00311 namespace openfluid { namespace base {
00312 
00313 
00314 
00324 class DLLEXPORT PluggableFunction
00325 {
00326 
00327   private:
00328 
00332     openfluid::core::CoreRepository* mp_InternalCoreData;
00333 
00334 
00338     openfluid::base::ExecutionMessages* mp_ExecMsgs;
00339 
00340 
00344     const openfluid::base::EnvironmentProperties* mp_FunctionEnv;
00345 
00346 
00350     openfluid::core::FuncParamsMap_t m_ParamsMap;
00351 
00355     openfluid::base::FuncID_t m_FunctionID;
00356 
00357     unsigned int m_MaxThreads;
00358 
00359     bool m_Initialized;
00360 
00361     static bool IsUnitIDInPtrList(const openfluid::core::UnitsPtrList_t* UnitsList,
00362                                   const openfluid::core::UnitID_t& ID);
00363 
00364     static std::string generateDotEdge(std::string SrcClass, std::string SrcID,
00365                                        std::string DestClass, std::string DestID,
00366                                        std::string Options);
00367 
00368 
00369   protected:
00370 
00371     // TODO check if const
00375     openfluid::core::CoreRepository* mp_CoreData;
00376 
00384     void OPENFLUID_AppendVariable(openfluid::core::Unit *UnitPtr,
00385                                   const openfluid::core::VariableName_t VarName,
00386                                   const openfluid::core::Value& Val);
00387 
00394     void OPENFLUID_AppendVariable(openfluid::core::Unit& aUnit,
00395                                   const openfluid::core::VariableName_t VarName,
00396                                   const openfluid::core::Value& Val);
00397 
00404     void OPENFLUID_AppendVariable(openfluid::core::Unit *UnitPtr,
00405                                   const openfluid::core::VariableName_t VarName,
00406                                   const double Val);
00407 
00414     void OPENFLUID_AppendVariable(openfluid::core::Unit *UnitPtr,
00415                                   const openfluid::core::VariableName_t VarName,
00416                                   const long Val);
00417 
00424     void OPENFLUID_AppendVariable(openfluid::core::Unit *UnitPtr,
00425                                   const openfluid::core::VariableName_t VarName,
00426                                   const bool Val);
00427 
00434     void OPENFLUID_AppendVariable(openfluid::core::Unit *UnitPtr,
00435                                   const openfluid::core::VariableName_t VarName,
00436                                   const std::string& Val);
00437 
00438 
00446     void OPENFLUID_SetVariable(openfluid::core::Unit *UnitPtr,
00447                                const openfluid::core::VariableName_t VarName,
00448                                const openfluid::core::TimeStep_t Step,
00449                                const openfluid::core::Value& Val);
00450 
00458     void OPENFLUID_SetVariable(openfluid::core::Unit *UnitPtr,
00459                                const openfluid::core::VariableName_t VarName,
00460                                const openfluid::core::TimeStep_t Step,
00461                                const double Val);
00462 
00470     void OPENFLUID_SetVariable(openfluid::core::Unit *UnitPtr,
00471                                const openfluid::core::VariableName_t VarName,
00472                                const openfluid::core::TimeStep_t Step,
00473                                const long Val);
00474 
00482     void OPENFLUID_SetVariable(openfluid::core::Unit *UnitPtr,
00483                                const openfluid::core::VariableName_t VarName,
00484                                const openfluid::core::TimeStep_t Step,
00485                                const bool Val);
00486 
00494     void OPENFLUID_SetVariable(openfluid::core::Unit *UnitPtr,
00495                                const openfluid::core::VariableName_t VarName,
00496                                const openfluid::core::TimeStep_t Step,
00497                                const std::string Val);
00498 
00499 
00508     void OPENFLUID_GetVariable(const openfluid::core::Unit* UnitPtr,
00509                                const openfluid::core::VariableName_t VarName,
00510                                const openfluid::core::TimeStep_t Step,
00511                                openfluid::core::Value* Val) const;
00512 
00520     void OPENFLUID_GetVariable(const openfluid::core::Unit* UnitPtr,
00521                                const openfluid::core::VariableName_t VarName,
00522                                const openfluid::core::TimeStep_t Step,
00523                                openfluid::core::Value& Val) const;
00524 
00533     void OPENFLUID_GetVariable(const openfluid::core::Unit* UnitPtr,
00534                                const openfluid::core::VariableName_t VarName,
00535                                const openfluid::core::TimeStep_t Step,
00536                                double* Val) const;
00537 
00545     void OPENFLUID_GetVariable(const openfluid::core::Unit* UnitPtr,
00546                                const openfluid::core::VariableName_t VarName,
00547                                const openfluid::core::TimeStep_t Step,
00548                                double& Val) const;
00557     void OPENFLUID_GetVariable(const openfluid::core::Unit* UnitPtr,
00558                                const openfluid::core::VariableName_t VarName,
00559                                const openfluid::core::TimeStep_t Step,
00560                                long* Val) const;
00561 
00569     void OPENFLUID_GetVariable(const openfluid::core::Unit* UnitPtr,
00570                                const openfluid::core::VariableName_t VarName,
00571                                const openfluid::core::TimeStep_t Step,
00572                                long& Val) const;
00573 
00582     void OPENFLUID_GetVariable(const openfluid::core::Unit* UnitPtr,
00583                                const openfluid::core::VariableName_t VarName,
00584                                const openfluid::core::TimeStep_t Step,
00585                                bool* Val) const;
00586 
00594     void OPENFLUID_GetVariable(const openfluid::core::Unit* UnitPtr,
00595                                const openfluid::core::VariableName_t VarName,
00596                                const openfluid::core::TimeStep_t Step,
00597                                bool& Val) const;
00598 
00599 
00608     void OPENFLUID_GetVariable(const openfluid::core::Unit* UnitPtr,
00609                                const openfluid::core::VariableName_t VarName,
00610                                const openfluid::core::TimeStep_t Step,
00611                                std::string* Val) const;
00612 
00620     void OPENFLUID_GetVariable(const openfluid::core::Unit* UnitPtr,
00621                                const openfluid::core::VariableName_t VarName,
00622                                const openfluid::core::TimeStep_t Step,
00623                                std::string& Val) const;
00624 
00630     bool OPENFLUID_IsVariableExist(const openfluid::core::Unit *UnitPtr,
00631                                    const openfluid::core::VariableName_t VarName) const;
00632 
00639     bool OPENFLUID_IsVariableExist(const openfluid::core::Unit *UnitPtr,
00640                                    const openfluid::core::VariableName_t VarName,
00641                                    const openfluid::core::TimeStep_t Step) const;
00642 
00651      bool OPENFLUID_IsVariableExist(const openfluid::core::Unit *UnitPtr,
00652                                     const openfluid::core::VariableName_t VarName,
00653                                     const openfluid::core::TimeStep_t Step,
00654                                     const openfluid::core::Value::Type ValueType) const;
00655 
00663     bool OPENFLUID_IsTypedVariableExist(const openfluid::core::Unit *UnitPtr,
00664                                    const openfluid::core::VariableName_t VarName,
00665                                    const openfluid::core::Value::Type VarType) const;
00666 
00675      bool OPENFLUID_IsTypedVariableExist(const openfluid::core::Unit *UnitPtr,
00676                                     const openfluid::core::VariableName_t VarName,
00677                                     const openfluid::core::TimeStep_t Step,
00678                                     const openfluid::core::Value::Type VarType) const;
00679 
00680 
00687      void OPENFLUID_SetInputData(openfluid::core::Unit *UnitPtr,
00688                                  const openfluid::core::InputDataName_t& InputName,
00689                                  const openfluid::core::Value& Val);
00690 
00697      void OPENFLUID_SetInputData(openfluid::core::Unit *UnitPtr,
00698                                  const openfluid::core::InputDataName_t& InputName,
00699                                  const double& Val);
00700 
00707      void OPENFLUID_SetInputData(openfluid::core::Unit *UnitPtr,
00708                                  const openfluid::core::InputDataName_t& InputName,
00709                                  const long& Val);
00710 
00717      void OPENFLUID_SetInputData(openfluid::core::Unit *UnitPtr,
00718                                  const openfluid::core::InputDataName_t& InputName,
00719                                  const std::string& Val);
00720 
00721 
00728     void OPENFLUID_GetInputData(const openfluid::core::Unit *UnitPtr,
00729                                 const openfluid::core::InputDataName_t InputName,
00730                                 openfluid::core::StringValue& Val) const;
00731 
00739     void OPENFLUID_GetInputData(const openfluid::core::Unit *UnitPtr,
00740                                 const openfluid::core::InputDataName_t InputName,
00741                                 openfluid::core::DoubleValue* Val) const;
00742 
00749     void OPENFLUID_GetInputData(const openfluid::core::Unit *UnitPtr,
00750                                 const openfluid::core::InputDataName_t InputName,
00751                                 openfluid::core::DoubleValue& Val) const;
00752 
00760     void OPENFLUID_GetInputData(const openfluid::core::Unit *UnitPtr,
00761                                 const openfluid::core::InputDataName_t InputName,
00762                                 openfluid::core::VectorValue* Val) const;
00763 
00770     void OPENFLUID_GetInputData(const openfluid::core::Unit *UnitPtr,
00771                                 const openfluid::core::InputDataName_t InputName,
00772                                 openfluid::core::VectorValue& Val) const;
00773 
00780     void OPENFLUID_GetInputData(const openfluid::core::Unit *UnitPtr,
00781                                 const openfluid::core::InputDataName_t InputName,
00782                                 openfluid::core::MatrixValue& Val) const;
00783 
00791     void OPENFLUID_GetInputData(const openfluid::core::Unit *UnitPtr,
00792                                 const openfluid::core::InputDataName_t InputName,
00793                                 double *Val) const;
00794 
00801     void OPENFLUID_GetInputData(const openfluid::core::Unit *UnitPtr,
00802                                 const openfluid::core::InputDataName_t InputName,
00803                                 double& Val) const;
00804 
00812     void OPENFLUID_GetInputData(const openfluid::core::Unit *UnitPtr,
00813                                 const openfluid::core::InputDataName_t InputName,
00814                                 long *Val) const;
00815 
00822     void OPENFLUID_GetInputData(const openfluid::core::Unit *UnitPtr,
00823                                 const openfluid::core::InputDataName_t InputName,
00824                                 long& Val) const;
00825 
00833     void OPENFLUID_GetInputData(const openfluid::core::Unit *UnitPtr,
00834                                 const openfluid::core::InputDataName_t InputName,
00835                                 std::string *Val) const;
00836 
00843     void OPENFLUID_GetInputData(const openfluid::core::Unit *UnitPtr,
00844                                 const openfluid::core::InputDataName_t InputName,
00845                                 std::string& Val) const;
00846 
00852     bool OPENFLUID_IsInputDataExist(const openfluid::core::Unit *UnitPtr,
00853                                     const openfluid::core::InputDataName_t InputName) const;
00854 
00855 
00862     bool OPENFLUID_GetFunctionParameter(const openfluid::core::FuncParamsMap_t Params,
00863                                         const openfluid::core::FuncParamKey_t ParamName,
00864                                         openfluid::core::StringValue& Val) const;
00865 
00872     bool OPENFLUID_GetFunctionParameter(const openfluid::core::FuncParamsMap_t Params,
00873                                         const openfluid::core::FuncParamKey_t ParamName,
00874                                         openfluid::core::DoubleValue& Val) const;
00875 
00882     bool OPENFLUID_GetFunctionParameter(const openfluid::core::FuncParamsMap_t Params,
00883                                         const openfluid::core::FuncParamKey_t ParamName,
00884                                         openfluid::core::VectorValue& Val) const;
00885 
00892     bool OPENFLUID_GetFunctionParameter(const openfluid::core::FuncParamsMap_t Params,
00893                                         const openfluid::core::FuncParamKey_t ParamName,
00894                                         openfluid::core::MatrixValue& Val) const;
00895 
00903     bool OPENFLUID_GetFunctionParameter(const openfluid::core::FuncParamsMap_t Params,
00904                                         const openfluid::core::FuncParamKey_t ParamName,
00905                                         double *Val) const;
00906 
00913     bool OPENFLUID_GetFunctionParameter(const openfluid::core::FuncParamsMap_t Params,
00914                                         const openfluid::core::FuncParamKey_t ParamName,
00915                                         double& Val) const;
00916 
00924     bool OPENFLUID_GetFunctionParameter(const openfluid::core::FuncParamsMap_t Params,
00925                                         const openfluid::core::FuncParamKey_t ParamName,
00926                                         long *Val) const;
00927 
00934     bool OPENFLUID_GetFunctionParameter(const openfluid::core::FuncParamsMap_t Params,
00935                                         const openfluid::core::FuncParamKey_t ParamName,
00936                                         long& Val) const;
00937 
00945     bool OPENFLUID_GetFunctionParameter(const openfluid::core::FuncParamsMap_t Params,
00946                                         const openfluid::core::FuncParamKey_t ParamName,
00947                                         float *Val) const;
00948 
00955     bool OPENFLUID_GetFunctionParameter(const openfluid::core::FuncParamsMap_t Params,
00956                                         const openfluid::core::FuncParamKey_t ParamName,
00957                                         float& Val) const;
00958 
00966     bool OPENFLUID_GetFunctionParameter(const openfluid::core::FuncParamsMap_t Params,
00967                                         const openfluid::core::FuncParamKey_t ParamName,
00968                                         int *Val) const;
00969 
00976     bool OPENFLUID_GetFunctionParameter(const openfluid::core::FuncParamsMap_t Params,
00977                                         const openfluid::core::FuncParamKey_t ParamName,
00978                                         int& Val) const;
00979 
00987     bool OPENFLUID_GetFunctionParameter(const openfluid::core::FuncParamsMap_t Params,
00988                                         const openfluid::core::FuncParamKey_t ParamName,
00989                                         std::string *Val) const;
00990 
00997     bool OPENFLUID_GetFunctionParameter(const openfluid::core::FuncParamsMap_t Params,
00998                                         const openfluid::core::FuncParamKey_t ParamName,
00999                                         std::string& Val) const;
01000 
01008     bool OPENFLUID_GetFunctionParameter(const openfluid::core::FuncParamsMap_t Params,
01009                                         const openfluid::core::FuncParamKey_t ParamName,
01010                                         std::vector<std::string> *Vals) const;
01011 
01018     bool OPENFLUID_GetFunctionParameter(const openfluid::core::FuncParamsMap_t Params,
01019                                         const openfluid::core::FuncParamKey_t ParamName,
01020                                         std::vector<std::string>& Vals) const;
01021 
01029     bool OPENFLUID_GetFunctionParameter(const openfluid::core::FuncParamsMap_t Params,
01030                                         const openfluid::core::FuncParamKey_t ParamName,
01031                                         std::vector<double> *Vals) const;
01032 
01039     bool OPENFLUID_GetFunctionParameter(const openfluid::core::FuncParamsMap_t Params,
01040                                         const openfluid::core::FuncParamKey_t ParamName,
01041                                         std::vector<double>& Vals) const;
01042 
01050     bool OPENFLUID_GetFunctionParameter(const openfluid::core::FuncParamsMap_t Params,
01051                                         const openfluid::core::FuncParamKey_t ParamName,
01052                                         std::vector<long> *Vals) const;
01053 
01060     bool OPENFLUID_GetFunctionParameter(const openfluid::core::FuncParamsMap_t Params,
01061                                         const openfluid::core::FuncParamKey_t ParamName,
01062                                         std::vector<long>& Vals) const;
01063 
01064 
01070     void OPENFLUID_AppendEvent(openfluid::core::Unit *UnitPtr,
01071                                openfluid::core::Event& Ev);
01072 
01073 
01082     void OPENFLUID_GetEvents(const openfluid::core::Unit *UnitPtr,
01083                              const openfluid::core::DateTime BeginDate,
01084                              const openfluid::core::DateTime EndDate,
01085                              openfluid::core::EventsCollection* Events) const;
01086 
01094     void OPENFLUID_GetEvents(const openfluid::core::Unit *UnitPtr,
01095                              const openfluid::core::DateTime BeginDate,
01096                              const openfluid::core::DateTime EndDate,
01097                              openfluid::core::EventsCollection& Events) const;
01098 
01103     bool OPENFLUID_IsUnitClassExist(openfluid::core::UnitClass_t ClassName);
01104 
01105 
01111     bool OPENFLUID_IsUnitExist(openfluid::core::UnitClass_t ClassName,
01112                                openfluid::core::UnitID_t ID);
01113 
01118     void OPENFLUID_GetUnitsCount(unsigned int& UnitsCount);
01119 
01126     bool OPENFLUID_GetUnitsCount(const openfluid::core::UnitClass_t ClassName,
01127                                  unsigned int& UnitsCount);
01128 
01129 
01137     bool OPENFLUID_GetUnit(const openfluid::core::UnitClass_t& ClassName,
01138                            const openfluid::core::UnitID_t& ID,
01139                            openfluid::core::Unit* aUnit);
01140 
01141     openfluid::core::Unit* OPENFLUID_GetUnit(const openfluid::core::UnitClass_t& ClassName,
01142                                              const openfluid::core::UnitID_t& ID);
01143 
01150     void OPENFLUID_AddUnit(openfluid::core::UnitClass_t ClassName,
01151                            openfluid::core::UnitID_t ID,
01152                            openfluid::core::PcsOrd_t PcsOrder);
01153 
01160     void OPENFLUID_DeleteUnit(openfluid::core::UnitClass_t ClassName,
01161                               openfluid::core::UnitID_t ID);
01162 
01163 
01172     bool OPENFLUID_AddFromToConnection(openfluid::core::UnitClass_t ClassNameFrom,
01173                                        openfluid::core::UnitID_t IDFrom,
01174                                        openfluid::core::UnitClass_t ClassNameTo,
01175                                        openfluid::core::UnitID_t IDTo);
01176 
01183     bool OPENFLUID_AddFromToConnection(openfluid::core::Unit* FromUnit,
01184                                        openfluid::core::Unit* ToUnit);
01185 
01194     bool OPENFLUID_RemoveFromToConnection(openfluid::core::UnitClass_t ClassNameFrom,
01195                                           openfluid::core::UnitID_t IDFrom,
01196                                           openfluid::core::UnitClass_t ClassNameTo,
01197                                           openfluid::core::UnitID_t IDTo);
01198 
01205     bool OPENFLUID_RemoveFromToConnection(openfluid::core::Unit* FromUnit,
01206                                           openfluid::core::Unit* ToUnit);
01207 
01208 
01217     bool OPENFLUID_AddChildParentConnection(openfluid::core::UnitClass_t ClassNameChild,
01218                                             openfluid::core::UnitID_t IDChild,
01219                                             openfluid::core::UnitClass_t ClassNameParent,
01220                                             openfluid::core::UnitID_t IDParent);
01221 
01228     bool OPENFLUID_AddChildParentConnection(openfluid::core::Unit* ChildUnit,
01229                                             openfluid::core::Unit* ParentUnit);
01230 
01231 
01240     bool OPENFLUID_RemoveChildParentConnection(openfluid::core::UnitClass_t ClassNameChild,
01241                                                 openfluid::core::UnitID_t IDChild,
01242                                                 openfluid::core::UnitClass_t ClassNameParent,
01243                                                 openfluid::core::UnitID_t IDParent);
01244 
01251     bool OPENFLUID_RemoveChildParentConnection(openfluid::core::Unit* ChildUnit,
01252                                                 openfluid::core::Unit* ParentUnit);
01253 
01261     bool OPENFLUID_IsUnitConnectedTo(openfluid::core::Unit* aUnit,
01262                                      const openfluid::core::UnitClass_t& ClassNameTo,
01263                                      const openfluid::core::UnitID_t& IDTo);
01264 
01265 
01273     bool OPENFLUID_IsUnitConnectedFrom(openfluid::core::Unit* aUnit,
01274                                        const openfluid::core::UnitClass_t& ClassNameFrom,
01275                                        const openfluid::core::UnitID_t& IDFrom);
01276 
01277 
01285     bool OPENFLUID_IsUnitChildOf(openfluid::core::Unit* aUnit,
01286                                  const openfluid::core::UnitClass_t& ClassNameParent,
01287                                  const openfluid::core::UnitID_t& IDParent);
01288 
01289 
01297     bool OPENFLUID_IsUnitParentOf(openfluid::core::Unit* aUnit,
01298                                   const openfluid::core::UnitClass_t& ClassNameChild,
01299                                   const openfluid::core::UnitID_t& IDChild);
01300 
01301 
01308     void OPENFLUID_BuildUnitsMatrix(const openfluid::core::UnitClass_t& UnitsClass,
01309                                     const unsigned int& ColsNbr,
01310                                     const unsigned int& RowsNbr);
01311 
01312 
01318     void OPENFLUID_ExportUnitsGraphAsDotFile(const std::string& Filename);
01319 
01326     void OPENFLUID_RaiseWarning(std::string Sender, openfluid::core::TimeStep_t TimeStep, std::string Msg);
01327 
01333     void OPENFLUID_RaiseWarning(std::string Sender, std::string Msg);
01334 
01342     void OPENFLUID_RaiseWarning(std::string Sender, std::string Source, openfluid::core::TimeStep_t TimeStep, std::string Msg);
01343 
01350     void OPENFLUID_RaiseWarning(std::string Sender, std::string Source, std::string Msg);
01351 
01352 
01359     void OPENFLUID_RaiseError(std::string Sender, openfluid::core::TimeStep_t TimeStep, std::string Msg);
01360 
01366     void OPENFLUID_RaiseError(std::string Sender, std::string Msg);
01367 
01375     void OPENFLUID_RaiseError(std::string Sender, std::string Source, openfluid::core::TimeStep_t TimeStep, std::string Msg);
01376 
01383     void OPENFLUID_RaiseError(std::string Sender, std::string Source, std::string Msg);
01384 
01385 
01391     bool OPENFLUID_GetRunEnvironment(std::string Key, std::string *Val);
01392 
01398     bool OPENFLUID_GetRunEnvironment(std::string Key, bool *Val);
01399 
01404     inline unsigned int OPENFLUID_GetFunctionMaxThreads() const { return m_MaxThreads; };
01405 
01410     void OPENFLUID_SetFunctionMaxThreads(const unsigned int& MaxNumThreads);
01411 
01412 
01413     StdoutAndFileOutputStream OPENFLUID_Logger;
01414 
01415 
01416   public:
01420     PluggableFunction();
01421 
01425     virtual ~PluggableFunction();
01426 
01430     void initializeFunction(openfluid::core::CoreRepository* CoreData,
01431                             openfluid::base::ExecutionMessages* ExecMsgs,
01432                             openfluid::base::EnvironmentProperties* FuncEnv,
01433                             const unsigned int& MaxThreads,
01434                             const openfluid::base::FuncID_t& FuncID);
01435 
01439     void finalizeFunction();
01440 
01441 
01442 
01446     virtual bool initParams(openfluid::core::FuncParamsMap_t Params)=0;
01447 
01451     virtual bool prepareData()=0;
01452 
01456     virtual bool checkConsistency()=0;
01457 
01461     virtual bool initializeRun(const SimulationInfo* SimInfo)=0;
01462 
01466     virtual bool runStep(const SimulationStatus* SimStatus)=0;
01467 
01471     virtual bool finalizeRun(const SimulationInfo* SimInfo)=0;
01472 
01473 };
01474 
01475 
01476 typedef PluggableFunction* (*GetPluggableFunctionProc)();
01477 
01478 typedef FunctionSignature* (*GetSignatureProc)();
01479 
01480 typedef std::string (*GetSDKVersionProc)();
01481 
01482 
01483 
01484 } } // namespace openfluid::base
01485 
01486 
01487 
01488 #endif
01489 

Generated using Doxygen 1.7.6.1
Creative Commons License Creative Commons By-NC-ND license