source: XIOS/trunk/src/object_template.hpp @ 470

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

Add possibility to make inheritance of attributes and reference before closing the context definition.
New fortran fonction : xios_solve inheritance()
After this call, the value of attribute have the inherited value of their parent.

YM

File size: 3.5 KB
Line 
1#ifndef __XMLIO_CObjectTemplate__
2#define __XMLIO_CObjectTemplate__
3
4/// xios headers ///
5#include "xmlioserver_spl.hpp"
6#include "attribute_map.hpp"
7#include "node_enum.hpp"
8#include "buffer_in.hpp"
9#include "event_server.hpp"
10#include "attribute.hpp"
11
12namespace xios
13{
14   /// ////////////////////// Déclarations ////////////////////// ///
15   template <class T>
16      class CObjectTemplate
17         : public CObject
18         , public virtual CAttributeMap
19   {
20
21         /// Friend ///
22         friend class CObjectFactory;
23
24         /// Typedef ///
25         typedef CAttributeMap SuperClassMap;
26         typedef CObject SuperClass;
27         typedef T DerivedType;
28         
29         enum EEventId
30         {
31           EVENT_ID_SEND_ATTRIBUTE=100
32         } ;
33
34      public :
35
36         /// Autres ///
37         virtual StdString toString(void) const;
38         virtual void fromString(const StdString & str);
39
40//         virtual void toBinary  (StdOStream & os) const;
41//         virtual void fromBinary(StdIStream & is);
42         virtual string getName(void) const ;
43         virtual void parse(xml::CXMLNode & node);
44         
45         /// Accesseurs ///
46         ENodeType getType(void) const;
47
48         /// Test ///
49         virtual bool hasChild(void) const;
50
51         /// Traitements ///
52         virtual void solveDescInheritance(bool apply, const CAttributeMap * const parent = 0);
53
54         /// Traitement statique ///
55         static void ClearAllAttributes(void);
56         void sendAttributToServer(const string& id);
57         void sendAttributToServer(CAttribute& attr) ;
58         static void recvAttributFromClient(CEventServer& event) ;
59         static bool dispatchEvent(CEventServer& event) ;
60
61         /// Accesseur statique ///
62         static std::vector<boost::shared_ptr<DerivedType> > &
63            GetAllVectobject(const StdString & contextId);
64
65         /// Destructeur ///
66         virtual ~CObjectTemplate(void);
67         
68         static bool has(const string& id) ;
69         static bool has(const string& contextId, const string& id) ;
70         static T* get(const string& id) ;
71         static T* get(const T* ptr) ;
72         static T* get(const string& contextId, const string& id) ;
73         T* get(void) ;
74         shared_ptr<T> getShared(void) ;
75         static shared_ptr<T> getShared(const T* ptr) ;
76         
77         static T* create(const string& id=string("")) ;
78         static const vector<T*> getAll() ;
79         static const vector<T*> getAll(const string& contextId) ;
80       
81         void generateCInterface(ostream& oss) ;
82         void generateFortran2003Interface(ostream& oss) ;
83         void generateFortranInterface(ostream& oss) ;
84         
85      protected :
86
87         /// Constructeurs ///
88         CObjectTemplate(void);
89         explicit CObjectTemplate(const StdString & id);
90         CObjectTemplate(const CObjectTemplate<T> & object,
91                         bool withAttrList = true, bool withId = true);
92         CObjectTemplate(const CObjectTemplate<T> * const object); // Not implemented.
93
94      private :
95
96         /// Propriétés statiques ///
97         static xios_map<StdString,
98                xios_map<StdString,
99                boost::shared_ptr<DerivedType> > > AllMapObj; 
100         static xios_map<StdString,
101                std::vector<boost::shared_ptr<DerivedType> > > AllVectObj;
102               
103         static xios_map< StdString, long int > GenId ;
104
105   }; // class CObjectTemplate
106} // namespace xios
107
108//#include "object_template_impl.hpp"
109
110#endif // __XMLIO_CObjectTemplate__
Note: See TracBrowser for help on using the repository browser.