source: XIOS/trunk/src/attribute.hpp @ 432

Last change on this file since 432 was 432, checked in by ymipsl, 11 years ago

Enhancement : Add fortran interface to know if an attribute is set or not
ex : CALL xios_is_defined_field_attr("field_A",enabled=ok)

YM

File size: 4.1 KB
Line 
1#ifndef __XMLIO_CAttribute__
2#define __XMLIO_CAttribute__
3
4/// boost headers ///
5#include <boost/any.hpp>
6
7/// xios headers ///
8#include "xmlioserver_spl.hpp"
9#include "object.hpp"
10#include "base_type.hpp"
11#include "message.hpp"
12#include "buffer_in.hpp"
13#include "buffer_out.hpp"
14
15namespace xios
16{
17      /// ////////////////////// Déclarations ////////////////////// ///
18      class CAttribute : public CObject, public virtual CBaseType
19      {
20            typedef CObject SuperClass;
21
22         public :
23
24            /// Constructeurs ///
25            explicit CAttribute(const StdString & id);
26//            CAttribute(const CAttribute & attribut);
27//            CAttribute(const CAttribute * const attribut); // Not implemented.
28
29            /// Accesseurs ///
30            const StdString & getName(void) const;
31//            const boost::any & getAnyValue(void) const;
32//            template <typename T> inline T getValue(void) const;
33//            template <typename T> inline T* getRef(void);
34
35//            /// Mutateurs ///
36//            template <typename T> inline void setValue(const T & value);
37//            void setAnyValue(const boost::any & value);
38//            void clear(void);
39
40            /// Test ///
41//            bool isEmpty(void) const;
42//            template <typename T> inline bool isType(void) const;
43            virtual void set(const CAttribute& ) =0 ;
44            /// Destructeur ///
45            virtual ~CAttribute(void);
46
47            /// Autres ///
48            virtual StdString toString(void) const = 0;
49            virtual void fromString(const StdString & str) = 0;
50
51//            virtual void toBinary  (StdOStream & os) const = 0;
52//            virtual void fromBinary(StdIStream & is) = 0;
53
54            virtual void generateCInterface(ostream& oss, const string& className) = 0 ;
55            virtual void generateCInterfaceIsDefined(ostream& oss, const string& className) ;
56            virtual void generateFortran2003Interface(ostream& oss, const string& className) = 0 ;
57            virtual void generateFortran2003InterfaceIsDefined(ostream& oss, const string& className) ;
58            virtual void generateFortranInterfaceDeclaration_(ostream& oss,const string& className) = 0 ;
59            virtual void generateFortranInterfaceDeclaration(ostream& oss,const string& className) = 0 ;
60            virtual void generateFortranInterfaceBody_(ostream& oss,const string& className) = 0 ;
61            virtual void generateFortranInterfaceGetDeclaration_(ostream& oss,const string& className) = 0 ;
62            virtual void generateFortranInterfaceGetDeclaration(ostream& oss,const string& className) = 0 ;
63            virtual void generateFortranInterfaceGetBody_(ostream& oss,const string& className) = 0 ;
64            virtual void generateFortranInterfaceIsDefinedDeclaration_(ostream& oss,const string& className) ;
65            virtual void generateFortranInterfaceIsDefinedDeclaration(ostream& oss,const string& className)  ;
66            virtual void generateFortranInterfaceIsDefinedBody_(ostream& oss,const string& className) ;
67
68
69           
70         protected :
71
72            /// Constructeurs ///
73//            CAttribute(void);  // Not implemented.
74
75            /// Propriété ///
76//            boost::any value;
77
78      }; // class CAttribute
79
80      /// ////////////////////// Définitions ////////////////////// ///
81/*
82      template <typename T>
83         T CAttribute::getValue(void) const
84      {
85         return (boost::any_cast<T>(this->value));
86      }
87
88      template <typename T>
89         T* CAttribute::getRef(void)
90      {
91         return (boost::any_cast<T>(&value));
92      }
93
94      template <typename T>
95         void CAttribute::setValue(const T & value)
96      {
97         this->value = value;
98      }
99
100      template<typename T>
101         bool CAttribute::isType(void) const
102      {
103         return (this->value.type() == typeid(T));
104      }
105*/
106 
107   CMessage& operator<<(CMessage& msg,CAttribute& type) ;
108   CMessage& operator<<(CMessage& msg, const CAttribute&  type) ;
109 
110   CBufferOut& operator<<(CBufferOut& buffer,CAttribute& type) ;
111   CBufferIn& operator>>(CBufferIn& buffer, CAttribute&  type) ;
112
113}
114  // namespace xios
115
116#endif // __XMLIO_CAttribute__
Note: See TracBrowser for help on using the repository browser.