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) |
---|
20 | {return Attr.print(o) ; } |
---|
21 | |
---|
22 | virtual void assignValue(const BaseAttribut*) = 0; |
---|
23 | |
---|
24 | virtual string getId(void) const {return getName();} ; |
---|
25 | bool hasId(void){return (true);} |
---|
26 | |
---|
27 | virtual void setFromString(const std::string str) = 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 getValue(TYPE & value) const { error_get() ; }\ |
---|
35 | virtual void getValue(Array<TYPE,1>& value) const { error_get() ; }\ |
---|
36 | virtual void getValue(Array<TYPE,2>& value) const { error_get() ; }\ |
---|
37 | virtual void getValue(Array<TYPE,3>& value) const { error_get() ; } |
---|
38 | |
---|
39 | SETTER_AND_GETTER(int) |
---|
40 | SETTER_AND_GETTER(bool) |
---|
41 | SETTER_AND_GETTER(double) |
---|
42 | SETTER_AND_GETTER(char) |
---|
43 | SETTER_AND_GETTER(string) |
---|
44 | |
---|
45 | #undef SETTER_AND_GETTER |
---|
46 | |
---|
47 | |
---|
48 | virtual bool _hasValue() const = 0; |
---|
49 | |
---|
50 | static void error_set(void) |
---|
51 | { throw XMLIOIncompatibleTypeException("BaseAttribut::set<type> > Setting value type is incompatible with attribut type"); } |
---|
52 | |
---|
53 | static void error_get(void) |
---|
54 | { throw XMLIOIncompatibleTypeException("BaseAttribut::set<type> >Getting value type is incompatible with attribut type"); } |
---|
55 | |
---|
56 | }; //class BaseAttribut |
---|
57 | } // namespace XMLIOSERVER |
---|
58 | |
---|
59 | #endif //__BASE_ATTRIBUT__ |
---|
60 | |
---|