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