[1918] | 1 | #ifndef __ELEMENT_HPP__ |
---|
| 2 | #define __ELEMENT_HPP__ |
---|
| 3 | |
---|
| 4 | #include "xios_spl.hpp" |
---|
| 5 | #include "array_new.hpp" |
---|
| 6 | #include "element_view.hpp" |
---|
| 7 | #include "exception.hpp" |
---|
| 8 | #include "context_client.hpp" |
---|
| 9 | #include "context_server.hpp" |
---|
| 10 | |
---|
| 11 | namespace xios |
---|
| 12 | { |
---|
| 13 | class CDistributedView ; |
---|
| 14 | class CLocalView; |
---|
| 15 | class CLocalConnector ; |
---|
| 16 | |
---|
[2267] | 17 | class CDistributedElement : public std::enable_shared_from_this<CDistributedElement> |
---|
[1918] | 18 | { |
---|
| 19 | |
---|
| 20 | protected: |
---|
| 21 | std::map<int, CArray<size_t,1>> globalIndex_ ; |
---|
| 22 | std::map<int, int> localSize_ ; |
---|
| 23 | size_t globalSize_ ; |
---|
[2267] | 24 | std::vector<shared_ptr<CDistributedView>> views_= std::vector<shared_ptr<CDistributedView>>(CElementView::numViewType_) ; |
---|
[1918] | 25 | CDistributedElement(void) {} ; |
---|
| 26 | |
---|
| 27 | public: |
---|
| 28 | CDistributedElement(int globalSize, const map<int, CArray<size_t,1>>& globalIndex) ; |
---|
| 29 | CDistributedElement(CEventServer& event) ; |
---|
| 30 | void addFullView(void) ; |
---|
| 31 | void sendToServer(CContextClient* client, CEventClient& event, const CMessage& messageHeader) ; |
---|
| 32 | void recvFromClient(CEventServer& event) ; |
---|
| 33 | size_t getGlobalSize(void) { return globalSize_;} |
---|
[1999] | 34 | std::map<int, CArray<size_t,1>>& getGlobalIndex(void) { return globalIndex_;} |
---|
| 35 | |
---|
[2267] | 36 | shared_ptr<CDistributedView> getView(CElementView::type type) |
---|
[1918] | 37 | { |
---|
| 38 | if (views_[(size_t)type]==nullptr) { ERROR("CDistributedElement::getView(CElementView::type type)",<<"View is not initialized");} |
---|
| 39 | else return views_[(size_t)type] ; |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | void addView(CElementView::type type, std::map<int, CArray<int,1>>& indexView) ; |
---|
[1930] | 43 | void addView(CElementView::type type, std::map<int, CArray<bool,1>>& maskView) ; |
---|
[1918] | 44 | void sendToServer(CEventClient& event, const CMessage& messageHeader) ; |
---|
| 45 | |
---|
| 46 | friend class CDistributedView ; |
---|
| 47 | } ; |
---|
| 48 | |
---|
| 49 | |
---|
| 50 | class CLocalElement : public CDistributedElement |
---|
| 51 | { |
---|
| 52 | // keep local connector inside |
---|
[2267] | 53 | std::map<pair<CElementView::type,CElementView::type>, shared_ptr<CLocalConnector>> connectors_ ; |
---|
[1918] | 54 | |
---|
| 55 | public: |
---|
[2396] | 56 | CLocalElement(int localRank, size_t globalSize, const CArray<size_t,1>& globalIndex) ; |
---|
[1918] | 57 | CLocalElement(int localRank, CEventServer& event) ; |
---|
| 58 | void recvFromClient(int localRank, CEventServer& event) ; |
---|
[1930] | 59 | const CArray<size_t,1>& getGlobalIndex(void) { return globalIndex_ ;} |
---|
[1918] | 60 | void addView(CElementView::type type, CArray<int,1>& indexView) ; |
---|
[1930] | 61 | void addView(CElementView::type type, CArray<bool,1>& maskView) ; |
---|
[1918] | 62 | void addFullView(void) ; |
---|
[2267] | 63 | |
---|
| 64 | shared_ptr<CLocalView> getView(CElementView::type type) ; |
---|
| 65 | /* { |
---|
[1918] | 66 | if (views_[(size_t)type]==nullptr) { ERROR("CLocalElement::getView(CElementView::type type)",<<"View is not initialized");} |
---|
[2267] | 67 | else return static_pointer_cast<CLocalView>(views_[(size_t)type]) ; |
---|
[1918] | 68 | } |
---|
[2267] | 69 | */ |
---|
| 70 | shared_ptr<CLocalConnector> getConnector(CElementView::type srcType, CElementView::type dstType) ; |
---|
[1918] | 71 | |
---|
| 72 | private : |
---|
| 73 | int localRank_; |
---|
| 74 | CArray<size_t,1>& globalIndex_ ; |
---|
| 75 | int& localSize_ ; |
---|
| 76 | |
---|
| 77 | friend class CLocalView ; |
---|
| 78 | } ; |
---|
| 79 | |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | #endif |
---|
| 83 | |
---|