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 __EVENT_HPP__ 00041 #define __EVENT_HPP__ 00042 00043 00044 #include <openfluid/dllexport.hpp> 00045 #include <openfluid/deprecation.hpp> 00046 #include <openfluid/core/TypeDefs.hpp> 00047 #include <openfluid/core/DateTime.hpp> 00048 00049 00050 namespace openfluid { namespace core { 00051 00052 00053 00054 /** 00055 @brief Class defining a discrete event, including attached information 00056 00057 Each event attached information is represented by a Key-Value couple : 00058 @li Key is the name given to the information 00059 @li Value is the value of the information and can be numeric or text information 00060 */ 00061 class DLLEXPORT Event 00062 { 00063 public: 00064 typedef std::map<std::string, openfluid::core::StringValue> EventInfosMap_t; 00065 00066 private: 00067 DateTime m_Date; 00068 00069 EventInfosMap_t m_Infos; 00070 00071 public: 00072 00073 /** 00074 Default constructor 00075 */ 00076 Event(); 00077 00078 /** 00079 Constructor 00080 @param[in] Date the date and time of the event 00081 */ 00082 Event(DateTime Date); 00083 00084 /** 00085 Destructor 00086 */ 00087 ~Event(); 00088 00089 /** 00090 Returns true if the information exists 00091 @param[in] Key the requested information key 00092 */ 00093 bool isInfoExist(const std::string Key) const; 00094 00095 /** 00096 Returns true if the information exists and equals the given string value 00097 @param[in] Key the requested information key 00098 @param[in] Value the requested value 00099 */ 00100 bool isInfoEqual(const std::string Key, const std::string Value) const; 00101 00102 /** 00103 Returns true if the information exists and equals the given long value 00104 @param[in] Key the requested information key 00105 @param[in] Value the requested value 00106 */ 00107 bool isInfoEqual(const std::string Key, long Value) const; 00108 00109 /** 00110 Returns true if the information exists and equals the given double value 00111 @param[in] Key the requested information key 00112 @param[in] Value the requested value 00113 */ 00114 bool isInfoEqual(const std::string Key, const double Value) const; 00115 00116 /** 00117 Returns true if the information exists and equals the given double value 00118 @param[in] Key the requested information key 00119 @param[in] Info the requested value 00120 @deprecated 00121 */ 00122 bool isInfoEqual(const std::string Key, const double* Info) const OPENFLUID_DEPRECATED; 00123 00124 /** 00125 Returns true if the information exists and equals the given DoubleValue value 00126 @param[in] Key the requested information key 00127 @param[in] Info the requested value 00128 */ 00129 bool isInfoEqual(const std::string Key, const DoubleValue& Info) const; 00130 00131 /** 00132 Returns the number of information 00133 */ 00134 inline int getInfosCount() const { return m_Infos.size(); } 00135 00136 /** 00137 Returns all the informations as an EventInfosMap 00138 */ 00139 inline EventInfosMap_t getInfos() const { return m_Infos; } 00140 00141 /** 00142 Returns the date and time of the event 00143 */ 00144 inline DateTime getDateTime() const { return m_Date; } 00145 00146 /** 00147 Gets an information as a string 00148 @param[in] Key the requested information key 00149 @param[out] Info the value corresponding to the requested key 00150 @return true if the key exists and the conversion to the requested type is correct 00151 @deprecated 00152 */ 00153 bool getInfoAsString(const std::string Key, std::string *Info) const OPENFLUID_DEPRECATED; 00154 00155 /** 00156 Gets an information as a string 00157 @param[in] Key the requested information key 00158 @param[out] Info the value corresponding to the requested key 00159 @return true if the key exists and the conversion to the requested type is correct 00160 */ 00161 bool getInfoAsString(const std::string Key, std::string& Info) const; 00162 00163 /** 00164 Gets an information as a long integer 00165 @param[in] Key the requested information key 00166 @param[out] Info the value corresponding to the requested key 00167 @return true if the key exists and the conversion to the requested type is correct 00168 @deprecated 00169 */ 00170 bool getInfoAsLong(const std::string Key, long *Info) const OPENFLUID_DEPRECATED; 00171 00172 /** 00173 Gets an information as a long integer 00174 @param[in] Key the requested information key 00175 @param[out] Info the value corresponding to the requested key 00176 @return true if the key exists and the conversion to the requested type is correct 00177 */ 00178 bool getInfoAsLong(const std::string Key, long& Info) const; 00179 00180 /** 00181 Gets an information as a double 00182 @param[in] Key the requested information key 00183 @param[out] Info the value corresponding to the requested key 00184 @return true if the key exists and the conversion to the requested type is correct 00185 @deprecated 00186 */ 00187 bool getInfoAsDouble(const std::string Key, double *Info) const OPENFLUID_DEPRECATED; 00188 00189 /** 00190 Gets an information as a double 00191 @param[in] Key the requested information key 00192 @param[out] Info the value corresponding to the requested key 00193 @return true if the key exists and the conversion to the requested type is correct 00194 */ 00195 bool getInfoAsDouble(const std::string Key, double& Info) const; 00196 00197 /** 00198 Gets an information as a DoubleValue 00199 @param[in] Key the requested information key 00200 @param[out] Info the value corresponding to the requested key 00201 @return true if the key exists and the conversion to the requested type is correct 00202 */ 00203 bool getInfoAsDoubleValue(const std::string Key, DoubleValue& Info) const; 00204 00205 /** 00206 Adds an information to the event 00207 @param[in] Key the key of the added information 00208 @param[in] Info the value of the added information 00209 @return true if the adding is correct (key does not already exists) 00210 */ 00211 bool addInfo(const std::string Key, const std::string Info); 00212 00213 /** 00214 Prints the content of the event to stdout 00215 */ 00216 void println() const; 00217 00218 }; 00219 00220 } } // namespace openfluid::core 00221 00222 #endif /* __EVENT_HPP__ */