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 | |
---|
11 | namespace 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 | this->setValue(value); |
---|
83 | return *this; |
---|
84 | } |
---|
85 | |
---|
86 | //--------------------------------------------------------------- |
---|
87 | |
---|
88 | template <class T> |
---|
89 | StdString CAttributeEnum<T>::_toString(void) const |
---|
90 | { |
---|
91 | StdOStringStream oss; |
---|
92 | if (!CEnum<T>::isEmpty() && this->hasId()) |
---|
93 | oss << this->getName() << "=\"" << CEnum<T>::toString() << "\""; |
---|
94 | return (oss.str()); |
---|
95 | } |
---|
96 | |
---|
97 | template <class T> |
---|
98 | void CAttributeEnum<T>::_fromString(const StdString & str) |
---|
99 | { |
---|
100 | CEnum<T>::fromString(str) ; |
---|
101 | } |
---|
102 | |
---|
103 | template <class T> |
---|
104 | bool CAttributeEnum<T>::_toBuffer (CBufferOut& buffer) const |
---|
105 | { |
---|
106 | return CEnum<T>::toBuffer(buffer) ; |
---|
107 | } |
---|
108 | |
---|
109 | template <class T> |
---|
110 | bool CAttributeEnum<T>::_fromBuffer(CBufferIn& buffer) |
---|
111 | { |
---|
112 | return CEnum<T>::fromBuffer(buffer) ; |
---|
113 | } |
---|
114 | |
---|
115 | template <typename T> |
---|
116 | void CAttributeEnum<T>::generateCInterface(ostream& oss,const string& className) |
---|
117 | { |
---|
118 | CInterface::AttributeCInterface<CEnumBase>(oss, className, this->getName()) ; |
---|
119 | } |
---|
120 | |
---|
121 | template <typename T> |
---|
122 | void CAttributeEnum<T>::generateFortran2003Interface(ostream& oss,const string& className) |
---|
123 | { |
---|
124 | CInterface::AttributeFortran2003Interface<string>(oss, className, this->getName()) ; |
---|
125 | } |
---|
126 | |
---|
127 | template <typename T> |
---|
128 | void CAttributeEnum<T>::generateFortranInterfaceDeclaration_(ostream& oss,const string& className) |
---|
129 | { |
---|
130 | CInterface::AttributeFortranInterfaceDeclaration<string>(oss, className, this->getName()+"_") ; |
---|
131 | } |
---|
132 | |
---|
133 | template <typename T> |
---|
134 | void CAttributeEnum<T>::generateFortranInterfaceBody_(ostream& oss,const string& className) |
---|
135 | { |
---|
136 | CInterface::AttributeFortranInterfaceBody<string>(oss, className, this->getName()) ; |
---|
137 | } |
---|
138 | |
---|
139 | template <typename T> |
---|
140 | void CAttributeEnum<T>::generateFortranInterfaceDeclaration(ostream& oss,const string& className) |
---|
141 | { |
---|
142 | CInterface::AttributeFortranInterfaceDeclaration<string>(oss, className, this->getName()) ; |
---|
143 | } |
---|
144 | |
---|
145 | template <typename T> |
---|
146 | void CAttributeEnum<T>::generateFortranInterfaceGetDeclaration_(ostream& oss,const string& className) |
---|
147 | { |
---|
148 | CInterface::AttributeFortranInterfaceGetDeclaration<string>(oss, className, this->getName()+"_") ; |
---|
149 | } |
---|
150 | |
---|
151 | template <typename T> |
---|
152 | void CAttributeEnum<T>::generateFortranInterfaceGetBody_(ostream& oss,const string& className) |
---|
153 | { |
---|
154 | CInterface::AttributeFortranInterfaceGetBody<string>(oss, className, this->getName()) ; |
---|
155 | } |
---|
156 | |
---|
157 | template <typename T> |
---|
158 | void CAttributeEnum<T>::generateFortranInterfaceGetDeclaration(ostream& oss,const string& className) |
---|
159 | { |
---|
160 | CInterface::AttributeFortranInterfaceGetDeclaration<string>(oss, className, this->getName()) ; |
---|
161 | } |
---|
162 | |
---|
163 | } // namespace xios |
---|
164 | |
---|
165 | #endif // __XIOS_ATTRIBUTE_ENUM_IMPL_HPP__ |
---|