Changeset 1105
- Timestamp:
- 04/25/17 10:57:48 (8 years ago)
- Location:
- XIOS/trunk/src
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/array_new.hpp
r1050 r1105 300 300 Array<T_numtype,N_rank>::reference(array); 301 301 initialized = true; 302 } 303 304 bool operator== (const CArray<T_numtype,N_rank>& array) 305 { 306 size_t nbThis = this->numElements(); 307 size_t nbArr = array.numElements(); 308 if (nbThis != nbArr) return false; 309 for (size_t idx = 0; idx < nbThis; ++idx) 310 if ((*this)(idx) != array(idx)) return false; 311 312 return true; 313 } 314 315 bool operator== (const Array<T_numtype,N_rank>& array) 316 { 317 return ((*this) == (dynamic_cast<const CArray<T_numtype,N_rank>& >(array))); 302 318 } 303 319 -
XIOS/trunk/src/attribute.hpp
r778 r1105 16 16 { 17 17 /// ////////////////////// Déclarations ////////////////////// /// 18 /*! 19 \class CAttribute 20 The fundamental class which describes the attributes of other different class in XIOS. 21 This class only plays a role of interface, its class child will have specific implelemtation corresponding to type of attribute 22 */ 18 23 class CAttribute : public CObject, public virtual CBaseType 19 24 { … … 24 29 /// Constructeurs /// 25 30 explicit CAttribute(const StdString & id); 26 // CAttribute(const CAttribute & attribut);27 // CAttribute(const CAttribute * const attribut); // Not implemented.28 31 29 32 /// Accesseurs /// 30 33 const StdString & getName(void) const; 31 // const boost::any & getAnyValue(void) const;32 // template <typename T> inline T getValue(void) const;33 // template <typename T> inline T* getRef(void);34 34 35 // /// Mutateurs ///36 // template <typename T> inline void setValue(const T & value);37 // void setAnyValue(const boost::any & value);38 // void clear(void);39 40 /// Test ///41 // bool isEmpty(void) const;42 // template <typename T> inline bool isType(void) const;43 35 virtual void set(const CAttribute& ) =0 ; 44 36 virtual void reset(void ) =0 ; … … 49 41 virtual StdString toString(void) const = 0; 50 42 virtual void fromString(const StdString & str) = 0; 51 52 // virtual void toBinary (StdOStream & os) const = 0; 53 // virtual void fromBinary(StdIStream & is) = 0; 43 virtual bool isEqual(const CAttribute& ) = 0; 54 44 55 45 //! Returns true if and only if the attribute should be publicly exposed in the API 56 46 virtual bool isPublic() const { return true; } 57 47 48 /* 49 Groupd of functions to generate C and Fortran interface 50 */ 58 51 virtual void generateCInterface(ostream& oss, const string& className) = 0 ; 59 52 virtual void generateCInterfaceIsDefined(ostream& oss, const string& className) ; … … 73 66 virtual bool hasInheritedValue(void) const = 0; 74 67 75 protected : 76 77 /// Constructeurs /// 78 // CAttribute(void); // Not implemented. 79 80 /// Propriété /// 81 // boost::any value; 68 protected : 82 69 83 70 }; // class CAttribute 84 71 85 /// ////////////////////// Définitions ////////////////////// ///86 /*87 template <typename T>88 T CAttribute::getValue(void) const89 {90 return (boost::any_cast<T>(this->value));91 }92 93 template <typename T>94 T* CAttribute::getRef(void)95 {96 return (boost::any_cast<T>(&value));97 }98 99 template <typename T>100 void CAttribute::setValue(const T & value)101 {102 this->value = value;103 }104 105 template<typename T>106 bool CAttribute::isType(void) const107 {108 return (this->value.type() == typeid(T));109 }110 */111 112 72 CMessage& operator<<(CMessage& msg,CAttribute& type) ; 113 73 CMessage& operator<<(CMessage& msg, const CAttribute& type) ; -
XIOS/trunk/src/attribute_array.hpp
r780 r1105 40 40 CArray<T_numtype, N_rank> getInheritedValue(void) const ; 41 41 bool hasInheritedValue(void) const; 42 43 bool isEqual(const CAttributeArray& attr); 44 bool isEqual(const CAttribute& attr); 42 45 43 46 /// Destructeur /// -
XIOS/trunk/src/attribute_array_impl.hpp
r778 r1105 103 103 } 104 104 105 template <typename T_numtype, int N_rank> 106 bool CAttributeArray<T_numtype,N_rank>::isEqual(const CAttributeArray& attr) 107 { 108 return ((dynamic_cast<CArray<T_numtype,N_rank>& >(*this)) == (dynamic_cast<const CArray<T_numtype,N_rank>& >(attr))); 109 } 110 111 template <typename T_numtype, int N_rank> 112 bool CAttributeArray<T_numtype,N_rank>::isEqual(const CAttribute& attr) 113 { 114 return ((*this) == (dynamic_cast<const CAttributeArray<T_numtype,N_rank>& >(attr))); 115 } 105 116 106 117 template <typename T_numtype, int N_rank> -
XIOS/trunk/src/attribute_enum.hpp
r591 r1105 47 47 bool hasInheritedValue(void) const; 48 48 49 bool isEqual(const CAttributeEnum& attr ); 50 bool isEqual(const CAttribute& attr ); 51 49 52 /// Destructeur /// 50 53 virtual ~CAttributeEnum(void) { } -
XIOS/trunk/src/attribute_enum_impl.hpp
r580 r1105 111 111 } 112 112 113 template <class T> 114 bool CAttributeEnum<T>::isEqual(const CAttribute& attr) 115 { 116 return (this->isEqual(dynamic_cast<const CAttributeEnum<T>& >(attr))); 117 } 118 119 template <class T> 120 bool CAttributeEnum<T>::isEqual(const CAttributeEnum& attr) 121 { 122 return ((dynamic_cast<const CEnum<T>& >(*this)) == (dynamic_cast<const CEnum<T>& >(attr))); 123 } 124 113 125 //--------------------------------------------------------------- 114 126 -
XIOS/trunk/src/attribute_map.cpp
r996 r1105 16 16 ///-------------------------------------------------------------- 17 17 18 /*! 19 Clear all attributes of an object and reset them to empty state 20 */ 18 21 void CAttributeMap::clearAllAttributes(void) 19 22 { … … 29 32 //--------------------------------------------------------------- 30 33 34 /* 35 Clear an attribute and reset its value 36 \param[in] key id of attribute 37 */ 31 38 void CAttributeMap::clearAttribute(const StdString& key) 32 39 { … … 36 43 //--------------------------------------------------------------- 37 44 45 /*! 46 Set an attribute of certain id with a value 47 \param[in] key id of the attribute 48 \param[in] attr value of attribute 49 */ 38 50 void CAttributeMap::setAttribute(const StdString& key, CAttribute* const attr) 39 51 { … … 50 62 //--------------------------------------------------------------- 51 63 64 /*! 65 Subscript operator. Return attribute with a specific id 66 */ 52 67 CAttribute* CAttributeMap::operator[](const StdString& key) 53 68 { … … 103 118 } 104 119 } 120 121 /*! 122 Compare two attribute maps 123 \param [in] another attribute map to compare 124 \return true if these two maps have same attributes whose value are identical 125 */ 126 bool CAttributeMap::isEqual(const CAttributeMap& another) 127 { 128 SuperClassMap::const_iterator itb = another.begin(), ite = another.end(), it; 129 for (it = itb; it !=ite; ++it) 130 { 131 if ((*it).first.compare(StdString("id")) != 0 && (*it).first.compare(StdString("src")) != 0) 132 { 133 if (this->hasAttribute(it->first)) 134 { 135 if (!((*it).second->isEqual(*(*this)[it->first]))) 136 return false; 137 } 138 else 139 return false; 140 } 141 } 142 143 return true; 144 } 145 105 146 106 147 //--------------------------------------------------------------- … … 139 180 } 140 181 182 /*! 183 Duplicate attribute map with a specific attribute map. 184 Copy all non-empty attribute of the current attribute map 185 \param [in] srcAttr attribute map which is copied from. 186 */ 141 187 void CAttributeMap::duplicateAttributes(const CAttributeMap* const srcAttr) 142 188 { … … 216 262 } 217 263 */ 264 265 218 266 void CAttributeMap::generateCInterface(ostream& oss, const string& className) 219 267 { -
XIOS/trunk/src/attribute_map.hpp
r996 r1105 12 12 { 13 13 /// ////////////////////// Déclarations ////////////////////// /// 14 /*! 15 \class CAttributeMap 16 This class represents the set of attributes which an object can have. 17 */ 18 14 19 class CAttributeMap 15 20 : public xios_map<StdString, CAttribute*> … … 34 39 35 40 void clearAttribute(const StdString& key); 41 bool isEqual(const CAttributeMap& another); 36 42 37 43 /// Destructeur /// -
XIOS/trunk/src/attribute_template.hpp
r780 r1105 54 54 bool hasInheritedValue(void) const; 55 55 56 bool isEqual(const CAttributeTemplate& attr ); 57 bool isEqual(const CAttribute& attr ); 58 56 59 /// Destructeur /// 57 60 virtual ~CAttributeTemplate(void) { } -
XIOS/trunk/src/attribute_template_impl.hpp
r1028 r1105 139 139 { 140 140 return !this->isEmpty() || !inheritedValue.isEmpty() ; 141 } 142 143 template <class T> 144 bool CAttributeTemplate<T>::isEqual(const CAttribute& attr) 145 { 146 const CAttributeTemplate<T>& tmp = dynamic_cast<const CAttributeTemplate<T>& >(attr); 147 this->isEqual(tmp); 148 149 } 150 151 template <class T> 152 bool CAttributeTemplate<T>::isEqual(const CAttributeTemplate& attr) 153 { 154 if ((!this->hasInheritedValue() && !attr.hasInheritedValue())) 155 return true; 156 if (this->hasInheritedValue() && attr.hasInheritedValue()) 157 return (this->getInheritedValue() == attr.getInheritedValue()); 158 else 159 return false; 141 160 } 142 161 -
XIOS/trunk/src/date.cpp
r647 r1105 62 62 hour = date.hour; minute = date.minute; second = date.second; 63 63 return (*this); 64 } 65 66 bool CDate::operator==(const CDate& date) 67 { 68 return (&(*relCalendar) == &(*date.relCalendar) && 69 year == date.year && month == date.month && day == date.day && 70 hour == date.hour && minute == date.minute && second == date.second); 71 64 72 } 65 73 -
XIOS/trunk/src/date.hpp
r591 r1105 32 32 /// Opérateurs /// 33 33 CDate& operator=(const CDate& date); 34 bool operator==(const CDate& date); 34 35 friend StdOStream& operator<<(StdOStream& out, const CDate& date); 35 36 friend StdIStream& operator>>(StdIStream& in, CDate& date); -
XIOS/trunk/src/duration.cpp
r1049 r1105 24 24 hour = duration.hour; minute = duration.minute; second = duration.second; timestep = duration.timestep; 25 25 return *this; 26 } 27 28 /*! 29 This operation may not serve much, it's here because of the need of operator== from generic class CType<T> 30 */ 31 bool CDuration::operator==(const CDuration& duration) 32 { 33 return (year == duration.year && month == duration.month && day == duration.day && 34 hour == duration.hour && minute == duration.minute && second == duration.second && timestep == duration.timestep); 26 35 } 27 36 -
XIOS/trunk/src/duration.hpp
r1028 r1105 22 22 /// Opérateurs /// 23 23 CDuration& operator=(const CDuration& duration); 24 bool operator==(const CDuration& duration); 24 25 25 26 friend StdOStream& operator<<(StdOStream& out, const CDuration& duration); -
XIOS/trunk/src/object_template.hpp
r731 r1105 61 61 static bool dispatchEvent(CEventServer& event) ; 62 62 63 bool isEqual(const string& id); 64 bool isEqual(T* obj); 65 63 66 /// Accesseur statique /// 64 67 static std::vector<boost::shared_ptr<DerivedType> > & -
XIOS/trunk/src/object_template_impl.hpp
r769 r1105 136 136 } 137 137 138 /*! 139 Compare two object of same type 140 */ 141 template <class T> 142 bool CObjectTemplate<T>::isEqual(const string& id) 143 { 144 T* obj = CObjectTemplate<T>::get(id); 145 return this->isEqual(obj); 146 } 147 148 template <class T> 149 bool CObjectTemplate<T>::isEqual(T* obj) 150 { 151 152 CAttributeMap& attrMapThis = *this; 153 CAttributeMap& attrMapObj = *obj; 154 return (attrMapThis.isEqual(attrMapObj)); 155 } 156 138 157 //--------------------------------------------------------------- 139 158 -
XIOS/trunk/src/type/enum.hpp
r591 r1105 100 100 __INLINE__ const CEnum_ref& operator = (const CEnum_ref& val) const; 101 101 __INLINE__ operator T_enum&() const; 102 bool operator == (const CEnum_ref &other) {return this->get()==other.get() ;}102 103 103 104 104 inline virtual CBaseType* clone(void) const { return _clone(); } … … 134 134 } ; 135 135 136 template <typename T> __INLINE__ bool operator== (const CEnum<T>& lhs, const typename T::t_enum& rhs); 137 template <typename T> __INLINE__ bool operator== (const typename T::t_enum& lhs, const CEnum<T>& rhs); 138 template <typename T> __INLINE__ bool operator== (const CEnum<T>& lhs, const CEnum<T>& rhs); 139 template <typename T> __INLINE__ bool operator== (const CEnum_ref<T>& lhs, const CEnum_ref<T>& rhs); 140 template <typename T> __INLINE__ bool operator== (const CEnum_ref<T>& lhs, const typename T::t_enum& rhs); 141 template <typename T> __INLINE__ bool operator== (const typename T::t_enum& lhs, const CEnum_ref<T>& rhs); 142 template <typename T> __INLINE__ bool operator== (const CEnum<T>& lhs, const CEnum_ref<T>& rhs) {return (lhs.get() == rhs.get());} 143 template <typename T> __INLINE__ bool operator== (const CEnum_ref<T>& lhs, const CEnum<T>& rhs) {return (rhs == lhs); } 144 136 145 template <typename T> __INLINE__ CBufferOut& operator<<(CBufferOut& buffer, const CEnum<T>& type) ; 137 146 template <typename T> __INLINE__ CBufferOut& operator<<(CBufferOut& buffer, const typename T::t_enum & type) ; -
XIOS/trunk/src/type/enum_impl.hpp
r680 r1105 249 249 << "Enum is not initialized."); 250 250 } 251 252 251 252 template <typename T> 253 bool operator== (const CEnum<T>& lhs, const typename T::t_enum& rhs) 254 { 255 if (lhs.isEmpty()) return false; 256 return (lhs.get() == rhs); 257 } 258 259 template <typename T> 260 bool operator== (const typename T::t_enum& lhs, const CEnum<T>& rhs) 261 { 262 return rhs == lhs; 263 } 264 265 template <typename T> 266 bool operator== (const CEnum<T>& lhs, const CEnum<T>& rhs) 267 { 268 if ((lhs.isEmpty() && !rhs.isEmpty()) || (!lhs.isEmpty() && rhs.isEmpty())) return false; 269 if (lhs.isEmpty() && rhs.isEmpty()) return true; 270 return (lhs.get() == rhs.get()); 271 } 272 273 253 274 template <typename T> 254 275 CBufferOut& operator<<(CBufferOut& buffer, const CEnum<T>& type) -
XIOS/trunk/src/type/enum_ref_impl.hpp
r680 r1105 263 263 } 264 264 265 265 template <typename T> 266 bool operator== (const CEnum_ref<T>& lhs, const typename T::t_enum& rhs) 267 { 268 if (lhs.isEmpty()) return false; 269 return (lhs.get() == rhs); 270 } 271 272 template <typename T> 273 bool operator== (const typename T::t_enum& lhs, const CEnum_ref<T>& rhs) 274 { 275 return rhs == lhs; 276 } 277 278 template <typename T> 279 bool operator== (const CEnum_ref<T>& lhs, const CEnum_ref<T>& rhs) 280 { 281 if ((lhs.isEmpty() && !rhs.isEmpty()) || (!lhs.isEmpty() && rhs.isEmpty())) return false; 282 if (lhs.isEmpty() && rhs.isEmpty()) return true; 283 return (lhs.get() == rhs.get()); 284 } 266 285 267 286 template <typename T> -
XIOS/trunk/src/type/type.hpp
r748 r1105 94 94 const CType_ref& operator = (CType<T>& val) const ; 95 95 const CType_ref& operator = (const CType_ref& val) const; 96 operator T&() const; 96 operator T&() const; 97 97 98 98 inline virtual CBaseType* clone(void) const { return _clone(); } … … 127 127 size_t _size(void) const ; 128 128 } ; 129 130 template <typename T> inline bool operator==(const CType<T>& lhs, const T& rhs); 131 template <typename T> inline bool operator==(const T& lhs, const CType<T>& rhs); 132 template <typename T> inline bool operator==(const CType_ref<T>& lhs, const T& rhs); 133 template <typename T> inline bool operator==(const T& lhs, const CType_ref<T>& rhs); 134 template <typename T> inline bool operator==(const CType_ref<T>& lhs, const CType_ref<T>& rhs); 135 136 template <typename T> 137 inline bool operator==(const CType_ref<T>& lhs, const CType<T>& rhs) 138 { 139 if ((lhs.isEmpty() && !rhs.isEmpty()) || (!lhs.isEmpty() && rhs.isEmpty())) return false; 140 if (lhs.isEmpty() && rhs.isEmpty()) return true; 141 return (*lhs.ptrValue == *rhs.ptrValue); 142 } 143 144 template <typename T> 145 inline bool operator==(const CType<T>& lhs, const CType_ref<T>& rhs) 146 { 147 return (rhs == lhs); 148 } 129 149 130 150 -
XIOS/trunk/src/type/type_decl.cpp
r591 r1105 22 22 /* template CMessage& operator<< <decl_type> (CMessage& msg, const CType_ref<decl_type>& type) ;*/ \ 23 23 template CMessage& operator<< <decl_type> (CMessage& msg, const decl_type& type) ; \ 24 template CMessage& operator<< <decl_type> (CMessage& msg, decl_type& type) ; 24 template CMessage& operator<< <decl_type> (CMessage& msg, decl_type& type) ; \ 25 template bool operator==(const CType<decl_type>& lhs, const decl_type& rhs); \ 26 template bool operator==(const decl_type& lhs, const CType<decl_type>& rhs); \ 27 template bool operator==(const CType_ref<decl_type>& lhs, const decl_type& rhs); \ 28 template bool operator==(const decl_type& lhs, const CType_ref<decl_type>& rhs); \ 29 template bool operator==(const CType_ref<decl_type>& lhs, const CType<decl_type>& rhs); \ 30 template bool operator==(const CType<decl_type>& lhs, const CType_ref<decl_type>& rhs); \ 31 template bool operator==(const CType_ref<decl_type>& lhs, const CType_ref<decl_type>& rhs); 25 32 26 33 macro(string) -
XIOS/trunk/src/type/type_impl.hpp
r748 r1105 211 211 } 212 212 213 template <typename T> 214 bool operator==(const CType<T>& lhs, const T& rhs) 215 { 216 if (lhs.isEmpty()) return false; 217 return (*lhs.ptrValue == rhs); 218 } 219 220 template <typename T> 221 bool operator==(const T& lhs, const CType<T>& rhs) 222 { 223 return (rhs == lhs); 224 } 225 226 template <typename T> 227 bool operator==(const CType<T>& lhs, const CType<T>& rhs) 228 { 229 if ((lhs.isEmpty() && !rhs.isEmpty()) || (!lhs.isEmpty() && rhs.isEmpty())) return false; 230 if (lhs.isEmpty() && rhs.isEmpty()) return true; 231 232 return (*lhs.ptrValue == *rhs.ptrValue); 233 } 213 234 214 235 template <typename T> -
XIOS/trunk/src/type/type_ref_impl.hpp
r680 r1105 201 201 } 202 202 203 203 template <typename T> 204 bool operator==(const CType_ref<T>& lhs, const T& rhs) 205 { 206 if (lhs.isEmpty()) return false; 207 return (*lhs.ptrValue == rhs); 208 } 209 210 template <typename T> 211 bool operator==(const T& lhs, const CType_ref<T>& rhs) 212 { 213 return (rhs == lhs); 214 } 215 216 template <typename T> 217 bool operator==(const CType_ref<T>& lhs, const CType_ref<T>& rhs) 218 { 219 if ((lhs.isEmpty() && !rhs.isEmpty()) || (!lhs.isEmpty() && rhs.isEmpty())) return false; 220 if (lhs.isEmpty() && rhs.isEmpty()) return true; 221 222 return (*lhs.ptrValue == *rhs.ptrValue); 223 } 204 224 205 225 template <typename T>
Note: See TracChangeset
for help on using the changeset viewer.