[219] | 1 | #ifndef __XMLIO_CContext__ |
---|
| 2 | #define __XMLIO_CContext__ |
---|
| 3 | |
---|
[335] | 4 | /// xios headers /// |
---|
[219] | 5 | #include "xmlioserver_spl.hpp" |
---|
[352] | 6 | //#include "node_type.hpp" |
---|
[219] | 7 | #include "calendar.hpp" |
---|
| 8 | |
---|
| 9 | #include "declare_group.hpp" |
---|
[300] | 10 | //#include "context_client.hpp" |
---|
| 11 | //#include "context_server.hpp" |
---|
| 12 | #include "data_output.hpp" |
---|
[219] | 13 | |
---|
[382] | 14 | #include "mpi.hpp" |
---|
[300] | 15 | |
---|
[799] | 16 | #include "registry.hpp" |
---|
[219] | 17 | |
---|
[799] | 18 | |
---|
[335] | 19 | namespace xios { |
---|
[300] | 20 | class CContextClient ; |
---|
| 21 | class CContextServer ; |
---|
| 22 | |
---|
[219] | 23 | |
---|
| 24 | /// ////////////////////// Déclarations ////////////////////// /// |
---|
| 25 | class CContextGroup; |
---|
| 26 | class CContextAttributes; |
---|
| 27 | class CContext; |
---|
[352] | 28 | class CFile; |
---|
[219] | 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 | { |
---|
[300] | 42 | public : |
---|
| 43 | enum EEventId |
---|
| 44 | { |
---|
| 45 | EVENT_ID_CLOSE_DEFINITION,EVENT_ID_UPDATE_CALENDAR, |
---|
[799] | 46 | EVENT_ID_CREATE_FILE_HEADER,EVENT_ID_CONTEXT_FINALIZE, |
---|
| 47 | EVENT_ID_SEND_REGISTRY |
---|
[300] | 48 | } ; |
---|
| 49 | |
---|
[219] | 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 /// |
---|
[343] | 77 | void setCalendar(boost::shared_ptr<CCalendar> newCalendar); |
---|
[219] | 78 | |
---|
| 79 | /// Accesseurs /// |
---|
[343] | 80 | boost::shared_ptr<CCalendar> getCalendar(void) const; |
---|
[219] | 81 | |
---|
| 82 | /// Accesseurs statiques /// |
---|
| 83 | static StdString GetName(void); |
---|
| 84 | static StdString GetDefName(void); |
---|
| 85 | static ENodeType GetType(void); |
---|
| 86 | |
---|
[347] | 87 | static CContextGroup* GetContextGroup(void); |
---|
[219] | 88 | |
---|
| 89 | public : |
---|
| 90 | |
---|
| 91 | /// Traitements /// |
---|
[445] | 92 | virtual void solveDescInheritance(bool apply, const CAttributeMap * const parent = 0); |
---|
| 93 | void solveFieldRefInheritance(bool apply); |
---|
[219] | 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; |
---|
[300] | 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) ; |
---|
[461] | 108 | bool isInitialized(void) ; |
---|
[300] | 109 | CContextServer* server ; |
---|
| 110 | CContextClient* client ; |
---|
| 111 | bool hasClient ; |
---|
| 112 | bool hasServer ; |
---|
| 113 | void finalize(void) ; |
---|
| 114 | void closeDefinition(void) ; |
---|
| 115 | void findAllEnabledFields(void); |
---|
[459] | 116 | void processEnabledFiles(void) ; |
---|
[300] | 117 | void solveAllGridRef(void); |
---|
| 118 | void solveAllOperation(void); |
---|
[459] | 119 | void solveAllExpression(void); |
---|
[445] | 120 | void solveAllInheritance(bool apply=true) ; |
---|
[300] | 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) ; |
---|
[799] | 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 |
---|
[300] | 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) ; |
---|
[799] | 136 | static void recvRegistry(CEventServer& event) ; |
---|
| 137 | void recvRegistry(CBufferIn& buffer) ; //!< registry is received by the root process of the servers |
---|
[347] | 138 | static CContext* getCurrent(void) ; |
---|
| 139 | static CContextGroup* getRoot(void) ; |
---|
[346] | 140 | static void setCurrent(const string& id) ; |
---|
[347] | 141 | static CContext* create(const string& id = "") ; |
---|
[219] | 142 | |
---|
| 143 | public : |
---|
| 144 | |
---|
| 145 | /// Autres /// |
---|
| 146 | virtual void parse(xml::CXMLNode & node); |
---|
| 147 | |
---|
| 148 | virtual StdString toString(void) const; |
---|
[369] | 149 | // virtual void toBinary (StdOStream & os) const; |
---|
| 150 | // virtual void fromBinary(StdIStream & is); |
---|
[219] | 151 | |
---|
[300] | 152 | public : |
---|
[219] | 153 | |
---|
[343] | 154 | boost::shared_ptr<CCalendar> calendar; |
---|
[300] | 155 | |
---|
[347] | 156 | std::vector<CFile*> enabledFiles; |
---|
[346] | 157 | static shared_ptr<CContextGroup> root ; |
---|
[219] | 158 | |
---|
[799] | 159 | CRegistry* registryIn ; //!< input registry which is read from file |
---|
| 160 | CRegistry* registryOut ; //!< output registry which will be wrote on file at the finalize |
---|
[219] | 161 | }; // class CContext |
---|
| 162 | |
---|
| 163 | ///-------------------------------------------------------------- |
---|
| 164 | |
---|
| 165 | // Declare/Define CContextGroup and CContextDefinition |
---|
| 166 | DECLARE_GROUP(CContext); |
---|
| 167 | |
---|
| 168 | ///-------------------------------------------------------------- |
---|
| 169 | |
---|
[335] | 170 | } // namespace xios |
---|
[219] | 171 | |
---|
| 172 | #endif // __XMLIO_CContext__ |
---|