From 3e09472ba3e6a651287ecfb5e2bfeb0ef2aeb5db Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Mon, 30 Oct 2023 15:34:25 +0100 Subject: codec: Moved rpc.h to interface.h --- c++/codec/rpc.h | 103 -------------------------------------------------------- 1 file changed, 103 deletions(-) delete mode 100644 c++/codec/rpc.h (limited to 'c++/codec/rpc.h') diff --git a/c++/codec/rpc.h b/c++/codec/rpc.h deleted file mode 100644 index b1422a9..0000000 --- a/c++/codec/rpc.h +++ /dev/null @@ -1,103 +0,0 @@ -#pragma once - -#include -#include "schema.h" -#include "data.h" - -namespace saw { -template -class function; - -template -class function, Encode, Func> { -private: - Func func_; -public: - function(Func func): - func_{std::move(func)} - {} - - error_or> call(data req){ - return func_(std::move(req)); - } -}; - -template -class interface; - -template -class interface, Names>...>, Encode, Funcs...> { -private: - std::tuple, Encode, Funcs>...> funcs_; -public: - interface(function, Encode, Funcs>... funcs): - funcs_{std::move(funcs)...} - {} - - /** - * Get the function based on the string literal matching the position in the tuple - */ - template - function< - schema::Function< - typename parameter_pack_type< - parameter_key_pack_index< - Lit, Names... - >::value - , Requests...>::type - , - typename parameter_pack_type< - parameter_key_pack_index< - Lit, Names... - >::value - , Responses...>::type - > - , - Encode - , - typename parameter_pack_type< - parameter_key_pack_index< - Lit, Names... - >::value - , Funcs...>::type - >& get(){ - return std::get::value>(funcs_); - } - - template - error_or::value - , Responses...>::type - , Encode>> call( - data< - typename parameter_pack_type< - parameter_key_pack_index< - Lit, Names... - >::value - , Requests...>::type - , Encode> req - ){ - return get().call(std::move(req)); - } - -}; - -template -struct function_factory { - template - 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)...}; - } -}; -} -- cgit v1.2.3