[98] | 1 | #ifndef __BASE_ATTRIBUT__ |
---|
| 2 | #define __BASE_ATTRIBUT__ |
---|
[79] | 3 | |
---|
[98] | 4 | using std::ostream; |
---|
| 5 | using namespace blitz ; |
---|
| 6 | |
---|
| 7 | |
---|
[104] | 8 | using XMLIOSERVER::XMLIOIncompatibleTypeException; |
---|
[98] | 9 | |
---|
| 10 | namespace XMLIOSERVER |
---|
[79] | 11 | { |
---|
[98] | 12 | class BaseAttribut |
---|
| 13 | { |
---|
[104] | 14 | public: |
---|
[108] | 15 | |
---|
| 16 | virtual string getName(void) const = 0 ; |
---|
[104] | 17 | virtual ostream & print(ostream& o) const = 0 ; |
---|
[108] | 18 | |
---|
[113] | 19 | friend ostream& operator <<(ostream& o,const BaseAttribut& Attr) { return (Attr.print(o)) ; } |
---|
[108] | 20 | |
---|
[113] | 21 | bool hasId(void) const { return (true); } |
---|
[108] | 22 | |
---|
[113] | 23 | virtual string getId(void) const { return (getName()); } ; |
---|
[79] | 24 | |
---|
[113] | 25 | virtual void assignValue(const BaseAttribut*) = 0; |
---|
[104] | 26 | virtual void setFromString(const std::string str) = 0; |
---|
[113] | 27 | virtual bool _hasValue() const = 0; |
---|
[108] | 28 | |
---|
[104] | 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() ; } |
---|
[108] | 38 | |
---|
[104] | 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) |
---|
[108] | 44 | |
---|
[104] | 45 | #undef SETTER_AND_GETTER |
---|
[79] | 46 | |
---|
[104] | 47 | static void error_set(void) |
---|
| 48 | { throw XMLIOIncompatibleTypeException("BaseAttribut::set<type> > Setting value type is incompatible with attribut type"); } |
---|
| 49 | |
---|
| 50 | static void error_get(void) |
---|
| 51 | { throw XMLIOIncompatibleTypeException("BaseAttribut::set<type> >Getting value type is incompatible with attribut type"); } |
---|
[108] | 52 | |
---|
[98] | 53 | }; //class BaseAttribut |
---|
| 54 | } // namespace XMLIOSERVER |
---|
[79] | 55 | |
---|
[98] | 56 | #endif //__BASE_ATTRIBUT__ |
---|
[108] | 57 | |
---|
[114] | 58 | |
---|
| 59 | |
---|
| 60 | |
---|