source: XIOS/dev/dev_olga/src/object_template.hpp @ 1132

Last change on this file since 1132 was 1021, checked in by oabramkina, 7 years ago

Intermeadiate version for merging with new server functionalities.

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