1 | #ifndef __BASE_ATTRIBUT__ |
---|
2 | #define __BASE_ATTRIBUT__ |
---|
3 | |
---|
4 | using std::ostream; |
---|
5 | using namespace blitz ; |
---|
6 | |
---|
7 | |
---|
8 | using XMLIOSERVER::XMLIOIncompatibleTypeException; |
---|
9 | |
---|
10 | namespace XMLIOSERVER |
---|
11 | { |
---|
12 | class BaseAttribut |
---|
13 | { |
---|
14 | public: |
---|
15 | |
---|
16 | virtual string getName(void) const = 0 ; |
---|
17 | virtual ostream & print(ostream& o) const = 0 ; |
---|
18 | |
---|
19 | friend ostream& operator <<(ostream& o,const BaseAttribut& Attr) { return (Attr.print(o)) ; } |
---|
20 | |
---|
21 | bool hasId(void) const { return (true); } |
---|
22 | |
---|
23 | virtual string getId(void) const { return (getName()); } ; |
---|
24 | |
---|
25 | virtual void assignValue(const BaseAttribut*) = 0; |
---|
26 | virtual void setFromString(const std::string&) = 0; |
---|
27 | virtual bool hasValue() const = 0; |
---|
28 | |
---|
29 | #define SETTER_AND_GETTER(TYPE) \ |
---|
30 | virtual void setValue(const TYPE & value) { error_set() ; }\ |
---|
31 | virtual void setValue(const Array<TYPE,1>& value) { error_set() ; }\ |
---|
32 | virtual void setValue(const Array<TYPE,2>& value) { error_set() ; }\ |
---|
33 | virtual void setValue(const Array<TYPE,3>& value) { error_set() ; }\ |
---|
34 | virtual void setValue(const Array<TYPE,4>& value) { error_set() ; }\ |
---|
35 | virtual void getValue(TYPE & value) const { error_get() ; }\ |
---|
36 | virtual void getValue(Array<TYPE,1>& value) const { error_get() ; }\ |
---|
37 | virtual void getValue(Array<TYPE,2>& value) const { error_get() ; }\ |
---|
38 | virtual void getValue(Array<TYPE,3>& value) const { error_get() ; }\ |
---|
39 | virtual void getValue(Array<TYPE,4>& value) const { error_get() ; } |
---|
40 | |
---|
41 | SETTER_AND_GETTER(int) |
---|
42 | SETTER_AND_GETTER(bool) |
---|
43 | SETTER_AND_GETTER(double) |
---|
44 | SETTER_AND_GETTER(char) |
---|
45 | SETTER_AND_GETTER(string) |
---|
46 | |
---|
47 | #undef SETTER_AND_GETTER |
---|
48 | |
---|
49 | static void error_set(void) |
---|
50 | { throw XMLIOIncompatibleTypeException("BaseAttribut::set<type> > Setting value type is incompatible with attribut type"); } |
---|
51 | |
---|
52 | static void error_get(void) |
---|
53 | { throw XMLIOIncompatibleTypeException("BaseAttribut::set<type> >Getting value type is incompatible with attribut type"); } |
---|
54 | |
---|
55 | }; //class BaseAttribut |
---|
56 | } // namespace XMLIOSERVER |
---|
57 | |
---|
58 | #endif //__BASE_ATTRIBUT__ |
---|
59 | |
---|
60 | |
---|
61 | |
---|
62 | |
---|