1 | #ifndef __XMLIO_CContext__ |
---|
2 | #define __XMLIO_CContext__ |
---|
3 | |
---|
4 | /// xios headers /// |
---|
5 | #include "xmlioserver_spl.hpp" |
---|
6 | //#include "node_type.hpp" |
---|
7 | #include "calendar.hpp" |
---|
8 | |
---|
9 | #include "declare_group.hpp" |
---|
10 | //#include "context_client.hpp" |
---|
11 | //#include "context_server.hpp" |
---|
12 | #include "data_output.hpp" |
---|
13 | |
---|
14 | #include <mpi.h> |
---|
15 | |
---|
16 | |
---|
17 | namespace xios { |
---|
18 | class CContextClient ; |
---|
19 | class CContextServer ; |
---|
20 | |
---|
21 | |
---|
22 | /// ////////////////////// Déclarations ////////////////////// /// |
---|
23 | class CContextGroup; |
---|
24 | class CContextAttributes; |
---|
25 | class CContext; |
---|
26 | class CFile; |
---|
27 | ///-------------------------------------------------------------- |
---|
28 | |
---|
29 | // Declare/Define CFileAttribute |
---|
30 | BEGIN_DECLARE_ATTRIBUTE_MAP(CContext) |
---|
31 | # include "context_attribute.conf" |
---|
32 | END_DECLARE_ATTRIBUTE_MAP(CContext) |
---|
33 | |
---|
34 | ///-------------------------------------------------------------- |
---|
35 | |
---|
36 | class CContext |
---|
37 | : public CObjectTemplate<CContext> |
---|
38 | , public CContextAttributes |
---|
39 | { |
---|
40 | public : |
---|
41 | enum EEventId |
---|
42 | { |
---|
43 | EVENT_ID_CLOSE_DEFINITION,EVENT_ID_UPDATE_CALENDAR, |
---|
44 | EVENT_ID_CREATE_FILE_HEADER,EVENT_ID_CONTEXT_FINALIZE |
---|
45 | } ; |
---|
46 | |
---|
47 | /// typedef /// |
---|
48 | typedef CObjectTemplate<CContext> SuperClass; |
---|
49 | typedef CContextAttributes SuperClassAttribute; |
---|
50 | |
---|
51 | public : |
---|
52 | |
---|
53 | typedef CContextAttributes RelAttributes; |
---|
54 | typedef CContext RelGroup; |
---|
55 | |
---|
56 | //--------------------------------------------------------- |
---|
57 | |
---|
58 | public : |
---|
59 | |
---|
60 | /// Constructeurs /// |
---|
61 | CContext(void); |
---|
62 | explicit CContext(const StdString & id); |
---|
63 | CContext(const CContext & context); // Not implemented yet. |
---|
64 | CContext(const CContext * const context); // Not implemented yet. |
---|
65 | |
---|
66 | /// Destructeur /// |
---|
67 | virtual ~CContext(void); |
---|
68 | |
---|
69 | //--------------------------------------------------------- |
---|
70 | |
---|
71 | public : |
---|
72 | |
---|
73 | /// Mutateurs /// |
---|
74 | void setCalendar(boost::shared_ptr<CCalendar> newCalendar); |
---|
75 | |
---|
76 | /// Accesseurs /// |
---|
77 | boost::shared_ptr<CCalendar> getCalendar(void) const; |
---|
78 | |
---|
79 | /// Accesseurs statiques /// |
---|
80 | static StdString GetName(void); |
---|
81 | static StdString GetDefName(void); |
---|
82 | static ENodeType GetType(void); |
---|
83 | |
---|
84 | static CContextGroup* GetContextGroup(void); |
---|
85 | |
---|
86 | public : |
---|
87 | |
---|
88 | /// Traitements /// |
---|
89 | virtual void solveDescInheritance(const CAttributeMap * const parent = 0); |
---|
90 | void solveFieldRefInheritance(void); |
---|
91 | void solveCalendar(void); |
---|
92 | |
---|
93 | /// Autres méthodes statiques /// |
---|
94 | static void ShowTree(StdOStream & out = std::clog); |
---|
95 | static void CleanTree(void); |
---|
96 | |
---|
97 | /// Test /// |
---|
98 | virtual bool hasChild(void) const; |
---|
99 | |
---|
100 | bool eventLoop(void) ; |
---|
101 | bool serverLoop(void) ; |
---|
102 | void clientLoop(void) ; |
---|
103 | void initServer(MPI_Comm intraComm, MPI_Comm interComm) ; |
---|
104 | void initClient(MPI_Comm intraComm, MPI_Comm interComm) ; |
---|
105 | CContextServer* server ; |
---|
106 | CContextClient* client ; |
---|
107 | bool hasClient ; |
---|
108 | bool hasServer ; |
---|
109 | void finalize(void) ; |
---|
110 | void closeDefinition(void) ; |
---|
111 | void findAllEnabledFields(void); |
---|
112 | void solveAllGridRef(void); |
---|
113 | void solveAllOperation(void); |
---|
114 | void solveAllInheritance(void) ; |
---|
115 | void findEnabledFiles(void); |
---|
116 | void closeAllFile(void) ; |
---|
117 | void updateCalendar(int step) ; |
---|
118 | void createFileHeader(void ) ; |
---|
119 | // dispatch event |
---|
120 | static bool dispatchEvent(CEventServer& event) ; |
---|
121 | void sendCloseDefinition(void) ; |
---|
122 | void sendUpdateCalendar(int step) ; |
---|
123 | void sendCreateFileHeader(void) ; |
---|
124 | static void recvUpdateCalendar(CEventServer& event) ; |
---|
125 | void recvUpdateCalendar(CBufferIn& buffer) ; |
---|
126 | static void recvCloseDefinition(CEventServer& event) ; |
---|
127 | static void recvCreateFileHeader(CEventServer& event) ; |
---|
128 | void recvCreateFileHeader(CBufferIn& buffer) ; |
---|
129 | static CContext* getCurrent(void) ; |
---|
130 | static CContextGroup* getRoot(void) ; |
---|
131 | static void setCurrent(const string& id) ; |
---|
132 | static CContext* create(const string& id = "") ; |
---|
133 | |
---|
134 | public : |
---|
135 | |
---|
136 | /// Autres /// |
---|
137 | virtual void parse(xml::CXMLNode & node); |
---|
138 | |
---|
139 | virtual StdString toString(void) const; |
---|
140 | virtual void toBinary (StdOStream & os) const; |
---|
141 | virtual void fromBinary(StdIStream & is); |
---|
142 | |
---|
143 | public : |
---|
144 | |
---|
145 | boost::shared_ptr<CCalendar> calendar; |
---|
146 | |
---|
147 | std::vector<CFile*> enabledFiles; |
---|
148 | static shared_ptr<CContextGroup> root ; |
---|
149 | |
---|
150 | |
---|
151 | }; // class CContext |
---|
152 | |
---|
153 | ///-------------------------------------------------------------- |
---|
154 | |
---|
155 | // Declare/Define CContextGroup and CContextDefinition |
---|
156 | DECLARE_GROUP(CContext); |
---|
157 | |
---|
158 | ///-------------------------------------------------------------- |
---|
159 | |
---|
160 | } // namespace xios |
---|
161 | |
---|
162 | #endif // __XMLIO_CContext__ |
---|