Changeset 1117


Ignore:
Timestamp:
05/04/17 15:14:37 (7 years ago)
Author:
mhnguyen
Message:

Fixing bug of using *_ref on chaining transformations.

+) Correct isEqual function of attribute_template
+) Modify isEqual function of CAttributeMap to make sure that some attributes are
excluded from comparasion

Test
+) On Curie
+) toy_cmpi6 works.

Location:
XIOS/trunk/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/attribute_map.cpp

    r1112 r1117  
    122122         Compare two attribute maps 
    123123         \param [in] another attribute map to compare 
     124         \param [in] excludedAttrs attribute to be excluded from comparasion 
    124125         \return true if these two maps have same attributes whose value are identical 
    125126      */ 
    126       bool CAttributeMap::isEqual(const CAttributeMap& another) 
     127      bool CAttributeMap::isEqual(const CAttributeMap& another, const vector<StdString>& excludedAttrs) 
    127128      { 
    128129         SuperClassMap::const_iterator itb = another.begin(), ite = another.end(), it; 
    129130         for (it = itb; it !=ite; ++it) 
    130131         { 
    131             if ((*it).first.compare(StdString("id")) != 0 && (*it).first.compare(StdString("src")) != 0) 
     132            bool excluded = false; 
     133            for (int idx = 0; idx < excludedAttrs.size(); ++idx) 
    132134            { 
    133               if (this->hasAttribute(it->first)) 
    134               {  
    135                 if (!((*it).second->isEqual(*(*this)[it->first]))) 
    136                 return false; 
     135               if (0 == (*it).first.compare(excludedAttrs[idx])) 
     136               { 
     137                 excluded = true; 
     138                 break; 
     139               }  
     140            } 
     141 
     142            if (!excluded) 
     143            { 
     144              if ((*it).first.compare(StdString("id")) != 0 && (*it).first.compare(StdString("src")) != 0) 
     145              { 
     146                if (this->hasAttribute(it->first)) 
     147                {  
     148                  if (!((*it).second->isEqual(*(*this)[it->first]))) 
     149                  { 
     150                    return false; 
     151                  } 
     152                } 
     153                else 
     154                  return false; 
    137155              } 
    138               else 
    139                 return false; 
    140156            } 
    141157         } 
  • XIOS/trunk/src/attribute_map.hpp

    r1105 r1117  
    1515        \class CAttributeMap 
    1616        This class represents the set of attributes which an object can have. 
     17        Each attribute in the set is represented by an unique id. 
    1718      */ 
    1819 
     
    3940 
    4041            void clearAttribute(const StdString& key); 
    41             bool isEqual(const CAttributeMap& another); 
     42            bool isEqual(const CAttributeMap& another, const vector<StdString>& excludedAttrs); 
    4243 
    4344            /// Destructeur /// 
  • XIOS/trunk/src/attribute_template.hpp

    r1112 r1117  
    1616{ 
    1717      /// ////////////////////// Déclarations ////////////////////// /// 
     18  /*! 
     19    \class CAttributeTemplate 
     20    The class implements attribute of some basic types 
     21  */ 
    1822      template <class T> 
    1923         class CAttributeTemplate : public CAttribute, public CType<T> 
     
    5458            bool hasInheritedValue(void) const; 
    5559 
    56             bool isEqual(const CAttributeTemplate& attr ); 
     60            bool isEqual_(const CAttributeTemplate& attr ); 
    5761            bool isEqual(const CAttribute& attr ); 
    58              
     62 
    5963            /// Destructeur /// 
    6064            virtual ~CAttributeTemplate(void) { } 
  • XIOS/trunk/src/attribute_template_impl.hpp

    r1112 r1117  
    145145    { 
    146146      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) 
     147      return this->isEqual_(tmp); 
     148    } 
     149 
     150    template <class T> 
     151    bool CAttributeTemplate<T>::isEqual_(const CAttributeTemplate& attr) 
    153152    { 
    154153      if ((!this->hasInheritedValue() && !attr.hasInheritedValue())) 
  • XIOS/trunk/src/node/axis.cpp

    r1106 r1117  
    986986  bool CAxis::isEqual(CAxis* obj) 
    987987  { 
    988     bool objEqual = SuperClass::isEqual(obj); 
     988    vector<StdString> excludedAttr; 
     989    excludedAttr.push_back("axis_ref"); 
     990 
     991    bool objEqual = SuperClass::isEqual(obj, excludedAttr);     
    989992    if (!objEqual) return objEqual; 
    990993 
  • XIOS/trunk/src/node/domain.cpp

    r1106 r1117  
    22472247  bool CDomain::isEqual(CDomain* obj) 
    22482248  { 
    2249     bool objEqual = SuperClass::isEqual(obj); 
     2249    vector<StdString> excludedAttr; 
     2250    excludedAttr.push_back("domain_ref"); 
     2251    bool objEqual = SuperClass::isEqual(obj, excludedAttr); 
    22502252    if (!objEqual) return objEqual; 
    22512253 
  • XIOS/trunk/src/node/scalar.cpp

    r1106 r1117  
    7474  bool CScalar::isEqual(CScalar* obj) 
    7575  { 
    76     bool objEqual = SuperClass::isEqual(obj); 
     76    vector<StdString> excludedAttr; 
     77    excludedAttr.push_back("scalar_ref"); 
     78    bool objEqual = SuperClass::isEqual(obj, excludedAttr); 
    7779    if (!objEqual) return objEqual; 
    7880 
  • XIOS/trunk/src/object_template.hpp

    r1105 r1117  
    6161         static bool dispatchEvent(CEventServer& event) ; 
    6262 
    63          bool isEqual(const string& id); 
    64          bool isEqual(T* obj); 
     63         bool isEqual(const string& id, const vector<StdString>& excludedAttrs); 
     64         bool isEqual(T* obj, const vector<StdString>& excludedAttrs); 
    6565 
    6666         /// Accesseur statique /// 
  • XIOS/trunk/src/object_template_impl.hpp

    r1105 r1117  
    140140   */ 
    141141   template <class T> 
    142    bool CObjectTemplate<T>::isEqual(const string& id) 
     142   bool CObjectTemplate<T>::isEqual(const string& id, const vector<StdString>& excludedAttrs) 
    143143   { 
    144144      T* obj = CObjectTemplate<T>::get(id); 
    145       return this->isEqual(obj); 
    146    } 
    147  
    148    template <class T> 
    149    bool CObjectTemplate<T>::isEqual(T* obj) 
     145      return this->isEqual(obj, excludedAttrs); 
     146   } 
     147 
     148   template <class T> 
     149   bool CObjectTemplate<T>::isEqual(T* obj, const vector<StdString>& excludedAttrs) 
    150150   { 
    151151 
    152152      CAttributeMap& attrMapThis = *this; 
    153153      CAttributeMap& attrMapObj  = *obj; 
    154       return (attrMapThis.isEqual(attrMapObj)); 
     154      return (attrMapThis.isEqual(attrMapObj, excludedAttrs)); 
    155155   } 
    156156 
Note: See TracChangeset for help on using the changeset viewer.