source: XIOS/dev/dev_trunk_graph/src/attribute_array_impl.hpp @ 2030

Last change on this file since 2030 was 2019, checked in by yushan, 3 years ago

Graph intermedia commit to a tmp branch

  • 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.3 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    template <typename T_numtype, int N_rank>
144    StdString CAttributeArray<T_numtype,N_rank>::_dumpGraph(void) const
145    {
146      StdOStringStream oss;
147      if (! isEmpty() && this->hasId() && (this->numElements()!=0))
148        oss << this->getName() << "=" << CArray<T_numtype, N_rank>::dump() << "";
149      return (oss.str());
150    }
151
152
153      template <typename T_numtype, int N_rank>
154         void CAttributeArray<T_numtype, N_rank>::_fromString(const StdString & str)
155      {
156        CArray<T_numtype, N_rank>::fromString(str) ;
157      }
158
159      template <typename T_numtype, int N_rank>
160      bool CAttributeArray<T_numtype, N_rank>::_toBuffer (CBufferOut& buffer) const
161      {
162         return CArray<T_numtype, N_rank>::toBuffer(buffer) ;
163      }
164
165      template <typename T_numtype, int N_rank>
166      bool CAttributeArray<T_numtype, N_rank>::_fromBuffer(CBufferIn& buffer)
167      {
168        return CArray<T_numtype, N_rank>::fromBuffer(buffer) ;
169      }
170
171      template <typename T_numtype, int N_rank>
172      void CAttributeArray<T_numtype, N_rank>::generateCInterface(ostream& oss,const string& className)
173      {
174        CInterface::AttributeCInterface<CArray<T_numtype, N_rank> >(oss, className, this->getName());
175      }
176
177      template <typename T_numtype, int N_rank>
178      void CAttributeArray<T_numtype, N_rank>::generateFortran2003Interface(ostream& oss,const string& className)
179      {
180        CInterface::AttributeFortran2003Interface<CArray<T_numtype, N_rank> >(oss, className, this->getName());
181      }
182
183      template <typename T_numtype, int N_rank>
184      void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceDeclaration_(ostream& oss,const string& className)
185      {
186        CInterface::AttributeFortranInterfaceDeclaration<CArray<T_numtype, N_rank> >(oss, className, this->getName() + "_");
187      }
188
189      template <typename T_numtype, int N_rank>
190      void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceBody_(ostream& oss,const string& className)
191      {
192        CInterface::AttributeFortranInterfaceBody<CArray<T_numtype, N_rank> >(oss, className, this->getName());
193      }
194
195      template <typename T_numtype, int N_rank>
196      void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceDeclaration(ostream& oss,const string& className)
197      {
198        CInterface::AttributeFortranInterfaceDeclaration<CArray<T_numtype, N_rank> >(oss, className, this->getName());
199      }
200
201      template <typename T_numtype, int N_rank>
202      void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceGetDeclaration_(ostream& oss,const string& className)
203      {
204        CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T_numtype, N_rank> >(oss, className, this->getName() + "_");
205      }
206
207      template <typename T_numtype, int N_rank>
208      void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceGetBody_(ostream& oss,const string& className)
209      {
210        CInterface::AttributeFortranInterfaceGetBody<CArray<T_numtype, N_rank> >(oss, className, this->getName());
211      }
212
213      template <typename T_numtype, int N_rank>
214      void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceGetDeclaration(ostream& oss,const string& className)
215      {
216        CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T_numtype, N_rank> >(oss, className, this->getName());
217      }
218} // namespace xios
219
220#endif // __XIOS_ATTRIBUTE_ENUM_IMPL_HPP__
Note: See TracBrowser for help on using the repository browser.