Changeset 489 for XIOS/trunk/src/node/variable.hpp
- Timestamp:
- 09/22/14 14:17:33 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/node/variable.hpp
r472 r489 15 15 class CVariableAttributes; 16 16 class CVariable; 17 17 class CContext; 18 18 ///-------------------------------------------------------------- 19 19 … … 29 29 , public CVariableAttributes 30 30 { 31 enum EEventId 32 { 33 EVENT_ID_VARIABLE_VALUE 34 }; 35 31 36 /// typedef /// 32 37 typedef CObjectTemplate<CVariable> SuperClass; … … 52 57 enum EVarType 53 58 { t_int, t_short_int, t_long_int, t_float, t_double, t_long_double, t_bool, t_string, t_undefined } ; 54 55 59 60 56 61 /// Autres /// 57 62 virtual void parse(xml::CXMLNode & node); … … 60 65 /// Accesseur /// 61 66 const StdString & getContent (void) const; 62 63 67 68 void setContent(const StdString& content); 69 70 64 71 template <typename T> inline T getData(void) const; 65 72 template <typename T> inline void setData(T data); 73 66 74 template <typename T, StdSize N> 67 75 inline void getData(CArray<T, N>& _data_array) const; 68 76 69 77 EVarType getVarType(void) const ; 70 78 79 static bool dispatchEvent(CEventServer& event) ; 80 81 //! Sending a request to set up variable data 82 void sendValue(); 83 84 static void recvValue(CEventServer& event) ; 85 void recvValue(CBufferIn& buffer) ; 86 71 87 public : 72 88 73 89 /// Accesseurs statiques /// 74 90 static StdString GetName(void); … … 85 101 inline bool CVariable::getData(void) const 86 102 { 87 if (content.compare("true")==0 || content.compare(".true.")==0 || content.compare(".TRUE.")==0) return true ; 88 else if (content.compare("false")==0 || content.compare(".false.")==0 || content.compare(".FALSE.")==0) return false ; 103 if (content.compare("true")==0 || content.compare(".true.")==0 || content.compare(".TRUE.")==0) return true ; 104 else if (content.compare("false")==0 || content.compare(".false.")==0 || content.compare(".FALSE.")==0) return false ; 89 105 else ERROR("CVariable::getdata()", 90 106 << "Cannot convert string <" << content << "> into type required" ); 91 107 return false ; 92 } 93 108 } 109 94 110 template <typename T> 95 111 inline T CVariable::getData(void) const 96 112 { 97 113 T retval ; 98 std::stringstream sstr(std::stringstream::in | std::stringstream::out); 114 std::stringstream sstr(std::stringstream::in | std::stringstream::out); 99 115 sstr<<content ; 100 116 sstr>>retval ; … … 102 118 << "Cannot convert string <" << content << "> into type required" ); 103 119 return retval ; 104 } 120 } 105 121 122 template<> 123 inline void CVariable::setData(bool data) 124 { 125 if (true == data) content.assign("true"); 126 else content.assign("false"); 127 } 128 129 template <typename T> 130 inline void CVariable::setData(T data) 131 { 132 std::stringstream sstr; 133 sstr<<data; 134 content = sstr.str(); 135 } 106 136 107 137 ///--------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.