source: XMLIO_V2/dev/dev_rv/src/XMLIO/base_attribut.hpp @ 120

Last change on this file since 120 was 120, checked in by hozdoba, 14 years ago

Mise à jour intermédiaire ...
A venir : commit d'une version stable intégrant l'écriture de fichiers NetCDF4.
(en cours de finalisation actuellement)

File size: 2.1 KB
Line 
1#ifndef __BASE_ATTRIBUT__
2#define __BASE_ATTRIBUT__
3
4using std::ostream;
5using namespace blitz ;
6
7
8using XMLIOSERVER::XMLIOIncompatibleTypeException;
9
10namespace 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
Note: See TracBrowser for help on using the repository browser.