source: XIOS/dev/dev_ym/XIOS_COUPLING/src/attribute_array_impl.hpp @ 1878

Last change on this file since 1878 was 1875, checked in by ymipsl, 4 years ago

XIOS coupling branch
Some updates.

First coupling test is beginning to work...

YM

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
File size: 8.0 KB
RevLine 
[369]1#ifndef __XIOS_ATTRIBUTE_ARRAY_IMPL_HPP__
2#define __XIOS_ATTRIBUTE_ARRAY_IMPL_HPP__
3
4#include "buffer_in.hpp"
5#include "buffer_out.hpp"
6#include "generate_interface.hpp"
7#include "attribute_array.hpp"
8
[775]9
[369]10namespace xios
11{
12      /// ////////////////////// Définitions ////////////////////// ///
13      template <typename T_numtype, int N_rank>
14      CAttributeArray<T_numtype, N_rank>::CAttributeArray(const StdString & id)
15         : CAttribute(id)
[1875]16      { bool alwaysFalse ; alwaysFalse=false ; if (alwaysFalse) TV_ttf_display_type(this); }
[369]17
18      template <typename T_numtype, int N_rank>
19      CAttributeArray<T_numtype,N_rank>::CAttributeArray(const StdString & id, const CArray<T_numtype,N_rank>& value)
20         : CAttribute(id)
21      {
[1875]22         bool alwaysFalse ; alwaysFalse=false ; if (alwaysFalse) TV_ttf_display_type(this);
[369]23         this->setValue(value);
24      }
25
26      template <typename T_numtype, int N_rank>
27      CAttributeArray<T_numtype, N_rank>::CAttributeArray(const StdString & id, xios_map<StdString, CAttribute*> & umap)
28         : CAttribute(id)
29      {
[1875]30         bool alwaysFalse ; alwaysFalse=false ; if (alwaysFalse) TV_ttf_display_type(this);
[369]31         umap.insert(umap.end(), std::make_pair(id, this));
32      }
33
34      template <typename T_numtype, int N_rank>
35      CAttributeArray<T_numtype, N_rank>::CAttributeArray (const StdString & id, const CArray<T_numtype,N_rank>& value,
36                                                           xios_map<StdString, CAttribute*> & umap)
37         : CAttribute(id)
38      {
[1875]39         bool alwaysFalse ; alwaysFalse=false ; if (alwaysFalse) TV_ttf_display_type(this);
[369]40         this->setValue(value);
41         umap.insert(umap.end(), std::make_pair(id, this));
42      }
43
44      ///--------------------------------------------------------------
45
46      template <typename T_numtype, int N_rank>
[460]47      void CAttributeArray<T_numtype, N_rank>::reset(void)
48      {
49        CArray<T_numtype, N_rank>::reset() ;
50        inheritedValue.reset() ;
51      }
[775]52
[460]53      template <typename T_numtype, int N_rank>
[369]54      CArray<T_numtype,N_rank> CAttributeArray<T_numtype, N_rank>::getValue(void) const
55      {
56        return this->copy() ;
57      }
58
59      template <typename T_numtype, int N_rank>
60      void CAttributeArray<T_numtype,N_rank>::setValue(const CArray<T_numtype,N_rank>& value)
61      {
62        this->resize(value.shape()) ;
63        *this=value ;
64      }
65
66    template <typename T_numtype, int N_rank>
67    void CAttributeArray<T_numtype,N_rank>::set(const CAttribute& attr)
68    {
69      this->set(dynamic_cast<const CAttributeArray<T_numtype,N_rank>& >(attr)) ;
[775]70    }
[369]71
72    template <typename T_numtype, int N_rank>
73    void CAttributeArray<T_numtype,N_rank>::set(const CAttributeArray& attr)
74    {
75      this->setValue(attr) ;
[775]76    }
77
78
[445]79    template <typename T_numtype, int N_rank>
80    void CAttributeArray<T_numtype,N_rank>::setInheritedValue(const CAttribute& attr)
81    {
82      this->setInheritedValue(dynamic_cast<const CAttributeArray<T_numtype,N_rank>& >(attr)) ;
[775]83    }
[369]84
85    template <typename T_numtype, int N_rank>
[445]86    void CAttributeArray<T_numtype,N_rank>::setInheritedValue(const CAttributeArray& attr)
87    {
[1158]88      if (this->isEmpty() && _canInherite && attr.hasInheritedValue())
[447]89      {
90        inheritedValue.resize(attr.shape()) ;
91        inheritedValue=attr ;
92      }
[775]93    }
[445]94
95    template <typename T_numtype, int N_rank>
96    CArray<T_numtype,N_rank> CAttributeArray<T_numtype,N_rank>::getInheritedValue(void) const
97    {
98      if (this->isEmpty()) return inheritedValue.copy() ;
99      else return getValue() ;
[775]100    }
101
[445]102    template <typename T_numtype, int N_rank>
103    bool CAttributeArray<T_numtype,N_rank>::hasInheritedValue(void) const
104    {
105      return !this->isEmpty() || !inheritedValue.isEmpty() ;
[775]106    }
[445]107
[1158]108    template <typename T_numtype, int N_rank>
[1219]109    bool CAttributeArray<T_numtype,N_rank>::isEqual(const CAttribute& attr)
[1158]110    {
[1219]111      const CAttributeArray<T_numtype,N_rank>& tmp = dynamic_cast<const CAttributeArray<T_numtype,N_rank>& >(attr);
112      return this->isEqual_(tmp);     
[1158]113    }
[775]114
[445]115    template <typename T_numtype, int N_rank>
[1219]116    bool CAttributeArray<T_numtype,N_rank>::isEqual_(const CAttributeArray& attr)
[1158]117    {
[1219]118      if ((!this->hasInheritedValue() && !attr.hasInheritedValue()))
119          return true;
120      if (this->hasInheritedValue() && attr.hasInheritedValue())
121          return (this->getInheritedValue() == attr.getInheritedValue());
122      else 
123        return false;     
[1158]124    }
125
126    template <typename T_numtype, int N_rank>
[369]127    StdString CAttributeArray<T_numtype,N_rank>::_toString(void) const
128    {
129      StdOStringStream oss;
130      if (! isEmpty() && this->hasId()) oss << this->getName() << "=\"" << CArray<T_numtype, N_rank>::toString() << "\"";
131      return (oss.str());
132    }
133
[1622]134    template <typename T_numtype, int N_rank>
135    StdString CAttributeArray<T_numtype,N_rank>::_dump(void) const
136    {
137      StdOStringStream oss;
138      if (! isEmpty() && this->hasId() && (this->numElements()!=0))
139        oss << this->getName() << "=\"" << CArray<T_numtype, N_rank>::dump() << "\"";
140      return (oss.str());
141    }
142
143
[369]144      template <typename T_numtype, int N_rank>
145         void CAttributeArray<T_numtype, N_rank>::_fromString(const StdString & str)
146      {
147        CArray<T_numtype, N_rank>::fromString(str) ;
148      }
149
150      template <typename T_numtype, int N_rank>
151      bool CAttributeArray<T_numtype, N_rank>::_toBuffer (CBufferOut& buffer) const
152      {
153         return CArray<T_numtype, N_rank>::toBuffer(buffer) ;
154      }
155
156      template <typename T_numtype, int N_rank>
157      bool CAttributeArray<T_numtype, N_rank>::_fromBuffer(CBufferIn& buffer)
158      {
159        return CArray<T_numtype, N_rank>::fromBuffer(buffer) ;
160      }
161
162      template <typename T_numtype, int N_rank>
163      void CAttributeArray<T_numtype, N_rank>::generateCInterface(ostream& oss,const string& className)
164      {
[778]165        CInterface::AttributeCInterface<CArray<T_numtype, N_rank> >(oss, className, this->getName());
[369]166      }
[775]167
[369]168      template <typename T_numtype, int N_rank>
169      void CAttributeArray<T_numtype, N_rank>::generateFortran2003Interface(ostream& oss,const string& className)
170      {
[778]171        CInterface::AttributeFortran2003Interface<CArray<T_numtype, N_rank> >(oss, className, this->getName());
[369]172      }
[775]173
[369]174      template <typename T_numtype, int N_rank>
175      void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceDeclaration_(ostream& oss,const string& className)
176      {
[778]177        CInterface::AttributeFortranInterfaceDeclaration<CArray<T_numtype, N_rank> >(oss, className, this->getName() + "_");
[369]178      }
[775]179
[369]180      template <typename T_numtype, int N_rank>
181      void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceBody_(ostream& oss,const string& className)
182      {
[778]183        CInterface::AttributeFortranInterfaceBody<CArray<T_numtype, N_rank> >(oss, className, this->getName());
[369]184      }
185
186      template <typename T_numtype, int N_rank>
187      void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceDeclaration(ostream& oss,const string& className)
188      {
[778]189        CInterface::AttributeFortranInterfaceDeclaration<CArray<T_numtype, N_rank> >(oss, className, this->getName());
[369]190      }
[775]191
[369]192      template <typename T_numtype, int N_rank>
193      void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceGetDeclaration_(ostream& oss,const string& className)
194      {
[778]195        CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T_numtype, N_rank> >(oss, className, this->getName() + "_");
[369]196      }
[775]197
[369]198      template <typename T_numtype, int N_rank>
199      void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceGetBody_(ostream& oss,const string& className)
200      {
[778]201        CInterface::AttributeFortranInterfaceGetBody<CArray<T_numtype, N_rank> >(oss, className, this->getName());
[369]202      }
203
204      template <typename T_numtype, int N_rank>
205      void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceGetDeclaration(ostream& oss,const string& className)
206      {
[778]207        CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T_numtype, N_rank> >(oss, className, this->getName());
[369]208      }
209} // namespace xios
210
211#endif // __XIOS_ATTRIBUTE_ENUM_IMPL_HPP__
Note: See TracBrowser for help on using the repository browser.