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 | |
---|
12 | namespace 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 | std::map<int, size_t> getMinimumBufferSizeForAttributes(); |
---|
57 | void sendAttributToServer(const string& id); |
---|
58 | void sendAttributToServer(CAttribute& attr) ; |
---|
59 | void sendAllAttributesToServer(); |
---|
60 | static void recvAttributFromClient(CEventServer& event) ; |
---|
61 | static bool dispatchEvent(CEventServer& event) ; |
---|
62 | |
---|
63 | /// Accesseur statique /// |
---|
64 | static std::vector<boost::shared_ptr<DerivedType> > & |
---|
65 | GetAllVectobject(const StdString & contextId); |
---|
66 | |
---|
67 | /// Destructeur /// |
---|
68 | virtual ~CObjectTemplate(void); |
---|
69 | |
---|
70 | static bool has(const string& id) ; |
---|
71 | static bool has(const string& contextId, const string& id) ; |
---|
72 | static T* get(const string& id) ; |
---|
73 | static T* get(const T* ptr) ; |
---|
74 | static T* get(const string& contextId, const string& id) ; |
---|
75 | T* get(void) ; |
---|
76 | shared_ptr<T> getShared(void) ; |
---|
77 | static shared_ptr<T> getShared(const T* ptr) ; |
---|
78 | |
---|
79 | static T* create(const string& id=string("")) ; |
---|
80 | static const vector<T*> getAll() ; |
---|
81 | static const vector<T*> getAll(const string& contextId) ; |
---|
82 | |
---|
83 | void generateCInterface(ostream& oss) ; |
---|
84 | void generateFortran2003Interface(ostream& oss) ; |
---|
85 | void generateFortranInterface(ostream& oss) ; |
---|
86 | |
---|
87 | protected : |
---|
88 | |
---|
89 | /// Constructeurs /// |
---|
90 | CObjectTemplate(void); |
---|
91 | explicit CObjectTemplate(const StdString & id); |
---|
92 | CObjectTemplate(const CObjectTemplate<T> & object, |
---|
93 | bool withAttrList = true, bool withId = true); |
---|
94 | CObjectTemplate(const CObjectTemplate<T> * const object); // Not implemented. |
---|
95 | |
---|
96 | private : |
---|
97 | |
---|
98 | /// Propriétés statiques /// |
---|
99 | static xios_map<StdString, |
---|
100 | xios_map<StdString, |
---|
101 | boost::shared_ptr<DerivedType> > > AllMapObj; |
---|
102 | static xios_map<StdString, |
---|
103 | std::vector<boost::shared_ptr<DerivedType> > > AllVectObj; |
---|
104 | |
---|
105 | static xios_map< StdString, long int > GenId ; |
---|
106 | //#pragma omp threadprivate(AllMapObj, AllVectObj, GenId) |
---|
107 | |
---|
108 | }; // class CObjectTemplate |
---|
109 | } // namespace xios |
---|
110 | |
---|
111 | //#include "object_template_impl.hpp" |
---|
112 | |
---|
113 | #endif // __XIOS_CObjectTemplate__ |
---|