#ifndef __ELEMENT_HPP__ #define __ELEMENT_HPP__ #include "xios_spl.hpp" #include "array_new.hpp" #include "element_view.hpp" #include "exception.hpp" #include "context_client.hpp" #include "context_server.hpp" namespace xios { class CDistributedView ; class CLocalView; class CLocalConnector ; class CDistributedElement : public std::enable_shared_from_this { protected: std::map> globalIndex_ ; std::map localSize_ ; size_t globalSize_ ; std::vector> views_= std::vector>(CElementView::numViewType_) ; CDistributedElement(void) {} ; public: CDistributedElement(int globalSize, const map>& globalIndex) ; CDistributedElement(CEventServer& event) ; void addFullView(void) ; void sendToServer(CContextClient* client, CEventClient& event, const CMessage& messageHeader) ; void recvFromClient(CEventServer& event) ; size_t getGlobalSize(void) { return globalSize_;} std::map>& getGlobalIndex(void) { return globalIndex_;} shared_ptr getView(CElementView::type type) { if (views_[(size_t)type]==nullptr) { ERROR("CDistributedElement::getView(CElementView::type type)",<<"View is not initialized");} else return views_[(size_t)type] ; } void addView(CElementView::type type, std::map>& indexView) ; void addView(CElementView::type type, std::map>& maskView) ; void sendToServer(CEventClient& event, const CMessage& messageHeader) ; friend class CDistributedView ; } ; class CLocalElement : public CDistributedElement { // keep local connector inside std::map, shared_ptr> connectors_ ; public: CLocalElement(int localRank, size_t globalSize, const CArray& globalIndex) ; CLocalElement(int localRank, CEventServer& event) ; void recvFromClient(int localRank, CEventServer& event) ; const CArray& getGlobalIndex(void) { return globalIndex_ ;} void addView(CElementView::type type, CArray& indexView) ; void addView(CElementView::type type, CArray& maskView) ; void addFullView(void) ; shared_ptr getView(CElementView::type type) ; /* { if (views_[(size_t)type]==nullptr) { ERROR("CLocalElement::getView(CElementView::type type)",<<"View is not initialized");} else return static_pointer_cast(views_[(size_t)type]) ; } */ shared_ptr getConnector(CElementView::type srcType, CElementView::type dstType) ; private : int localRank_; CArray& globalIndex_ ; int& localSize_ ; friend class CLocalView ; } ; } #endif