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)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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) 
Note: See TracChangeset for help on using the changeset viewer.