XIOS  1.0
Xml I/O Server
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Définitions de type Énumérations Valeurs énumérées Amis Macros
attribute_array_impl.hpp
Aller à la documentation de ce fichier.
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 
10 namespace xios
11 {
13  template <typename T_numtype, int N_rank>
15  : CAttribute(id)
16  { /* Ne rien faire de plus */ }
17 
18  template <typename T_numtype, int N_rank>
20  : CAttribute(id)
21  {
22  this->setValue(value);
23  }
24 
25  template <typename T_numtype, int N_rank>
26  CAttributeArray<T_numtype, N_rank>::CAttributeArray(const StdString & id, xios_map<StdString, CAttribute*> & umap)
27  : CAttribute(id)
28  {
29  umap.insert(umap.end(), std::make_pair(id, this));
30  }
31 
32  template <typename T_numtype, int N_rank>
34  xios_map<StdString, CAttribute*> & umap)
35  : CAttribute(id)
36  {
37  this->setValue(value);
38  umap.insert(umap.end(), std::make_pair(id, this));
39  }
40 
42 
43  template <typename T_numtype, int N_rank>
45  {
47  inheritedValue.reset() ;
48  }
49 
50  template <typename T_numtype, int N_rank>
52  {
53  return this->copy() ;
54  }
55 
56  template <typename T_numtype, int N_rank>
58  {
59  this->resize(value.shape()) ;
60  *this=value ;
61  }
62 
63  template <typename T_numtype, int N_rank>
65  {
66  this->set(dynamic_cast<const CAttributeArray<T_numtype,N_rank>& >(attr)) ;
67  }
68 
69  template <typename T_numtype, int N_rank>
71  {
72  this->setValue(attr) ;
73  }
74 
75 
76  template <typename T_numtype, int N_rank>
78  {
79  this->setInheritedValue(dynamic_cast<const CAttributeArray<T_numtype,N_rank>& >(attr)) ;
80  }
81 
82  template <typename T_numtype, int N_rank>
84  {
85  if (this->isEmpty() && _canInherite && attr.hasInheritedValue())
86  {
87  inheritedValue.resize(attr.shape()) ;
88  inheritedValue=attr ;
89  }
90  }
91 
92  template <typename T_numtype, int N_rank>
94  {
95  if (this->isEmpty()) return inheritedValue.copy() ;
96  else return getValue() ;
97  }
98 
99  template <typename T_numtype, int N_rank>
101  {
102  return !this->isEmpty() || !inheritedValue.isEmpty() ;
103  }
104 
105  template <typename T_numtype, int N_rank>
107  {
108  const CAttributeArray<T_numtype,N_rank>& tmp = dynamic_cast<const CAttributeArray<T_numtype,N_rank>& >(attr);
109  return this->isEqual_(tmp);
110  }
111 
112  template <typename T_numtype, int N_rank>
114  {
115  if ((!this->hasInheritedValue() && !attr.hasInheritedValue()))
116  return true;
117  if (this->hasInheritedValue() && attr.hasInheritedValue())
118  return (this->getInheritedValue() == attr.getInheritedValue());
119  else
120  return false;
121  }
122 
123  template <typename T_numtype, int N_rank>
125  {
126  StdOStringStream oss;
127  if (! isEmpty() && this->hasId()) oss << this->getName() << "=\"" << CArray<T_numtype, N_rank>::toString() << "\"";
128  return (oss.str());
129  }
130 
131  template <typename T_numtype, int N_rank>
133  {
134  StdOStringStream oss;
135  if (! isEmpty() && this->hasId() && (this->numElements()!=0))
136  oss << this->getName() << "=\"" << CArray<T_numtype, N_rank>::dump() << "\"";
137  return (oss.str());
138  }
139 
140 
141  template <typename T_numtype, int N_rank>
143  {
145  }
146 
147  template <typename T_numtype, int N_rank>
149  {
150  return CArray<T_numtype, N_rank>::toBuffer(buffer) ;
151  }
152 
153  template <typename T_numtype, int N_rank>
155  {
157  }
158 
159  template <typename T_numtype, int N_rank>
160  void CAttributeArray<T_numtype, N_rank>::generateCInterface(ostream& oss,const string& className)
161  {
162  CInterface::AttributeCInterface<CArray<T_numtype, N_rank> >(oss, className, this->getName());
163  }
164 
165  template <typename T_numtype, int N_rank>
166  void CAttributeArray<T_numtype, N_rank>::generateFortran2003Interface(ostream& oss,const string& className)
167  {
168  CInterface::AttributeFortran2003Interface<CArray<T_numtype, N_rank> >(oss, className, this->getName());
169  }
170 
171  template <typename T_numtype, int N_rank>
173  {
174  CInterface::AttributeFortranInterfaceDeclaration<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>::generateFortranInterfaceBody_(ostream& oss,const string& className)
179  {
180  CInterface::AttributeFortranInterfaceBody<CArray<T_numtype, N_rank> >(oss, className, this->getName());
181  }
182 
183  template <typename T_numtype, int N_rank>
185  {
186  CInterface::AttributeFortranInterfaceDeclaration<CArray<T_numtype, N_rank> >(oss, className, this->getName());
187  }
188 
189  template <typename T_numtype, int N_rank>
191  {
192  CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T_numtype, N_rank> >(oss, className, this->getName() + "_");
193  }
194 
195  template <typename T_numtype, int N_rank>
197  {
198  CInterface::AttributeFortranInterfaceGetBody<CArray<T_numtype, N_rank> >(oss, className, this->getName());
199  }
200 
201  template <typename T_numtype, int N_rank>
203  {
204  CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T_numtype, N_rank> >(oss, className, this->getName());
205  }
206 } // namespace xios
207 
208 #endif // __XIOS_ATTRIBUTE_ENUM_IMPL_HPP__
bool fromBuffer(CBufferIn &buffer)
bool hasInheritedValue(void) const
bool isEqual_(const CAttributeArray &attr)
////////////////////// Déclarations ////////////////////// ///
bool toBuffer(CBufferOut &buffer) const
virtual void generateFortranInterfaceDeclaration_(ostream &oss, const string &className)
StdString _dump(void) const
virtual void generateFortranInterfaceGetDeclaration_(ostream &oss, const string &className)
CAttributeArray(const StdString &id)
Constructeurs ///.
bool _fromBuffer(CBufferIn &buffer)
bool isEqual(const CAttribute &attr)
std::string StdString
Definition: xios_spl.hpp:48
#define xios(arg)
CArray< T_numtype, N_rank > getValue(void) const
Accesseur ///.
StdString _toString(void) const
virtual void generateFortranInterfaceGetDeclaration(ostream &oss, const string &className)
virtual string dump(void) const
Definition: array_new.hpp:535
virtual void generateFortranInterfaceGetBody_(ostream &oss, const string &className)
virtual void generateCInterface(ostream &oss, const string &className)
void _fromString(const StdString &str)
axisDest_ index resize(nDest)
virtual void generateFortran2003Interface(ostream &oss, const string &className)
void setValue(const CArray< T_numtype, N_rank > &value)
Mutateurs ///.
virtual void reset(void)
Definition: array_new.hpp:546
axisDest_ n_glo setValue(extractN_)
void set(const CAttribute &attr)
CArray< T_numtype, N_rank > getInheritedValue(void) const
bool _toBuffer(CBufferOut &buffer) const
virtual void fromString(const string &str)
Definition: array_new.hpp:532
////////////////////// Déclarations ////////////////////// ///
Definition: attribute.hpp:23
std::ostringstream StdOStringStream
Définition de types (issus de la bibliothèque standard)///.
Definition: xios_spl.hpp:41
void setInheritedValue(const CAttributeArray &attr)
virtual string toString(void) const
Definition: array_new.hpp:533
virtual void generateFortranInterfaceBody_(ostream &oss, const string &className)
CArray< T_numtype, N_rank > copy() const
Definition: array_new.hpp:285
virtual void generateFortranInterfaceDeclaration(ostream &oss, const string &className)