All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PluggableWare.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 PluggableWare.hpp
35  \brief Header of ...
36 
37  \author Jean-Christophe FABRE <fabrejc@supagro.inra.fr>
38  */
39 
40 
41 #ifndef __PLUGGABLEWARE_HPP__
42 #define __PLUGGABLEWARE_HPP__
43 
44 #include <boost/filesystem/path.hpp>
45 #include <boost/property_tree/ptree.hpp>
46 #include <string>
47 
48 #include <openfluid/dllexport.hpp>
51 
52 
53 namespace openfluid { namespace ware {
54 
55 
56 /**
57  Hook function name of ware plugin body
58 */
59 #define WAREBODY_PROC_NAME "GetWareBody"
60 #define WAREBODY_PROC_DECL GetWareBody
61 
62 /**
63  Hook function name of ware plugin signature
64 */
65 #define WARESIGNATURE_PROC_NAME "GetWareSignature"
66 #define WARESIGNATURE_PROC_DECL GetWareSignature
67 
68 /**
69  Hook function name of ware ABI version
70 */
71 #define WAREABIVERSION_PROC_NAME "GetWareABIVersion"
72 #define WAREABIVERSION_PROC_DECL GetWareABIVersion
73 
74 
75 // =====================================================================
76 // =====================================================================
77 
78 
79 typedef std::string WareParamKey_t;
81 
82 typedef std::map<WareParamKey_t, WareParamValue_t> WareParams_t;
83 
84 
85 // =====================================================================
86 // =====================================================================
87 
88 
90 {
91  public:
92 
93  enum WareType { UNDEFINED, OBSERVER, SIMULATOR, OTHER };
94 
95 
96  private:
97 
98  /**
99  Ware execution environment
100  */
101  const openfluid::base::EnvironmentProperties* mp_WareEnv;
102 
103  /**
104  Simulator ID
105  */
106  WareID_t m_WareID;
107 
108 
109  protected:
110 
111  virtual bool isLinked() const { return mp_WareEnv != NULL; };
112 
113  bool m_Initialized;
114 
115  /**
116  Raises an error message to the kernel. This stops the simulation the next time the kernel has the control
117  @param[in] Msg the content of the message
118  */
119  virtual void OPENFLUID_RaiseError(const std::string& Msg);
120 
121  /**
122  Gets an environment string value associated to a Key
123  @param[in] Key the sender of the message
124  @param[out] Val the value associated with the environment key
125  */
126  bool OPENFLUID_GetRunEnvironment(std::string Key, std::string& Val);
127 
128  /**
129  Gets an environment boolean value associated to a Key
130  @param[in] Key the sender of the message
131  @param[out] Val the value associated with the environment key
132  */
133  bool OPENFLUID_GetRunEnvironment(std::string Key, bool& Val);
134 
135  /**
136  Returns the ID of the ware (itself)
137  @return the ID
138  */
139  WareID_t OPENFLUID_GetWareID() const { return m_WareID; };
140 
141  WareType m_WareType;
142 
143 
144  PluggableWare(WareType WType);
145 
146  public:
147 
148  virtual ~PluggableWare();
149 
151  {
152  mp_WareEnv = Env;
153  };
154 
155  virtual void initializeWare(const WareID_t& ID);
156 
157  virtual void finalizeWare();
158 
159  /**
160  * Return false if ParameterKey starts nor ends with a dot, true otherwise
161  */
162  static bool isWellFormated(const openfluid::ware::WareParamKey_t& ParameterKey);
163 
164  static boost::property_tree::ptree getParamsAsPropertyTree(
165  const WareParams_t& Params);
166 
167 };
168 
169 
170 
171 } } // openfluid::ware
172 
173 
174 
175 #endif /* __PLUGGABLEWARE_HPP__ */
Definition: StringValue.hpp:91
std::map< WareParamKey_t, WareParamValue_t > WareParams_t
Definition: PluggableWare.hpp:82
openfluid::core::StringValue WareParamValue_t
Definition: PluggableWare.hpp:80
WareType
Definition: PluggableWare.hpp:93
void linkToRunEnvironment(const openfluid::base::EnvironmentProperties *Env)
Definition: PluggableWare.hpp:150
WareID_t OPENFLUID_GetWareID() const
Definition: PluggableWare.hpp:139
std::string WareID_t
Definition: WareSignature.hpp:86
Header of ...
std::string WareParamKey_t
Definition: PluggableWare.hpp:79
Definition: PluggableWare.hpp:89
Definition: EnvProperties.hpp:53
#define DLLEXPORT
Definition: dllexport.hpp:51