1 | #ifndef __SERVER_HPP__ |
---|
2 | #define __SERVER_HPP__ |
---|
3 | |
---|
4 | #include "xios_spl.hpp" |
---|
5 | #include "context.hpp" |
---|
6 | #include "context_client.hpp" |
---|
7 | #include "mpi.hpp" |
---|
8 | #include "event_scheduler.hpp" |
---|
9 | |
---|
10 | namespace xios |
---|
11 | { |
---|
12 | class CServer |
---|
13 | { |
---|
14 | public: |
---|
15 | static void initialize(void); |
---|
16 | static void finalize(void); |
---|
17 | static void eventLoop(void); |
---|
18 | static void contextEventLoop(void); |
---|
19 | static void listenContext(void); |
---|
20 | static void listenFinalize(void); |
---|
21 | static void recvContextMessage(void* buff,int count); |
---|
22 | static void listenRootContext(void); |
---|
23 | static void listenRootFinalize(void); |
---|
24 | static void registerContext(void* buff,int count, int leaderRank=0); |
---|
25 | |
---|
26 | static MPI_Comm intraComm; |
---|
27 | static list<MPI_Comm> interComm; |
---|
28 | static std::list<MPI_Comm> contextInterComms; |
---|
29 | static CEventScheduler* eventScheduler; |
---|
30 | |
---|
31 | struct contextMessage |
---|
32 | { |
---|
33 | int nbRecv; |
---|
34 | int leaderRank; |
---|
35 | }; |
---|
36 | |
---|
37 | static bool isRoot; |
---|
38 | |
---|
39 | static map<string,CContext*> contextList; |
---|
40 | static bool finished; |
---|
41 | static bool is_MPI_Initialized; |
---|
42 | |
---|
43 | public: |
---|
44 | //! Get rank of the current process |
---|
45 | static int getRank(); |
---|
46 | |
---|
47 | //! Open a file stream to write the info logs |
---|
48 | static void openInfoStream(const StdString& fileName); |
---|
49 | //! Write the info logs to standard output |
---|
50 | static void openInfoStream(); |
---|
51 | //! Close the info logs file if it opens |
---|
52 | static void closeInfoStream(); |
---|
53 | |
---|
54 | //! Open a file stream to write the error log |
---|
55 | static void openErrorStream(const StdString& fileName); |
---|
56 | //! Write the error log to standard error output |
---|
57 | static void openErrorStream(); |
---|
58 | //! Close the error log file if it opens |
---|
59 | static void closeErrorStream(); |
---|
60 | |
---|
61 | private: |
---|
62 | static int rank; |
---|
63 | static StdOFStream m_infoStream; |
---|
64 | static StdOFStream m_errorStream; |
---|
65 | |
---|
66 | static void openStream(const StdString& fileName, const StdString& ext, std::filebuf* fb); |
---|
67 | }; |
---|
68 | } |
---|
69 | |
---|
70 | #endif |
---|