#pragma once #include "common.hpp" namespace saw { template<> struct remote_address { 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 { private: SAW_FORBID_COPY(remote); SAW_FORBID_MOVE(remote); struct key_t { std::array data; template static key_t create(const remote_address& addr){ key_t k; k.data = std::array{addr.get_address_id().get(), schema_hash::apply(), schema_hash::apply()}; return k; } bool operator<(const key_t& rhs) const { for(uint64_t i = 0u; i < 3; ++i){ if(data[i] != rhs.data[i]){ return data[i] < rhs.data[i]; } } return false; } }; std::map>> devs_; std::map>> reg_dat_srvs_; public: /** * Default constructor */ remote(){} /** * For now we don't need to specify the location since * we just create a default. */ conveyor>> resolve_address(uint64_t dev_id = 0u){ return heap>(dev_id); } /** * Parse address, but don't resolve it. */ error_or>> parse_address(uint64_t dev_id = 0u){ return heap>(dev_id); } /** * Spin up data server */ template error_or>> data_listen(remote_address& dev){ return heap>(dev); } /** * Spin up a rpc server */ template rpc_server listen(remote_address& dev, typename rpc_server::InterfaceT iface){ //using RpcServerT = rpc_server; //using InterfaceT = typename RpcServerT::InterfaceT; return {share>(), std::move(iface)}; } }; }