source: XIOS/trunk/src/attribute_enum_impl.hpp @ 369

Last change on this file since 369 was 369, checked in by ymipsl, 12 years ago

Major Update

  • redesign Type and attribute manipulation
  • add enumerate type and attribute
  • use blitz class array instead of boost class array

YM

File size: 5.1 KB
Line 
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
10 
11namespace xios
12{
13
14      /// ////////////////////// Définitions ////////////////////// ///
15      template <class T>
16         CAttributeEnum<T>::CAttributeEnum(const StdString & id)
17         : CAttribute(id)
18      { /* Ne rien faire de plus */ }
19
20      template <class T>
21         CAttributeEnum<T>::CAttributeEnum(const StdString & id, const T_enum & value)
22         : CAttribute(id)
23      {
24         this->setValue(value);
25      }
26
27      template <class T>
28      CAttributeEnum<T>::CAttributeEnum(const StdString & id,
29                              xios_map<StdString, CAttribute*> & umap)
30         : CAttribute(id)
31      {
32         umap.insert(umap.end(), std::make_pair(id, this));
33      }
34
35      template <class T>
36         CAttributeEnum<T>::CAttributeEnum
37            (const StdString & id, const T_enum & value,
38             xios_map<StdString, CAttribute*> & umap)
39         : CAttribute(id)
40      {
41         this->setValue(value);
42         umap.insert(umap.end(), std::make_pair(id, this));
43      }
44
45      ///--------------------------------------------------------------
46
47      template <class T>
48      typename T::t_enum CAttributeEnum<T>::getValue(void) const
49      {
50         return CEnum<T>::get() ;
51      }
52
53      template <class T>
54         string CAttributeEnum<T>::getStringValue(void) const
55      {
56         return CEnum<T>::toString() ;
57      }
58
59      template <class T>
60         void CAttributeEnum<T>::setValue(const typename T::t_enum & value)
61      {
62         CEnum<T>::set(value) ;
63      }
64
65    template <class T>
66    void CAttributeEnum<T>::set(const CAttribute& attr)
67    {
68      this->set(dynamic_cast<const CAttributeEnum<T>& >(attr)) ;
69    } 
70
71   template <class T>
72    void CAttributeEnum<T>::set(const CAttributeEnum& attr)
73    {
74      CEnum<T>::set(attr) ;
75    } 
76
77      //---------------------------------------------------------------
78
79      template <class T>
80      CAttributeEnum<T>& CAttributeEnum<T>::operator=(const T_enum & value)
81      {
82         cout<<"CAttributeEnum<T>& CAttributeEnum<T>::operator=(const T_enum & value)"<<endl ;
83         this->setValue(value);
84         return *this;
85      }
86
87      //---------------------------------------------------------------
88
89      template <class T>
90         StdString CAttributeEnum<T>::_toString(void) const
91      {
92         StdOStringStream oss;
93         if (!CEnum<T>::isEmpty() && this->hasId())
94            oss << this->getName() << "=\"" << CEnum<T>::toString() << "\"";
95         return (oss.str());
96      }
97
98      template <class T>
99         void CAttributeEnum<T>::_fromString(const StdString & str)
100      {
101        CEnum<T>::fromString(str) ;
102      }
103
104      template <class T>
105      bool CAttributeEnum<T>::_toBuffer (CBufferOut& buffer) const
106      {
107         return CEnum<T>::toBuffer(buffer) ;
108      }
109
110      template <class T>
111      bool CAttributeEnum<T>::_fromBuffer(CBufferIn& buffer)
112      {
113        return CEnum<T>::fromBuffer(buffer) ;
114      }
115
116      template <typename T>
117      void CAttributeEnum<T>::generateCInterface(ostream& oss,const string& className)
118      {
119        CInterface::AttributeCInterface<CEnumBase>(oss, className, this->getName()) ;
120      }
121     
122      template <typename T>
123      void CAttributeEnum<T>::generateFortran2003Interface(ostream& oss,const string& className)
124      {
125        CInterface::AttributeFortran2003Interface<string>(oss, className, this->getName()) ;
126      }
127     
128      template <typename T>
129      void CAttributeEnum<T>::generateFortranInterfaceDeclaration_(ostream& oss,const string& className)
130      {
131        CInterface::AttributeFortranInterfaceDeclaration<string>(oss, className, this->getName()+"_") ;
132      }
133 
134      template <typename T>
135      void CAttributeEnum<T>::generateFortranInterfaceBody_(ostream& oss,const string& className)
136      {
137        CInterface::AttributeFortranInterfaceBody<string>(oss, className, this->getName()) ;
138      }
139
140      template <typename T>
141      void CAttributeEnum<T>::generateFortranInterfaceDeclaration(ostream& oss,const string& className)
142      {
143        CInterface::AttributeFortranInterfaceDeclaration<string>(oss, className, this->getName()) ;
144      }
145     
146      template <typename T>
147      void CAttributeEnum<T>::generateFortranInterfaceGetDeclaration_(ostream& oss,const string& className)
148      {
149        CInterface::AttributeFortranInterfaceGetDeclaration<string>(oss, className, this->getName()+"_") ;
150      }
151 
152      template <typename T>
153      void CAttributeEnum<T>::generateFortranInterfaceGetBody_(ostream& oss,const string& className)
154      {
155        CInterface::AttributeFortranInterfaceGetBody<string>(oss, className, this->getName()) ;
156      }
157
158      template <typename T>
159      void CAttributeEnum<T>::generateFortranInterfaceGetDeclaration(ostream& oss,const string& className)
160      {
161        CInterface::AttributeFortranInterfaceGetDeclaration<string>(oss, className, this->getName()) ;
162      }
163 
164} // namespace xios
165
166#endif // __XIOS_ATTRIBUTE_ENUM_IMPL_HPP__
Note: See TracBrowser for help on using the repository browser.