1 | #ifndef __XIOS_CAttributeTemplate__ |
---|
2 | #define __XIOS_CAttributeTemplate__ |
---|
3 | |
---|
4 | /// boost headers /// |
---|
5 | #include <boost/lexical_cast.hpp> |
---|
6 | |
---|
7 | /// XIOS headers /// |
---|
8 | #include "xios_spl.hpp" |
---|
9 | #include "exception.hpp" |
---|
10 | #include "attribute.hpp" |
---|
11 | #include "buffer_in.hpp" |
---|
12 | #include "buffer_out.hpp" |
---|
13 | #include "type.hpp" |
---|
14 | |
---|
15 | namespace xios |
---|
16 | { |
---|
17 | /// ////////////////////// Déclarations ////////////////////// /// |
---|
18 | /*! |
---|
19 | \class CAttributeTemplate |
---|
20 | The class implements attribute of some basic types |
---|
21 | */ |
---|
22 | template <class T> |
---|
23 | class CAttributeTemplate : public CAttribute, public CType<T> |
---|
24 | { |
---|
25 | typedef CAttribute SuperClass; |
---|
26 | |
---|
27 | public : |
---|
28 | |
---|
29 | /// Typedef /// |
---|
30 | typedef T ValueType; |
---|
31 | |
---|
32 | /// Constructeurs /// |
---|
33 | explicit CAttributeTemplate(const StdString & id); |
---|
34 | CAttributeTemplate(const StdString & id, |
---|
35 | xios_map<StdString, CAttribute*> & umap); |
---|
36 | CAttributeTemplate(const StdString & id, const ValueType & value); |
---|
37 | CAttributeTemplate(const StdString & id, const ValueType & value, |
---|
38 | xios_map<StdString, CAttribute*> & umap); |
---|
39 | // CAttributeTemplate(const CAttribute & attribut) throw (CException); |
---|
40 | // CAttributeTemplate(const CAttribute * const attribut); // Not implemented. |
---|
41 | |
---|
42 | public : |
---|
43 | |
---|
44 | /// Accesseur /// |
---|
45 | ValueType getValue(void) const; |
---|
46 | // ValueType* getRef(void) ; |
---|
47 | |
---|
48 | /// Mutateurs /// |
---|
49 | void setValue(const ValueType & value); |
---|
50 | |
---|
51 | void set(const CAttribute& attr) ; |
---|
52 | void set(const CAttributeTemplate& attr) ; |
---|
53 | void reset(void) ; |
---|
54 | void checkEmpty(void) const; |
---|
55 | |
---|
56 | void setInheritedValue(const CAttributeTemplate& attr ); |
---|
57 | void setInheritedValue(const CAttribute& attr ); |
---|
58 | T getInheritedValue(void) const ; |
---|
59 | bool hasInheritedValue(void) const; |
---|
60 | |
---|
61 | bool isEqual(const CAttribute& attr ); |
---|
62 | |
---|
63 | /// Destructeur /// |
---|
64 | virtual ~CAttributeTemplate(void) { } |
---|
65 | |
---|
66 | /// Operateur /// |
---|
67 | CAttributeTemplate& operator=(const ValueType & value); |
---|
68 | |
---|
69 | /// Autre /// |
---|
70 | virtual StdString toString(void) const { return _toString();} |
---|
71 | virtual void fromString(const StdString & str) { if (str==resetInheritanceStr) { reset(); _canInherite=false ;} else _fromString(str);} |
---|
72 | // virtual CAttributeTemplate* clone() const {} |
---|
73 | // virtual void toBinary (StdOStream & os) const; |
---|
74 | // virtual void fromBinary(StdIStream & is); |
---|
75 | virtual StdString dump(void) const { return _dump();} |
---|
76 | virtual StdString dump4graph(void) const { return _dump4graph();} |
---|
77 | |
---|
78 | virtual bool toBuffer (CBufferOut& buffer) const { return _toBuffer(buffer);} |
---|
79 | virtual bool fromBuffer(CBufferIn& buffer) { return _fromBuffer(buffer); } |
---|
80 | // virtual size_t size(void) const; |
---|
81 | virtual void generateCInterface(ostream& oss,const string& className) ; |
---|
82 | virtual void generateFortran2003Interface(ostream& oss,const string& className) ; |
---|
83 | virtual void generateFortranInterfaceDeclaration_(ostream& oss,const string& className) ; |
---|
84 | virtual void generateFortranInterfaceBody_(ostream& oss,const string& className) ; |
---|
85 | virtual void generateFortranInterfaceDeclaration(ostream& oss,const string& className) ; |
---|
86 | virtual void generateFortranInterfaceGetDeclaration_(ostream& oss,const string& className) ; |
---|
87 | virtual void generateFortranInterfaceGetBody_(ostream& oss,const string& className) ; |
---|
88 | virtual void generateFortranInterfaceGetDeclaration(ostream& oss,const string& className) ; |
---|
89 | // virtual void generateFortranInterfaceIsDefinedDeclaration_(ostream& oss,const string& className) ; |
---|
90 | // virtual void generateFortranInterfaceIsDefinedBody_(ostream& oss,const string& className) ; |
---|
91 | // virtual void generateFortranInterfaceIsDefinedDeclaration(ostream& oss,const string& className) ; |
---|
92 | |
---|
93 | |
---|
94 | protected : |
---|
95 | |
---|
96 | /// Constructeurs /// |
---|
97 | // CAttributeTemplate(void); // Not implemented. |
---|
98 | private : |
---|
99 | bool isEqual_(const CAttributeTemplate& attr); |
---|
100 | StdString _toString(void) const; |
---|
101 | StdString _dump(void) const; |
---|
102 | StdString _dump4graph(void) const; |
---|
103 | void _fromString(const StdString & str); |
---|
104 | bool _toBuffer (CBufferOut& buffer) const; |
---|
105 | bool _fromBuffer(CBufferIn& buffer) ; |
---|
106 | |
---|
107 | CType<T> inheritedValue ; |
---|
108 | }; // class CAttribute |
---|
109 | |
---|
110 | |
---|
111 | template <class T> void FromBinary(StdIStream & is, T & obj); |
---|
112 | |
---|
113 | } // namespace xios |
---|
114 | |
---|
115 | #endif // __XIOS_CAttributeTemplate__ |
---|