Ignore:
Timestamp:
06/06/17 17:58:16 (7 years ago)
Author:
oabramkina
Message:

Two server levels: merging with trunk r1137.
There are bugs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_olga/src/array_new.hpp

    r731 r1158  
    302302      } 
    303303 
     304      bool operator== (const CArray<T_numtype,N_rank>& array) 
     305      { 
     306        size_t nbThis = this->numElements(); 
     307        size_t nbArr  = array.numElements(); 
     308        if (nbThis != nbArr) return false; 
     309        typename Array<T_numtype,N_rank>::const_iterator itx=array.begin(), itxe=array.end(), ity=this->begin() ; 
     310        for(;itx!=itxe;++itx,++ity) if (*itx!=*ity) return false ; 
     311        return true; 
     312      } 
     313 
     314      bool operator== (const Array<T_numtype,N_rank>& array) 
     315      { 
     316        return ((*this) == (dynamic_cast<const CArray<T_numtype,N_rank>& >(array))); 
     317      } 
     318 
    304319      void resize(int extent) 
    305320      { 
     
    552567  }; 
    553568 
     569 
     570#define macro(NRANK)\ 
     571\ 
     572  template <>\ 
     573  inline size_t CArray<StdString,NRANK>::size(void) const\ 
     574  {\ 
     575    size_t size=(1 + NRANK) * sizeof(int) ;\ 
     576    Array<StdString,NRANK>::const_iterator it, itb=this->begin(), ite=this->end() ;\ 
     577\ 
     578    for(it=itb;it!=ite;++it)\ 
     579    {\ 
     580      size+= sizeof(size_t) ;\ 
     581      size+= (*it).size();\ 
     582    } \ 
     583    return size ;\ 
     584  }\ 
     585\ 
     586/* for array string this function is an evaluation of maximum size of the array, considering stringArrayLen is the maximum size of the strings*/ \ 
     587  template <>\ 
     588  inline size_t CArray<StdString,NRANK>::size(sizeType numElements)\ 
     589  {\ 
     590    return (NRANK + 1) * sizeof(int) + numElements * stringArrayLen;\ 
     591  }\ 
     592  \ 
     593  template <>\ 
     594  inline bool CArray<StdString,NRANK>::toBuffer(CBufferOut& buffer) const\ 
     595  {\ 
     596    bool ret;\ 
     597    ret =  buffer.put(this->dimensions());\ 
     598    ret &= buffer.put(this->shape().data(), this->dimensions());\ 
     599\ 
     600    Array<StdString,NRANK>::const_iterator it, itb=this->begin(), ite=this->end() ;\ 
     601\ 
     602    for(it=itb;it!=ite;++it)\ 
     603    {\ 
     604      ret &= buffer.put((*it).size()) ;\ 
     605      ret &= buffer.put((*it).data(),(*it).size());\ 
     606    } \ 
     607    return ret;\ 
     608  }\ 
     609\ 
     610  template <>\ 
     611  inline bool CArray<StdString,NRANK>::fromBuffer(CBufferIn& buffer)\ 
     612  {\ 
     613     bool ret;\ 
     614     int numDim;\ 
     615     TinyVector<int,NRANK> vect;\ 
     616     size_t ne;\ 
     617\ 
     618     ret =  buffer.get(numDim);\ 
     619     ret &= buffer.get(vect.data(), NRANK);\ 
     620     this->resize(vect);\ 
     621\ 
     622     Array<StdString,NRANK>::iterator it, itb=this->begin(), ite=this->end() ;\ 
     623     for(it=itb;it!=ite;++it)\ 
     624     {\ 
     625       ret &= buffer.get(ne) ;\ 
     626       char* str = new char[ne] ;\ 
     627       ret &= buffer.get(str, ne);\ 
     628       *it = string(str,ne) ;\ 
     629       delete [] str ;\ 
     630     }\ 
     631     initialized = true;\ 
     632     return ret;\ 
     633  } 
     634macro(1) 
     635macro(2) 
     636macro(3) 
     637macro(4) 
     638macro(5) 
     639macro(6) 
     640macro(7) 
     641 
     642#undef macro 
     643 
    554644  template <typename T_numtype,int N_rank> inline CBufferOut& operator<<(CBufferOut& buffer, const CArray<T_numtype,N_rank>& array) 
    555645  { 
Note: See TracChangeset for help on using the changeset viewer.