Changeset 1105 for XIOS/trunk/src/type


Ignore:
Timestamp:
04/25/17 10:57:48 (7 years ago)
Author:
mhnguyen
Message:

Adding comparison operator between objects of XIOS.
Two objects of a same type are considered equal if they have same non-empty
attributes which have same values

+) Add operator== to class CArray
+) Add comparison operator to some basic attribute classes
+) Add operator== to date and duration (It seems that they don't serve much)

Test
+) On Curie
+) No Unit tests but test with transformation work (the next commit)

Location:
XIOS/trunk/src/type
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/type/enum.hpp

    r591 r1105  
    100100    __INLINE__ const CEnum_ref& operator = (const CEnum_ref& val) const; 
    101101    __INLINE__ operator T_enum&() const; 
    102     bool operator == (const CEnum_ref &other) {return this->get()==other.get() ;} 
     102     
    103103 
    104104    inline virtual CBaseType* clone(void) const   { return _clone(); } 
     
    134134  } ; 
    135135   
     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 
    136145  template <typename T> __INLINE__ CBufferOut& operator<<(CBufferOut& buffer, const CEnum<T>& type) ; 
    137146  template <typename T> __INLINE__ CBufferOut& operator<<(CBufferOut& buffer, const typename T::t_enum & type) ;   
  • XIOS/trunk/src/type/enum_impl.hpp

    r680 r1105  
    249249                     << "Enum is not initialized."); 
    250250  }   
    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 
    253274  template <typename T> 
    254275  CBufferOut& operator<<(CBufferOut& buffer, const CEnum<T>& type) 
  • XIOS/trunk/src/type/enum_ref_impl.hpp

    r680 r1105  
    263263  } 
    264264                      
    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  } 
    266285   
    267286  template <typename T> 
  • XIOS/trunk/src/type/type.hpp

    r748 r1105  
    9494    const CType_ref& operator = (CType<T>& val) const ; 
    9595    const CType_ref& operator = (const CType_ref& val) const; 
    96     operator T&() const; 
     96    operator T&() const;     
    9797 
    9898    inline virtual CBaseType* clone(void) const   { return _clone(); } 
     
    127127    size_t _size(void) const ; 
    128128  } ; 
     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  } 
    129149 
    130150 
  • XIOS/trunk/src/type/type_decl.cpp

    r591 r1105  
    2222/*  template CMessage& operator<< <decl_type> (CMessage& msg, const CType_ref<decl_type>& type) ;*/ \ 
    2323  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);     
    2532   
    2633  macro(string) 
  • XIOS/trunk/src/type/type_impl.hpp

    r748 r1105  
    211211  } 
    212212 
     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  } 
    213234 
    214235  template <typename T> 
  • XIOS/trunk/src/type/type_ref_impl.hpp

    r680 r1105  
    201201  } 
    202202                      
    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  } 
    204224   
    205225  template <typename T> 
Note: See TracChangeset for help on using the changeset viewer.