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

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