From 24d83f549a6fba7b23a0c048e1512d00ed704e0d Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Mon, 15 Apr 2024 15:24:40 +0200 Subject: codec, io_codec: Fixed some type issues with functions and moved rpc to io_codec due to dependency issues --- modules/codec/c++/interface.hpp | 43 ++++++++++------- modules/codec/c++/rpc.hpp | 102 ---------------------------------------- 2 files changed, 25 insertions(+), 120 deletions(-) delete mode 100644 modules/codec/c++/rpc.hpp (limited to 'modules/codec/c++') diff --git a/modules/codec/c++/interface.hpp b/modules/codec/c++/interface.hpp index 59401ca..19dc145 100644 --- a/modules/codec/c++/interface.hpp +++ b/modules/codec/c++/interface.hpp @@ -1,18 +1,21 @@ #pragma once +#include + #include #include "schema.hpp" #include "data.hpp" namespace saw { -template +template class function; -template -class function, Encode, Func> { +template +class function, Encode> { private: - Func func_; + std::function(data)> func_; public: + template function(Func func): func_{std::move(func)} {} @@ -22,15 +25,25 @@ public: } }; +template +class i_interface { +public: + virtual ~i_interface() = default; + + +}; + template class interface; -template -class interface, Names>...>, Encode, Funcs...> { +template +class interface, Names>...>, Encode> { +public: + using Schema = schema::Interface,Names>...>; private: - std::tuple, Encode, Funcs>...> funcs_; + std::tuple, Encode>...> funcs_; public: - interface(function, Encode, Funcs>... funcs): + interface(function, Encode>... funcs): funcs_{std::move(funcs)...} {} @@ -54,12 +67,6 @@ public: > , Encode - , - typename parameter_pack_type< - parameter_key_pack_index< - Lit, Names... - >::value - , Funcs...>::type >& get(){ return std::get::value>(funcs_); } @@ -89,16 +96,16 @@ public: template struct function_factory { template - static function create(Func func){ - return function{std::move(func)}; + static function create(Func func){ + return function{std::move(func)}; } }; template struct interface_factory { template - static interface create(Func... func){ - return interface{std::move(func)...}; + static interface create(Func... func){ + return interface{std::move(func)...}; } }; } diff --git a/modules/codec/c++/rpc.hpp b/modules/codec/c++/rpc.hpp deleted file mode 100644 index 5a24034..0000000 --- a/modules/codec/c++/rpc.hpp +++ /dev/null @@ -1,102 +0,0 @@ -#pragma once - -#include -#include -#include - -namespace saw { - -/** - * Representing data on the remote - */ -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); - - /** - * Determine type based on Name - */ - template - error_or< - id< - typename schema_member_type::type - > - > call(data_or_id inp); -}; - -/** - * Implementation of a remote server on the backend - */ -template -class rpc_server { -private: - interface iface_; -public: - rpc_server(interface iface): - iface_{std::move(iface)} - {} -}; - -/** - * Representation of a remote. - * Partially similar to a network address - */ -template -class remote_address { - static_assert(always_false, "Type of remote not supported"); - - -}; - -/** - * Reference Backend structure - */ -template -class remote { - static_assert(always_false, "Type of backend not supported"); - - /** - * Resolves an address for the remote - */ - conveyor> resolve_address(); - - /** - * Connect to a remote - */ - template - conveyor> connect(const remote_address& addr); - - /** - * Start listening - */ - template - rpc_server listen(); -}; -} -- cgit v1.2.3