diff options
Diffstat (limited to 'modules/remote-hip/c++/remote.hpp')
-rw-r--r-- | modules/remote-hip/c++/remote.hpp | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/modules/remote-hip/c++/remote.hpp b/modules/remote-hip/c++/remote.hpp new file mode 100644 index 0000000..5bb41cf --- /dev/null +++ b/modules/remote-hip/c++/remote.hpp @@ -0,0 +1,91 @@ +#pragma once + +#include "common.hpp" + +namespace saw { + +template<> +struct remote_address<rmt::Hip> { +private: + uint64_t dev_id_; + + SAW_FORBID_COPY(remote_address); + SAW_FORBID_MOVE(remote_address); +public: + remote_address(uint64_t id): + dev_id_{id} + {} + + uint64_t get_device_id() const { + return dev_id_; + } +}; + +template<> +class remote<rmt::Hip> { +private: + SAW_FORBID_COPY(remote); + SAW_FORBID_MOVE(remote); + + struct key_t { + uint64_t device_id; + uint32_t sch_id; + uint32_t enc_id; + + bool operator<(const key_t& rhs) const { + if(device_id != rhs.device_id){ + return device_id < rhs.device_id; + } + if(sch_id != rhs.sch_id){ + return sch_id < rhs.sch_id; + } + if(enc_id != rhs.enc_id){ + return enc_id < rhs.enc_id; + } + return false; + } + }; + + std::map<uint64_t, our<device<rmt::Hip>>> devs_; + std::map<key_t, ptr<i_data_server<rmt::Hip>>> reg_dat_srvs_; +public: + /** + * Default constructor + */ + remote(){} + + /** + * For now we don't need to specify the location since + * we just create a default. + */ + conveyor<own<remote_address<rmt::Hip>>> resolve_address(uint64_t dev_id = 0u){ + return heap<remote_address<rmt::Hip>>(dev_id); + } + + /** + * Parse address, but don't resolve it. + */ + error_or<own<remote_address<rmt::Hip>>> parse_address(uint64_t dev_id = 0u){ + return heap<remote_address<rmt::Hip>>(dev_id); + } + + /** + * Spin up data server + */ + template<typename Schema, typename Encoding> + error_or<own<data_server<Schema, Encoding, rmt::Hip>>> data_listen(remote_address<rmt::Hip>& dev){ + return heap<data_server<Schema, Encoding, rmt::Hip>>(dev); + } + + /** + * Spin up a rpc server + */ + template<typename Iface, typename Encoding> + rpc_server<Iface, Encoding, rmt::Hip> listen(remote_address<rmt::Hip>& dev, typename rpc_server<Iface, Encoding, rmt::Hip>::InterfaceT iface){ + //using RpcServerT = rpc_server<Iface, Encoding, rmt::Hip>; + //using InterfaceT = typename RpcServerT::InterfaceT; + return {share<device<rmt::Hip>>(), std::move(iface)}; + } +}; + +} |