[1761] | 1 | #ifndef __SERVICE_HPP__ |
---|
| 2 | #define __SERVICE_HPP__ |
---|
| 3 | |
---|
| 4 | #include "xios_spl.hpp" |
---|
| 5 | #include "mpi.hpp" |
---|
| 6 | #include "services_manager.hpp" |
---|
| 7 | #include "event_scheduler.hpp" |
---|
| 8 | |
---|
| 9 | namespace xios |
---|
| 10 | { |
---|
| 11 | |
---|
| 12 | class CServerContext ; |
---|
| 13 | |
---|
| 14 | class CService |
---|
| 15 | { |
---|
| 16 | public: |
---|
| 17 | |
---|
[1764] | 18 | const int NOTIFY_NOTHING=0 ; |
---|
| 19 | const int NOTIFY_CREATE_CONTEXT=1 ; |
---|
| 20 | |
---|
[1761] | 21 | CService(MPI_Comm serviceComm, const std::string& poolId, const std::string& serviceId, const int& partitionId, |
---|
| 22 | int type, int nbPartitions) ; |
---|
[1764] | 23 | bool eventLoop(bool serviceOnly=false) ; |
---|
[1761] | 24 | void createContext(const std::string& poolId, const std::string& serviceId, const int& partitionId, const std::string& contextId) ; |
---|
| 25 | void checkCreateContextNotification(void) ; |
---|
| 26 | void createContextNotify(int rank, const std::string& poolId, const std::string& serviceId, const int& partitionId, const std::string& contextId) ; |
---|
| 27 | void createContextDumpOut(CBufferOut& buffer) ; |
---|
| 28 | void createContextDumpIn(CBufferIn& buffer) ; |
---|
| 29 | void createNewContext(const std::string& poolId, const std::string& serviceId, const int& partitionId, const std::string& contextId) ; |
---|
| 30 | CServerContext* getServerContext(const std::string& contextId) { return contexts_[contextId]; } |
---|
| 31 | void finalizeSignal(void) ; |
---|
| 32 | CEventScheduler* getEventScheduler(void) ; |
---|
| 33 | |
---|
| 34 | std::string getPoolId(void) {return poolId_;} |
---|
| 35 | std::string getServiceId(void) {return serviceId_;} |
---|
| 36 | int getPartitionId(void) {return partitionId_;} |
---|
| 37 | int getType(void) {return type_;} |
---|
| 38 | int getNbPartitions(void) {return nbPartitions_;} |
---|
| 39 | |
---|
| 40 | private: |
---|
[1764] | 41 | void sendNotification(int rank) ; |
---|
| 42 | void notificationsDumpOut(CBufferOut& buffer) ; |
---|
| 43 | void notificationsDumpIn(CBufferIn& buffer) ; |
---|
| 44 | void checkNotifications(void) ; |
---|
| 45 | void createContext(void) ; |
---|
| 46 | |
---|
[1761] | 47 | MPI_Comm serviceComm_ ; |
---|
| 48 | MPI_Comm globalComm_ ; |
---|
[1764] | 49 | |
---|
[1761] | 50 | const size_t maxBufferSize_=1024*1024 ; |
---|
| 51 | const int localLeader_=0 ; |
---|
| 52 | int globalLeader_ ; |
---|
| 53 | CWindowManager* winNotify_ ; |
---|
[1764] | 54 | |
---|
| 55 | std::string name_ ; |
---|
| 56 | |
---|
[1761] | 57 | std::list<std::tuple<std::string, std::string, int, std::string>> notifications_; |
---|
[1764] | 58 | |
---|
| 59 | bool hasNotification_ ; |
---|
| 60 | int notifyInType_,notifyOutType_ ; |
---|
| 61 | std::tuple<std::string, std::string, int, std::string> notifyInCreateContext_, notifyOutCreateContext_ ; |
---|
| 62 | |
---|
[1761] | 63 | std::map<std::string, CServerContext*> contexts_ ; |
---|
| 64 | bool finalizeSignal_ ; |
---|
| 65 | CEventScheduler* eventScheduler_ ; |
---|
| 66 | |
---|
| 67 | std::string poolId_ ; |
---|
| 68 | std::string serviceId_ ; |
---|
| 69 | int partitionId_ ; |
---|
| 70 | int type_ ; |
---|
| 71 | int nbPartitions_ ; |
---|
| 72 | |
---|
| 73 | }; |
---|
| 74 | |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | |
---|
| 78 | |
---|
| 79 | #endif |
---|