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