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/attribute_map.cpp

    r996 r1105  
    1616      ///-------------------------------------------------------------- 
    1717 
     18      /*! 
     19         Clear all attributes of an object and reset them to empty state 
     20      */ 
    1821      void CAttributeMap::clearAllAttributes(void) 
    1922      { 
     
    2932      //--------------------------------------------------------------- 
    3033 
     34      /* 
     35        Clear an attribute and reset its value 
     36        \param[in] key id of attribute 
     37      */ 
    3138      void CAttributeMap::clearAttribute(const StdString& key) 
    3239      { 
     
    3643      //--------------------------------------------------------------- 
    3744 
     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      */ 
    3850      void CAttributeMap::setAttribute(const StdString& key, CAttribute* const attr) 
    3951      { 
     
    5062      //--------------------------------------------------------------- 
    5163 
     64      /*! 
     65        Subscript operator. Return attribute with a specific id 
     66      */ 
    5267      CAttribute* CAttributeMap::operator[](const StdString& key) 
    5368      { 
     
    103118         } 
    104119      } 
     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 
    105146 
    106147      //--------------------------------------------------------------- 
     
    139180      } 
    140181 
     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      */ 
    141187      void CAttributeMap::duplicateAttributes(const CAttributeMap* const srcAttr) 
    142188      { 
     
    216262      } 
    217263 */ 
     264 
     265       
    218266      void CAttributeMap::generateCInterface(ostream& oss, const string& className) 
    219267      { 
Note: See TracChangeset for help on using the changeset viewer.