1 | #ifndef __XMLIO_CAttribute__ |
---|
2 | #define __XMLIO_CAttribute__ |
---|
3 | |
---|
4 | /// boost headers /// |
---|
5 | #include <boost/any.hpp> |
---|
6 | |
---|
7 | /// xmlioserver headers /// |
---|
8 | #include "xmlioserver_spl.hpp" |
---|
9 | #include "object.hpp" |
---|
10 | |
---|
11 | namespace xmlioserver |
---|
12 | { |
---|
13 | namespace tree |
---|
14 | { |
---|
15 | /// ////////////////////// Déclarations ////////////////////// /// |
---|
16 | class CAttribute : public CObject |
---|
17 | { |
---|
18 | typedef CObject SuperClass; |
---|
19 | |
---|
20 | public : |
---|
21 | |
---|
22 | /// Constructeurs /// |
---|
23 | explicit CAttribute(const StdString & id); |
---|
24 | CAttribute(const CAttribute & attribut); |
---|
25 | CAttribute(const CAttribute * const attribut); // Not implemented. |
---|
26 | |
---|
27 | /// Accesseurs /// |
---|
28 | const StdString & getName(void) const; |
---|
29 | const boost::any & getAnyValue(void) const; |
---|
30 | template <typename T> inline T getValue(void) const; |
---|
31 | |
---|
32 | /// Mutateurs /// |
---|
33 | template <typename T> inline void setValue(const T & value); |
---|
34 | void setAnyValue(const boost::any & value); |
---|
35 | |
---|
36 | /// Test /// |
---|
37 | bool isEmpty(void) const; |
---|
38 | template <typename T> inline bool isType(void); |
---|
39 | |
---|
40 | /// Destructeur /// |
---|
41 | virtual ~CAttribute(void); |
---|
42 | |
---|
43 | /// Autres /// |
---|
44 | virtual StdString toString(void) const = 0; |
---|
45 | virtual void fromString(const StdString & str) = 0; |
---|
46 | |
---|
47 | virtual void toBinary (StdOStream & os) const = 0; |
---|
48 | virtual void fromBinary(StdIStream & is) = 0; |
---|
49 | |
---|
50 | protected : |
---|
51 | |
---|
52 | /// Constructeurs /// |
---|
53 | CAttribute(void); // Not implemented. |
---|
54 | |
---|
55 | private : |
---|
56 | |
---|
57 | /// Propriété /// |
---|
58 | boost::any value; |
---|
59 | |
---|
60 | }; // class CAttribute |
---|
61 | |
---|
62 | /// ////////////////////// Définitions ////////////////////// /// |
---|
63 | template <typename T> |
---|
64 | T CAttribute::getValue(void) const |
---|
65 | { return (boost::any_cast<T>(this->value)); } |
---|
66 | |
---|
67 | template <typename T> |
---|
68 | void CAttribute::setValue(const T & value) |
---|
69 | { this->value = value; } |
---|
70 | |
---|
71 | template<typename T> |
---|
72 | bool CAttribute::isType(void) |
---|
73 | { return (this->value.type() == typeid(T)); } |
---|
74 | |
---|
75 | } // namespace tree |
---|
76 | } // namespace xmlioserver |
---|
77 | |
---|
78 | #endif // __XMLIO_CAttribute__ |
---|