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

Fixing bug of referencing to an object.

+) From now on, two objects of a same grid element (domain, axis, scalar) are equal if
they have the same non-empty attributes and the same transformations.
(This is very common case with inheritance by *_ref).

Test
+) On Curie
+) Ok with toy_cmip6

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/scalar.cpp

    r976 r1106  
    6565  } 
    6666 
     67  /*! 
     68    Compare two scalar objects.  
     69    They are equal if only if they have identical attributes as well as their values. 
     70    Moreover, they must have the same transformations. 
     71  \param [in] scalar Compared scalar 
     72  \return result of the comparison 
     73  */ 
     74  bool CScalar::isEqual(CScalar* obj) 
     75  { 
     76    bool objEqual = SuperClass::isEqual(obj); 
     77    if (!objEqual) return objEqual; 
     78 
     79    TransMapTypes thisTrans = this->getAllTransformations(); 
     80    TransMapTypes objTrans  = obj->getAllTransformations(); 
     81 
     82    TransMapTypes::const_iterator it, itb, ite; 
     83    std::vector<ETranformationType> thisTransType, objTransType; 
     84    for (it = thisTrans.begin(); it != thisTrans.end(); ++it) 
     85      thisTransType.push_back(it->first); 
     86    for (it = objTrans.begin(); it != objTrans.end(); ++it) 
     87      objTransType.push_back(it->first); 
     88 
     89    if (thisTransType.size() != objTransType.size()) return false; 
     90    for (int idx = 0; idx < thisTransType.size(); ++idx) 
     91      objEqual &= (thisTransType[idx] == objTransType[idx]); 
     92 
     93    return objEqual; 
     94  } 
     95 
    6796  CTransformation<CScalar>* CScalar::addTransformation(ETranformationType transType, const StdString& id) 
    6897  { 
     
    84113  { 
    85114    return transformationMap_; 
    86   } 
    87  
    88   /*! 
    89     Check the validity of all transformations applied on scalar 
    90   This functions is called AFTER all inherited attributes are solved 
    91   */ 
    92   void CScalar::checkTransformations() 
    93   { 
    94     TransMapTypes::const_iterator itb = transformationMap_.begin(), it, 
    95                                   ite = transformationMap_.end(); 
    96 //    for (it = itb; it != ite; ++it) 
    97 //    { 
    98 //      (it->second)->checkValid(this); 
    99 //    } 
    100115  } 
    101116 
Note: See TracChangeset for help on using the changeset viewer.