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

Last change on this file since 1875 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
Line 
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
9
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)
16      { bool alwaysFalse ; alwaysFalse=false ; if (alwaysFalse) TV_ttf_display_type(this); }
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      {
22         bool alwaysFalse ; alwaysFalse=false ; if (alwaysFalse) TV_ttf_display_type(this);
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      {
30         bool alwaysFalse ; alwaysFalse=false ; if (alwaysFalse) TV_ttf_display_type(this);
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      {
39         bool alwaysFalse ; alwaysFalse=false ; if (alwaysFalse) TV_ttf_display_type(this);
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>
47      void CAttributeArray<T_numtype, N_rank>::reset(void)
48      {
49        CArray<T_numtype, N_rank>::reset() ;
50        inheritedValue.reset() ;
51      }
52
53      template <typename T_numtype, int N_rank>
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)) ;
70    }
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) ;
76    }
77
78
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)) ;
83    }
84
85    template <typename T_numtype, int N_rank>
86    void CAttributeArray<T_numtype,N_rank>::setInheritedValue(const CAttributeArray& attr)
87    {
88      if (this->isEmpty() && _canInherite && attr.hasInheritedValue())
89      {
90        inheritedValue.resize(attr.shape()) ;
91        inheritedValue=attr ;
92      }
93    }
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() ;
100    }
101
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() ;
106    }
107
108    template <typename T_numtype, int N_rank>
109    bool CAttributeArray<T_numtype,N_rank>::isEqual(const CAttribute& attr)
110    {
111      const CAttributeArray<T_numtype,N_rank>& tmp = dynamic_cast<const CAttributeArray<T_numtype,N_rank>& >(attr);
112      return this->isEqual_(tmp);     
113    }
114
115    template <typename T_numtype, int N_rank>
116    bool CAttributeArray<T_numtype,N_rank>::isEqual_(const CAttributeArray& attr)
117    {
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;     
124    }
125
126    template <typename T_numtype, int N_rank>
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
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
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      {
165        CInterface::AttributeCInterface<CArray<T_numtype, N_rank> >(oss, className, this->getName());
166      }
167
168      template <typename T_numtype, int N_rank>
169      void CAttributeArray<T_numtype, N_rank>::generateFortran2003Interface(ostream& oss,const string& className)
170      {
171        CInterface::AttributeFortran2003Interface<CArray<T_numtype, N_rank> >(oss, className, this->getName());
172      }
173
174      template <typename T_numtype, int N_rank>
175      void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceDeclaration_(ostream& oss,const string& className)
176      {
177        CInterface::AttributeFortranInterfaceDeclaration<CArray<T_numtype, N_rank> >(oss, className, this->getName() + "_");
178      }
179
180      template <typename T_numtype, int N_rank>
181      void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceBody_(ostream& oss,const string& className)
182      {
183        CInterface::AttributeFortranInterfaceBody<CArray<T_numtype, N_rank> >(oss, className, this->getName());
184      }
185
186      template <typename T_numtype, int N_rank>
187      void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceDeclaration(ostream& oss,const string& className)
188      {
189        CInterface::AttributeFortranInterfaceDeclaration<CArray<T_numtype, N_rank> >(oss, className, this->getName());
190      }
191
192      template <typename T_numtype, int N_rank>
193      void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceGetDeclaration_(ostream& oss,const string& className)
194      {
195        CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T_numtype, N_rank> >(oss, className, this->getName() + "_");
196      }
197
198      template <typename T_numtype, int N_rank>
199      void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceGetBody_(ostream& oss,const string& className)
200      {
201        CInterface::AttributeFortranInterfaceGetBody<CArray<T_numtype, N_rank> >(oss, className, this->getName());
202      }
203
204      template <typename T_numtype, int N_rank>
205      void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceGetDeclaration(ostream& oss,const string& className)
206      {
207        CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T_numtype, N_rank> >(oss, className, this->getName());
208      }
209} // namespace xios
210
211#endif // __XIOS_ATTRIBUTE_ENUM_IMPL_HPP__
Note: See TracBrowser for help on using the repository browser.