#ifndef __CONTEXT_CLIENT_HPP__ #define __CONTEXT_CLIENT_HPP__ #include "xios_spl.hpp" #include "buffer_out.hpp" #include "buffer_in.hpp" #include "buffer_client.hpp" #include "event_client.hpp" #include "event_server.hpp" #include "mpi.hpp" #include "registry.hpp" namespace xios { class CContext; /*! \class CContextClient A context can be both on client and on server side. In order to differenciate the role of context on each side, e.x client sending events, server receiving and processing events, there is a need of concrete "context" classes for both sides. CContextClient processes and sends events from client to server where CContextServer receives these events and processes them. */ class CContextClient { public: // Contructor CContextClient(CContext* parent, MPI_Comm intraComm, MPI_Comm interComm, CContext* parentServer = 0); // Send event to server void sendEvent(CEventClient& event); void waitEvent(list& ranks); // Functions relates to set/get buffers list getBuffers(list& serverlist, list& sizeList); void newBuffer(int rank); bool checkBuffers(list& ranks); bool checkBuffers(void); void releaseBuffers(void); bool isServerLeader(void) const; const std::list& getRanksServerLeader(void) const; bool isAttachedModeEnabled() const; // Close and finalize context client void closeContext(void); void finalize(void); void setBufferSize(const std::map& mapSize); public: CContext* context; //!< Context for client size_t timeLine; //!< Timeline of each event int clientRank; //!< Rank of current client int clientSize; //!< Size of client group int serverSize; //!< Size of server group MPI_Comm interComm; //!< Communicator of server group MPI_Comm intraComm; //!< Communicator of client group map buffers; //!< Buffers for connection to servers private: //! Mapping of server and buffer size for each connection to server std::map mapBufferSize_; //! Context for server (Only used in attached mode) CContext* parentServer; //! List of server ranks for which the client is leader std::list ranksServerLeader; public: // Some function should be removed in the future // void registerEvent(CEventClient& event); // list newEvent(CEventClient& event,list& sizes); // bool locked; // set connectedServer; }; } #endif // __CONTEXT_CLIENT_HPP__