Ignore:
Timestamp:
02/13/12 19:35:25 (12 years ago)
Author:
ymipsl
Message:

nouvelle version de developpement de xios

  • nouvelle interface fortran
  • recodage complet de la couche de communication
  • et bien d'autres choses...

YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XMLIO_V2/dev/common/src/attribute_template_impl.hpp

    r274 r300  
    33 
    44#include "array.hpp" 
     5#include "type.hpp" 
     6#include "buffer_in.hpp" 
     7#include "buffer_out.hpp" 
    58 
    69namespace xmlioserver 
     
    6972 
    7073      template <class T> 
     74         T* CAttributeTemplate<T>::getRef(void) 
     75      { 
     76         if (SuperClass::isEmpty()) 
     77         { 
     78            ERROR("T CAttributeTemplate<T>::getValue(void) const", 
     79                  << "[ id = " << this->getId() << "]" 
     80                  << " L'attribut est requis mais n'est pas défini !"); 
     81          } 
     82         return (SuperClass::getRef<T>()); 
     83      } 
     84 
     85      template <class T> 
    7186         void CAttributeTemplate<T>::setValue(const T & value) 
    7287      { 
     
    115130         FromBinary(is, value); 
    116131         this->setValue(value); 
     132      } 
     133 
     134      template <class T> 
     135         bool CAttributeTemplate<T>::toBuffer (CBufferOut& buffer) const 
     136      { 
     137         if (isEmpty()) return buffer.put(true) ; 
     138         else 
     139         { 
     140           bool ret=true ; 
     141           CType<T> val(*boost::any_cast<T>(&value)) ; 
     142           ret&=buffer.put(false) ; 
     143           ret&=val.toBuffer(buffer) ; 
     144           return ret ; 
     145         } 
     146      } 
     147 
     148      template <class T> 
     149      bool CAttributeTemplate<T>::fromBuffer(CBufferIn& buffer) 
     150      { 
     151        bool empty ; 
     152        bool ret=true ; 
     153        ret&=buffer.get(empty) ; 
     154        if (empty)  
     155        { 
     156          clear() ; 
     157          return ret ; 
     158        } 
     159        else 
     160        { 
     161          if (isEmpty()) 
     162          { 
     163            T val ; 
     164            setValue(val) ; 
     165          } 
     166          T* V=const_cast<T*>(boost::any_cast<T>(&value)) ; 
     167          CType<T> val(*V) ; 
     168          return val.fromBuffer(buffer) ; 
     169        } 
     170      } 
     171 
     172      template <class T> 
     173      size_t CAttributeTemplate<T>::size(void) const 
     174      { 
     175        if (isEmpty()) return sizeof(bool) ; 
     176        else 
     177        { 
     178          CType<T> val(*const_cast<T*>(boost::any_cast<T>(&value))) ; 
     179          return val.size()+sizeof(bool) ; 
     180        } 
    117181      } 
    118182 
Note: See TracChangeset for help on using the changeset viewer.