From 816760c8480e8e76c7f4021a845161eb697e215c Mon Sep 17 00:00:00 2001 From: Claudius 'keldu' Holeksa Date: Mon, 15 Jul 2024 15:29:12 +0200 Subject: Moving remote definitions from codec to remote module --- modules/remote/c++/remote_loopback.hpp | 99 ++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 modules/remote/c++/remote_loopback.hpp (limited to 'modules/remote/c++/remote_loopback.hpp') diff --git a/modules/remote/c++/remote_loopback.hpp b/modules/remote/c++/remote_loopback.hpp new file mode 100644 index 0000000..2949243 --- /dev/null +++ b/modules/remote/c++/remote_loopback.hpp @@ -0,0 +1,99 @@ +#pragma once + +#include + +#include "interface.hpp" +#include "remote.hpp" +#include "transfer_loopback.hpp" + +namespace saw { + +template +class remote_data { +private: + id id_; +public: + remote_data(const id& id): + id_{id} + {} + + /** + * Wait until data arrives + */ + error_or> wait(wait_scope& wait); + + /** + * Asynchronously wait for a result + */ + conveyor> on_receive(); +}; + +/** + * Client RPC reference structure + */ +template +class rpc_client { + /** + * request the data from the remote + */ + template + remote_data request_data(id data); + + /** @todo + * Determine type based on Name + */ + /* + template + error_or< + id< + typename schema_member_type::type + > + > call(data_or_id inp); + */ +}; + +template<> +class remote_address { +}; + +template +class rpc_server { +public: + using InterfaceT = interface; +private: + const remote_address* addr_; + InterfaceT iface_; +public: + rpc_server(const remote_address& addr__, InterfaceT iface__): + addr_{&addr__}, + iface_{std::move(iface__)} + {} + + // error_or> +}; + +template<> +class remote { +public: + /** + * Resolves an address for the remote + */ + error_or>> parse_address(){ + return heap>(); + } + + /** + * Connect to a remote + */ + template + conveyor> connect(const remote_address& addr); + + /** + * Start listening + */ + template + rpc_server listen(const remote_address& addr, typename rpc_server::InterfaceT iface){ + return {addr, std::move(iface)}; + } +}; +} -- cgit v1.2.3