source: XIOS/dev/branch_openmp/src/attribute_enum_impl.hpp @ 1383

Last change on this file since 1383 was 1328, checked in by yushan, 7 years ago

dev_omp

  • 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: 5.8 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{
[1328]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  }
[1328]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  }
[1328]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  }
[1328]56
[580]57  template <class T>
58  string CAttributeEnum<T>::getStringValue(void) const
59  {
[1328]60     return CEnum<T>::toString();
[580]61  }
[369]62
[580]63  template <class T>
64  void CAttributeEnum<T>::setValue(const typename T::t_enum & value)
65  {
66     CEnum<T>::set(value);
67  }
[369]68
[580]69  template <class T>
70  void CAttributeEnum<T>::set(const CAttribute& attr)
71  {
[1328]72    this->set(dynamic_cast<const CAttributeEnum<T>& >(attr));
[580]73  }
[1328]74
75 template <class T>
[580]76  void CAttributeEnum<T>::set(const CAttributeEnum& attr)
77  {
[1328]78    CEnum<T>::set(attr);
[580]79  }
[1328]80
[580]81  template <class T>
82  void CAttributeEnum<T>::setInheritedValue(const CAttribute& attr)
83  {
[1328]84    this->setInheritedValue(dynamic_cast<const CAttributeEnum<T>& >(attr));
[580]85  }
[1328]86
[580]87  template <class T>
88  void CAttributeEnum<T>::setInheritedValue(const CAttributeEnum& attr)
89  {
[1328]90    if (this->isEmpty() && _canInherite && attr.hasInheritedValue()) inheritedValue.set(attr.getInheritedValue());
[580]91  }
[1328]92
[580]93  template <class T>
94  typename T::t_enum CAttributeEnum<T>::getInheritedValue(void) const
95  {
[1328]96    if (this->isEmpty()) return inheritedValue.get();
97    else return getValue();
[580]98  }
[369]99
[580]100  template <class T>
[1328]101  string CAttributeEnum<T>::getInheritedStringValue(void) const
102  {
103     if (this->isEmpty()) return inheritedValue.toString();
104     else return CEnum<T>::toString();;
105  }
[369]106
[580]107  template <class T>
[1328]108  bool CAttributeEnum<T>::hasInheritedValue(void) const
109  {
110    return !this->isEmpty() || !inheritedValue.isEmpty();
111  }
[369]112
[1105]113  template <class T>
[1328]114  bool CAttributeEnum<T>::isEqual(const CAttribute& attr)
115  {
116    return (this->isEqual(dynamic_cast<const CAttributeEnum<T>& >(attr)));
117  }
[1105]118
119  template <class T>
[1328]120  bool CAttributeEnum<T>::isEqual(const CAttributeEnum& attr)
121  {
122    return ((dynamic_cast<const CEnum<T>& >(*this)) == (dynamic_cast<const CEnum<T>& >(attr)));
123  }
[1105]124
[580]125  //---------------------------------------------------------------
[369]126
[580]127  template <class T>
[1328]128  CAttributeEnum<T>& CAttributeEnum<T>::operator=(const T_enum & value)
129  {
130     this->setValue(value);
131     return *this;
132  }
[369]133
[580]134  //---------------------------------------------------------------
[369]135
[580]136  template <class T>
[1328]137  StdString CAttributeEnum<T>::_toString(void) const
138  {
139     StdOStringStream oss;
140     if (!CEnum<T>::isEmpty() && this->hasId())
141        oss << this->getName() << "=\"" << CEnum<T>::toString() << "\"";
142     return (oss.str());
143  }
[369]144
[580]145  template <class T>
[1328]146  void CAttributeEnum<T>::_fromString(const StdString & str)
147  {
148    CEnum<T>::fromString(str);
149  }
[369]150
[580]151  template <class T>
[1328]152  bool CAttributeEnum<T>::_toBuffer (CBufferOut& buffer) const
153  {
154     return CEnum<T>::toBuffer(buffer);
155  }
[369]156
[580]157  template <class T>
[1328]158  bool CAttributeEnum<T>::_fromBuffer(CBufferIn& buffer)
159  {
160    return CEnum<T>::fromBuffer(buffer);
161  }
[580]162
163  template <typename T>
[1328]164  void CAttributeEnum<T>::generateCInterface(ostream& oss,const string& className)
165  {
166    CInterface::AttributeCInterface<CEnumBase>(oss, className, this->getName());
167  }
[580]168
169  template <typename T>
[1328]170  void CAttributeEnum<T>::generateFortran2003Interface(ostream& oss,const string& className)
171  {
172    CInterface::AttributeFortran2003Interface<string>(oss, className, this->getName());
173  }
[580]174
175  template <typename T>
[1328]176  void CAttributeEnum<T>::generateFortranInterfaceDeclaration_(ostream& oss,const string& className)
177  {
178    CInterface::AttributeFortranInterfaceDeclaration<string>(oss, className, this->getName()+"_");
179  }
[580]180
181  template <typename T>
[1328]182  void CAttributeEnum<T>::generateFortranInterfaceBody_(ostream& oss,const string& className)
183  {
184    CInterface::AttributeFortranInterfaceBody<string>(oss, className, this->getName());
185  }
[580]186
187  template <typename T>
[1328]188  void CAttributeEnum<T>::generateFortranInterfaceDeclaration(ostream& oss,const string& className)
189  {
190    CInterface::AttributeFortranInterfaceDeclaration<string>(oss, className, this->getName());
191  }
[580]192
193  template <typename T>
[1328]194  void CAttributeEnum<T>::generateFortranInterfaceGetDeclaration_(ostream& oss,const string& className)
195  {
196    CInterface::AttributeFortranInterfaceGetDeclaration<string>(oss, className, this->getName()+"_");
197  }
[580]198
199  template <typename T>
[1328]200  void CAttributeEnum<T>::generateFortranInterfaceGetBody_(ostream& oss,const string& className)
201  {
202    CInterface::AttributeFortranInterfaceGetBody<string>(oss, className, this->getName());
203  }
[580]204
205  template <typename T>
[1328]206  void CAttributeEnum<T>::generateFortranInterfaceGetDeclaration(ostream& oss,const string& className)
207  {
208    CInterface::AttributeFortranInterfaceGetDeclaration<string>(oss, className, this->getName());
209  }
[369]210} // namespace xios
211
212#endif // __XIOS_ATTRIBUTE_ENUM_IMPL_HPP__
Note: See TracBrowser for help on using the repository browser.