Changeset 1478 for XIOS/trunk


Ignore:
Timestamp:
04/12/18 18:51:08 (6 years ago)
Author:
oabramkina
Message:

Exception handling for attributes by means of dynamic binding. This assures that attribute's id will always be printed in the error message.

Replacing changes done in r1477.

Location:
XIOS/trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/attribute_template.hpp

    r1117 r1478  
    5252            void set(const CAttributeTemplate& attr) ; 
    5353            void reset(void) ; 
     54            void checkEmpty(void) const; 
     55 
    5456 
    5557            void setInheritedValue(const CAttributeTemplate& attr ); 
     
    5759            T getInheritedValue(void) const ; 
    5860            bool hasInheritedValue(void) const; 
    59  
    60             bool isEqual_(const CAttributeTemplate& attr ); 
     61             
    6162            bool isEqual(const CAttribute& attr ); 
    6263 
     
    9596//            CAttributeTemplate(void); // Not implemented. 
    9697         private : 
     98          bool isEqual_(const CAttributeTemplate& attr); 
    9799          StdString _toString(void) const; 
    98100          void _fromString(const StdString & str); 
  • XIOS/trunk/src/attribute_template_impl.hpp

    r1477 r1478  
    6767      } 
    6868 
    69  
    70       template <class T> 
    71          T CAttributeTemplate<T>::getValue(void) const 
    72       { 
    73         try { 
    74           return CType<T>::get() ; 
    75         } 
    76         catch (xios::CException & exc) 
     69      template <class T> 
     70      void CAttributeTemplate<T>::checkEmpty(void) const 
     71      { 
     72        if (CType<T>::empty) 
    7773        { 
    7874          StdString msg("On checking attribute with id="); 
     
    8278          ERROR("template <typename T> void CType<T>::checkEmpty(void) const", << msg); 
    8379        } 
     80      } 
     81 
     82 
     83      template <class T> 
     84         T CAttributeTemplate<T>::getValue(void) const 
     85      { 
     86        return CType<T>::get() ; 
    8487 
    8588/* 
  • XIOS/trunk/src/type/type.hpp

    r1107 r1478  
    4747 
    4848    void allocate(void) ; 
    49     void checkEmpty(void) const; 
     49    virtual void checkEmpty(void) const {return _checkEmpty();}; 
    5050 
    5151    T* ptrValue ; 
     
    6363    void _reset(void) ; 
    6464    bool _isEmpty() const ; 
     65    void _checkEmpty(void) const; 
    6566    size_t _size(void) const ; 
    6667 
  • XIOS/trunk/src/type/type_impl.hpp

    r1477 r1478  
    8787  T& CType<T>::get(void) 
    8888  { 
    89     checkEmpty(); 
     89    this->checkEmpty(); 
    9090   return *ptrValue ; 
    9191  } 
     
    9494  const T& CType<T>::get(void) const 
    9595  { 
    96     checkEmpty(); 
     96    this->checkEmpty(); 
    9797    return *ptrValue ; 
    9898  } 
     
    122122   CType<T>::operator T&() 
    123123   { 
    124      try 
    125      { 
    126        checkEmpty(); 
    127      } 
    128      catch (xios::CException & exc) 
    129      { 
    130        StdString msg("Data is not initialized\n"); 
    131        ERROR("template <typename T> void CType<T>::checkEmpty(void) const", << msg); 
    132      } 
    133  
    134     return *ptrValue ; 
     124     this->checkEmpty(); 
     125     return *ptrValue ; 
    135126   } 
    136127 
     
    138129   CType<T>::operator const T&() const 
    139130   { 
    140     checkEmpty(); 
     131    this->checkEmpty(); 
    141132    return *ptrValue ; 
    142133   } 
     
    145136   CType<T>* CType<T>::_clone(void) const 
    146137   { 
    147      checkEmpty(); 
     138     this->checkEmpty(); 
    148139     return new CType(*this) ; 
    149140   } 
     
    174165  { 
    175166    ostringstream oss; 
    176     checkEmpty(); 
     167    this->checkEmpty(); 
    177168    oss<<*ptrValue ; 
    178169    return oss.str() ; 
     
    182173  bool CType<T>::_toBuffer(CBufferOut& buffer) const 
    183174  { 
    184     checkEmpty(); 
     175    this->checkEmpty(); 
    185176    return buffer.put(*ptrValue) ; 
    186177  } 
     
    215206 
    216207  template <typename T> 
    217   void CType<T>::checkEmpty(void) const 
    218   { 
    219 //    if (empty) ERROR("template <typename T> void CType<T>::checkEmpty(void) const", << "Data is not initialized") ; 
    220     if (empty) throw CException(); 
     208  void CType<T>::_checkEmpty(void) const 
     209  { 
     210    if (empty) ERROR("template <typename T> void CType<T>::checkEmpty(void) const", << "Data is not initialized") ; 
    221211  } 
    222212 
Note: See TracChangeset for help on using the changeset viewer.