source: XMLIO_V2/dev/dev_rv/src/xmlio/attribute_template_impl.hpp @ 184

Last change on this file since 184 was 182, checked in by hozdoba, 13 years ago
File size: 5.1 KB
RevLine 
[152]1#ifndef __XMLIO_CAttributeTemplate_impl__
2#define __XMLIO_CAttributeTemplate_impl__
3
[173]4#include "array.hpp"
5
[152]6namespace xmlioserver
7{
8   namespace tree
9   {
10      /// ////////////////////// Définitions ////////////////////// ///
11      template <class T>
12         CAttributeTemplate<T>::CAttributeTemplate(const StdString & id)
13         : CAttribute(id)
14      { /* Ne rien faire de plus */ }
15
16      template <class T>
17         CAttributeTemplate<T>::CAttributeTemplate(const StdString & id, const T & value)
18         : CAttribute(id)
19      {
20         this->setValue(value);
21      }
22
23      template <class T>
24         CAttributeTemplate<T>::CAttributeTemplate(const CAttribute & attribut)
25         throw (CException)
26         : CAttribute(attribut)
27      {
28         if (!attribut.isEmpty() && !attribut.isType<T>())
29            ERROR("CAttributeTemplate", << "Invalid instantiation !");
30      }
31
32      template <class T>
33         CAttributeTemplate<T>::CAttributeTemplate(const StdString & id,
34                              xios_map<StdString, CAttribute*> & umap)
35         : CAttribute(id)
36      {
37         umap.insert(umap.end(), std::make_pair(id, this));
38      }
39
40      template <class T>
41         CAttributeTemplate<T>::CAttributeTemplate
42            (const StdString & id, const T & value,
43             xios_map<StdString, CAttribute*> & umap)
44         : CAttribute(id)
45      {
46         this->setValue(value);
47         umap.insert(umap.end(), std::make_pair(id, this));
48      }
49
50      template <class T>
51         CAttributeTemplate<T>::~CAttributeTemplate(void)
[182]52      { 
53         this->clear();
54      }
[152]55
56      ///--------------------------------------------------------------
57
58      template <class T>
59         T CAttributeTemplate<T>::getValue(void) const
60      {
61         return (SuperClass::getValue<T>());
62      }
63
64      template <class T>
65         void CAttributeTemplate<T>::setValue(const T & value)
66      {
67         SuperClass::setValue<T>(value);
68      }
69
70      //---------------------------------------------------------------
71
72      template <class T>
73         T CAttributeTemplate<T>::operator=(const T & value)
74      {
75         this->setValue(value);
76         return (this->getValue());
77      }
78
79      //---------------------------------------------------------------
80
81      template <class T>
82         StdString CAttributeTemplate<T>::toString(void) const
83      {
84         StdOStringStream oss;
85         if (!this->isEmpty() && this->hasId())
86            oss << this->getName() << "=\"" << this->getValue() << "\"";
87         return (oss.str());
88      }
89
90      template <class T>
91         void CAttributeTemplate<T>::fromString(const StdString & str)
92      {
93         ERROR("CAttributeTemplate<T>::fromString(const StdString & str)",
94               << "[ str = " << str << " ] Not implemented yet !");
95      }
96
97      //---------------------------------------------------------------
98
99      template <class T>
100         void CAttributeTemplate<T>::toBinary (StdOStream & os) const
101      {
102         this->getValue()->toBinary(os);
103      }
104
105      template <class T>
106         void CAttributeTemplate<T>::fromBinary(StdIStream & is)
107      {
[173]108         T value;
109         FromBinary(is, value);
110         this->setValue(value);
[152]111      }
112
113      //---------------------------------------------------------------
114
115      /** Spécialisations des templates pour la fonction [toString] **/
116
117      template <>
118         StdString CAttributeTemplate<bool>::toString(void) const;
119
120      //---------------------------------------------------------------
121
122      /** Spécialisations des templates pour la fonction [fromString] **/
123
124      template <> // Chaîne de caractÚres.
125         void CAttributeTemplate<StdString>::fromString(const StdString & str);
126
127      template <> // Entier
128         void CAttributeTemplate<int>::fromString(const StdString & str);
129
130      template <> // Booléen
131         void CAttributeTemplate<bool>::fromString(const StdString & str);
132
133      template<> // Tableau
134         void CAttributeTemplate<ARRAY(double, 1)>::fromString(const StdString & str);
135
136      //---------------------------------------------------------------
137
138      /** Spécialisations des templates pour la fonction [toBinary] **/
139
140      template <> // Chaîne de caractÚres.
141         void CAttributeTemplate<StdString>::toBinary (StdOStream & os) const;
142
143      template <> // Entier
144         void CAttributeTemplate<int>::toBinary(StdOStream & os) const;
145
146      template <> // Booléen
147         void CAttributeTemplate<bool>::toBinary(StdOStream & os) const;
148
149      //---------------------------------------------------------------
150
151      /** Spécialisations des templates pour la fonction [fromBinary] **/
152
153      template <> // Chaîne de caractÚres.
154         void CAttributeTemplate<StdString>::fromBinary(StdIStream & is);
155
156      template <> // Entier
157         void CAttributeTemplate<int>::fromBinary(StdIStream & is);
158
159      template <> // Booléen
160         void CAttributeTemplate<bool>::fromBinary(StdIStream & is);
161
162      ///--------------------------------------------------------------
163   } // namespace tree
164} // namespace xmlioserver
165
166#endif // __XMLIO_CAttributeTemplate_impl__
Note: See TracBrowser for help on using the repository browser.