diff options
author | Claudius "keldu" Holeksa <mail@keldu.de> | 2024-05-17 18:14:41 +0200 |
---|---|---|
committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2024-05-17 18:14:41 +0200 |
commit | 7479b39379bcf79dfa73a61643538832c2571c49 (patch) | |
tree | 115666ec7696d12df2a9449e18f1fc5d4cf76cb8 /modules/io_codec/c++/rpc.hpp | |
parent | 059dc4308ac731d2b3c324166d87b8d527b9d217 (diff) |
Trying to get rpc interaction with iface working
Diffstat (limited to 'modules/io_codec/c++/rpc.hpp')
-rw-r--r-- | modules/io_codec/c++/rpc.hpp | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/modules/io_codec/c++/rpc.hpp b/modules/io_codec/c++/rpc.hpp index 547eea3..66b7c41 100644 --- a/modules/io_codec/c++/rpc.hpp +++ b/modules/io_codec/c++/rpc.hpp @@ -6,12 +6,39 @@ #include <forstio/codec/interface.hpp> +#include <variant> + namespace saw { /** + * + */ +template<typename T, typename Encoding> +class data_or_id { +private: + std::variant<id<T>, data<T,Encoding>> doi_; +public: + data_or_id(const id<T>& val): + doi_{val} + {} + + data_or_id(data<T,Encoding> val): + doi_{std::move(val)} + {} + + bool is_id() const { + return false; + } + + bool is_data() const { + return false; + } +}; + +/** * Representing data on the remote */ -template<typename T, typename Remote> +template<typename T, typename Encoding, typename Remote> class remote_data { private: id<T> id_; @@ -23,24 +50,24 @@ public: /** * Wait until data arrives */ - error_or<data<T>> wait(wait_scope& wait); + error_or<data<T, Encoding>> wait(wait_scope& wait); /** * Asynchronously wait for a result */ - conveyor<data<T>> on_receive(); + conveyor<data<T, Encoding>> on_receive(); }; /** * Client RPC reference structure */ -template<typename Iface, typename Encode, typename Remote> +template<typename Iface, typename Encoding, typename Remote> class rpc_client { /** * request the data from the remote */ template<typename IdT> - remote_data<IdT, Remote> request_data(id<IdT> data); + remote_data<IdT, Encoding, Remote> request_data(id<IdT> data); /** @todo * Determine type based on Name @@ -58,12 +85,12 @@ class rpc_client { /** * Implementation of a remote server on the backend */ -template<typename Iface, typename Encode, typename Remote> +template<typename Iface, typename Encoding, typename Remote> class rpc_server { private: - interface<Iface, Encode> iface_; + interface<Iface, Encoding> iface_; public: - rpc_server(interface<Iface, Encode> iface): + rpc_server(interface<Iface, Encoding> iface): iface_{std::move(iface)} {} }; |