source: XIOS/dev/branch_yushan_merged/src/attribute_enum_impl.hpp @ 1179

Last change on this file since 1179 was 1134, checked in by yushan, 7 years ago

branch merged with trunk r1130

  • 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: 6.2 KB
RevLine 
[369]1#ifndef __XIOS_ATTRIBUTE_ENUM_IMPL_HPP__
2#define __XIOS_ATTRIBUTE_ENUM_IMPL_HPP__
3
4#include "enum.hpp"
5#include "buffer_in.hpp"
6#include "buffer_out.hpp"
7#include "generate_interface.hpp"
8#include "attribute_enum.hpp"
9
10namespace xios
11{
[1134]12  /// ////////////////////// Définitions ////////////////////// ///
[580]13  template <class T>
14  CAttributeEnum<T>::CAttributeEnum(const StdString & id)
15     : CAttribute(id)
16  { /* Ne rien faire de plus */ }
[369]17
[580]18  template <class T>
19  CAttributeEnum<T>::CAttributeEnum(const StdString & id, const T_enum & value)
20     : CAttribute(id)
21  {
22     this->setValue(value);
23  }
[369]24
[580]25  template <class T>
26  CAttributeEnum<T>::CAttributeEnum(const StdString & id,
27                                    xios_map<StdString, CAttribute*> & umap)
28     : CAttribute(id)
29  {
30     umap.insert(umap.end(), std::make_pair(id, this));
31  }
[1134]32 
[580]33  template <class T>
34  CAttributeEnum<T>::CAttributeEnum
35        (const StdString & id, const T_enum & value,
36         xios_map<StdString, CAttribute*> & umap)
37     : CAttribute(id)
38  {
39     this->setValue(value);
40     umap.insert(umap.end(), std::make_pair(id, this));
41  }
[1134]42 
[580]43  ///--------------------------------------------------------------
44  template <class T>
45  void CAttributeEnum<T>::reset(void)
46  {
47     CEnum<T>::reset();
48     inheritedValue.reset();
49  }
[369]50
[580]51  template <class T>
52  typename T::t_enum CAttributeEnum<T>::getValue(void) const
53  {
54     return CEnum<T>::get();
55  }
[1134]56 
[580]57  template <class T>
58  string CAttributeEnum<T>::getStringValue(void) const
59  {
[1134]60    return CEnum<T>::toString();
[580]61  }
[369]62
[1134]63
[580]64  template <class T>
65  void CAttributeEnum<T>::setValue(const typename T::t_enum & value)
66  {
67     CEnum<T>::set(value);
68  }
[369]69
[580]70  template <class T>
71  void CAttributeEnum<T>::set(const CAttribute& attr)
72  {
[1134]73     this->set(dynamic_cast<const CAttributeEnum<T>& >(attr));
[580]74  }
[1134]75   
76  template <class T>
[580]77  void CAttributeEnum<T>::set(const CAttributeEnum& attr)
78  {
[1134]79     CEnum<T>::set(attr);
[580]80  }
[1134]81 
[580]82  template <class T>
83  void CAttributeEnum<T>::setInheritedValue(const CAttribute& attr)
84  {
[1134]85     this->setInheritedValue(dynamic_cast<const CAttributeEnum<T>& >(attr));
[580]86  }
[1134]87 
[580]88  template <class T>
89  void CAttributeEnum<T>::setInheritedValue(const CAttributeEnum& attr)
90  {
[1134]91     if (this->isEmpty() && _canInherite && attr.hasInheritedValue()) inheritedValue.set(attr.getInheritedValue());
[580]92  }
[1134]93 
[580]94  template <class T>
95  typename T::t_enum CAttributeEnum<T>::getInheritedValue(void) const
96  {
[1134]97     if (this->isEmpty()) return inheritedValue.get();
98     else return getValue();
[580]99  }
[369]100
[580]101  template <class T>
[1134]102      string CAttributeEnum<T>::getInheritedStringValue(void) const
103      {
104          if (this->isEmpty()) return inheritedValue.toString();
105          else return CEnum<T>::toString();;
106      }
[369]107
[580]108  template <class T>
[1134]109      bool CAttributeEnum<T>::hasInheritedValue(void) const
110      {
111          return !this->isEmpty() || !inheritedValue.isEmpty();
112      }
[369]113
[1105]114  template <class T>
[1134]115      bool CAttributeEnum<T>::isEqual(const CAttribute& attr)
116      {
117          return (this->isEqual(dynamic_cast<const CAttributeEnum<T>& >(attr)));
118      }
[1105]119
120  template <class T>
[1134]121      bool CAttributeEnum<T>::isEqual(const CAttributeEnum& attr)
122      {
123          return ((dynamic_cast<const CEnum<T>& >(*this)) == (dynamic_cast<const CEnum<T>& >(attr)));
124      }
[1105]125
[580]126  //---------------------------------------------------------------
[369]127
[580]128  template <class T>
[1134]129      CAttributeEnum<T>& CAttributeEnum<T>::operator=(const T_enum & value)
130      {
131          this->setValue(value);
132          return *this;
133      }
[369]134
[580]135  //---------------------------------------------------------------
[369]136
[580]137  template <class T>
[1134]138      StdString CAttributeEnum<T>::_toString(void) const
139      {
140          StdOStringStream oss;
141          if (!CEnum<T>::isEmpty() && this->hasId())
142              oss << this->getName() << "=\"" << CEnum<T>::toString() << "\"";
143          return (oss.str());
144      }
[369]145
[580]146  template <class T>
[1134]147      void CAttributeEnum<T>::_fromString(const StdString & str)
148      {
149          CEnum<T>::fromString(str);
150      }
[369]151
[580]152  template <class T>
[1134]153      bool CAttributeEnum<T>::_toBuffer (CBufferOut& buffer) const
154      {
155          return CEnum<T>::toBuffer(buffer);
156      }
[369]157
[580]158  template <class T>
[1134]159      bool CAttributeEnum<T>::_fromBuffer(CBufferIn& buffer)
160      {
161          return CEnum<T>::fromBuffer(buffer);
162      }
[580]163
164  template <typename T>
[1134]165      void CAttributeEnum<T>::generateCInterface(ostream& oss,const string& className)
166      {
167          CInterface::AttributeCInterface<CEnumBase>(oss, className, this->getName());
168      }
[580]169
170  template <typename T>
[1134]171      void CAttributeEnum<T>::generateFortran2003Interface(ostream& oss,const string& className)
172      {
173          CInterface::AttributeFortran2003Interface<string>(oss, className, this->getName());
174      }
[580]175
176  template <typename T>
[1134]177      void CAttributeEnum<T>::generateFortranInterfaceDeclaration_(ostream& oss,const string& className)
178      {
179          CInterface::AttributeFortranInterfaceDeclaration<string>(oss, className, this->getName()+"_");
180      }
[580]181
182  template <typename T>
[1134]183      void CAttributeEnum<T>::generateFortranInterfaceBody_(ostream& oss,const string& className)
184      {
185          CInterface::AttributeFortranInterfaceBody<string>(oss, className, this->getName());
186      }
[580]187
188  template <typename T>
[1134]189      void CAttributeEnum<T>::generateFortranInterfaceDeclaration(ostream& oss,const string& className)
190      {
191          CInterface::AttributeFortranInterfaceDeclaration<string>(oss, className, this->getName());
192      }
[580]193
194  template <typename T>
[1134]195      void CAttributeEnum<T>::generateFortranInterfaceGetDeclaration_(ostream& oss,const string& className)
196      {
197          CInterface::AttributeFortranInterfaceGetDeclaration<string>(oss, className, this->getName()+"_");
198      }
[580]199
200  template <typename T>
[1134]201      void CAttributeEnum<T>::generateFortranInterfaceGetBody_(ostream& oss,const string& className)
202      {
203          CInterface::AttributeFortranInterfaceGetBody<string>(oss, className, this->getName());
204      }
[580]205
206  template <typename T>
[1134]207      void CAttributeEnum<T>::generateFortranInterfaceGetDeclaration(ostream& oss,const string& className)
208      {
209          CInterface::AttributeFortranInterfaceGetDeclaration<string>(oss, className, this->getName());
210      }
[369]211} // namespace xios
212
213#endif // __XIOS_ATTRIBUTE_ENUM_IMPL_HPP__
[1134]214
Note: See TracBrowser for help on using the repository browser.