/*! \file client_server_mapping.hpp \author Ha NGUYEN \since 04 Feb 2015 \date 09 Mars 2015 \brief Mapping between index client and server. */ #ifndef __XIOS_CLIENT_SERVER_MAPPING_HPP__ #define __XIOS_CLIENT_SERVER_MAPPING_HPP__ #include "xios_spl.hpp" #include "array_new.hpp" #include "mpi.hpp" #include namespace xios { /*! \class CClientServerMapping This class computes index of data which are sent to server as well as index of data on server side. */ class CClientServerMapping { public: typedef boost::unordered_map > GlobalIndexMap; typedef std::map > LocalIndexMap; public: /** Default constructor */ CClientServerMapping(); /** Default destructor */ virtual ~CClientServerMapping(); // Only need global index on client to calculate mapping (supposed client has info of distribution) virtual void computeServerIndexMapping(const CArray& globalIndexOnClient) = 0; // // Simple case, global index on client and index on servers // virtual void computeServerIndexMapping(const CArray& globalIndexOnClient, // const std::vector* >& globalIndexOnServer); static std::map computeConnectedClients(int nbServer, int nbClient, MPI_Comm& clientIntraComm, const std::vector& connectedServerRank); const GlobalIndexMap& getGlobalIndexOnServer() const; // const LocalIndexMap& getLocalIndexSendToServer() const; protected: // void defaultComputeServerIndexMapping(const CArray& globalIndexOnClient, // const std::vector* >& globalIndexOnServer, // const CArray* localIndexOnClient = 0); protected: //! Global index of data on SERVER, which are calculated by client(s) GlobalIndexMap indexGlobalOnServer_; //! Index of the local data which will be sent to the corresponding server(s) // LocalIndexMap localIndexSend2Server_; //!< Number of clients connected to a server std::map connectedClients_; }; } // namespace xios #endif // __XIOS_CLIENT_SERVER_MAPPING_HPP__