source: XIOS/trunk/src/attribute_template.hpp @ 1112

Last change on this file since 1112 was 1112, checked in by ymipsl, 7 years ago

For xml : if attribute get the string value of "_reset_", attribute will be empty and the attribute will remain empty after inheritance.

YM

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
File size: 4.3 KB
Line 
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
15namespace xios
16{
17      /// ////////////////////// Déclarations ////////////////////// ///
18      template <class T>
19         class CAttributeTemplate : public CAttribute, public CType<T>
20      {
21            typedef CAttribute SuperClass;
22
23         public :
24
25            /// Typedef ///
26            typedef T ValueType;
27
28            /// Constructeurs ///
29            explicit CAttributeTemplate(const StdString & id);
30            CAttributeTemplate(const StdString & id,
31                               xios_map<StdString, CAttribute*> & umap);
32            CAttributeTemplate(const StdString & id, const ValueType & value);
33            CAttributeTemplate(const StdString & id, const ValueType & value,
34                               xios_map<StdString, CAttribute*> & umap);
35//            CAttributeTemplate(const CAttribute & attribut) throw (CException);
36//            CAttributeTemplate(const CAttribute * const attribut); // Not implemented.
37
38          public :
39
40            /// Accesseur ///
41            ValueType getValue(void) const;
42//            ValueType* getRef(void) ;
43
44            /// Mutateurs ///
45            void setValue(const ValueType & value);
46
47            void set(const CAttribute& attr) ;
48            void set(const CAttributeTemplate& attr) ;
49            void reset(void) ;
50
51            void setInheritedValue(const CAttributeTemplate& attr );
52            void setInheritedValue(const CAttribute& attr );
53            T getInheritedValue(void) const ;
54            bool hasInheritedValue(void) const;
55
56            bool isEqual(const CAttributeTemplate& attr );
57            bool isEqual(const CAttribute& attr );
58           
59            /// Destructeur ///
60            virtual ~CAttributeTemplate(void) { }
61
62            /// Operateur ///
63            CAttributeTemplate& operator=(const ValueType & value);
64
65            /// Autre ///
66            virtual StdString toString(void) const { return _toString();}
67            virtual void fromString(const StdString & str) { if (str==resetInheritanceStr) { reset(); _canInherite=false ;}  else _fromString(str);}
68//            virtual CAttributeTemplate* clone() const {}
69//            virtual void toBinary  (StdOStream & os) const;
70//            virtual void fromBinary(StdIStream & is);
71
72            virtual bool toBuffer  (CBufferOut& buffer) const { return _toBuffer(buffer);}
73            virtual bool fromBuffer(CBufferIn& buffer) { return _fromBuffer(buffer); }
74//            virtual size_t size(void) const;
75            virtual void generateCInterface(ostream& oss,const string& className) ;
76            virtual void generateFortran2003Interface(ostream& oss,const string& className) ;
77            virtual void generateFortranInterfaceDeclaration_(ostream& oss,const string& className) ;
78            virtual void generateFortranInterfaceBody_(ostream& oss,const string& className) ;
79            virtual void generateFortranInterfaceDeclaration(ostream& oss,const string& className) ;
80            virtual void generateFortranInterfaceGetDeclaration_(ostream& oss,const string& className) ;
81            virtual void generateFortranInterfaceGetBody_(ostream& oss,const string& className) ;
82            virtual void generateFortranInterfaceGetDeclaration(ostream& oss,const string& className) ;
83//            virtual void generateFortranInterfaceIsDefinedDeclaration_(ostream& oss,const string& className) ;
84//            virtual void generateFortranInterfaceIsDefinedBody_(ostream& oss,const string& className) ;
85//            virtual void generateFortranInterfaceIsDefinedDeclaration(ostream& oss,const string& className) ;
86
87
88         protected :
89
90            /// Constructeurs ///
91//            CAttributeTemplate(void); // Not implemented.
92         private :
93          StdString _toString(void) const;
94          void _fromString(const StdString & str);
95          bool _toBuffer  (CBufferOut& buffer) const;
96          bool _fromBuffer(CBufferIn& buffer) ;
97
98          CType<T> inheritedValue ;
99      }; // class CAttribute
100
101
102   template <class T>  void FromBinary(StdIStream & is, T & obj);
103
104} // namespace xios
105
106#endif // __XIOS_CAttributeTemplate__
Note: See TracBrowser for help on using the repository browser.