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/io_codec/.nix/derivation.nix | 2 +- modules/io_codec/SConstruct | 8 ++- modules/io_codec/c++/rpc.hpp | 109 +++++++++++++++++++++++++++-------- 3 files changed, 94 insertions(+), 25 deletions(-) (limited to 'modules/io_codec') diff --git a/modules/io_codec/.nix/derivation.nix b/modules/io_codec/.nix/derivation.nix index 7cd55a8..aa5deb8 100644 --- a/modules/io_codec/.nix/derivation.nix +++ b/modules/io_codec/.nix/derivation.nix @@ -24,7 +24,7 @@ in stdenv.mkDerivation { forstio.core forstio.async forstio.io - forstio.codec + forstio.codec ]; outputs = ["out" "dev"]; diff --git a/modules/io_codec/SConstruct b/modules/io_codec/SConstruct index 429656a..f4b8164 100644 --- a/modules/io_codec/SConstruct +++ b/modules/io_codec/SConstruct @@ -46,7 +46,13 @@ env_vars.Add('prefix', env=Environment(ENV=os.environ, variables=env_vars, CPPPATH=[], CPPDEFINES=['SAW_UNIX'], CXXFLAGS=['-std=c++20','-g','-Wall','-Wextra'], - LIBS=['forstio-io']) + LIBS=[ + 'forstio-core', + 'forstio-async', + 'forstio-io', + 'forstio-codec' + ] +); env.__class__.add_source_files = add_kel_source_files env.Tool('compilation_db'); env.cdb = env.CompilationDatabase('compile_commands.json'); diff --git a/modules/io_codec/c++/rpc.hpp b/modules/io_codec/c++/rpc.hpp index cdade00..3caa808 100644 --- a/modules/io_codec/c++/rpc.hpp +++ b/modules/io_codec/c++/rpc.hpp @@ -1,43 +1,106 @@ #pragma once -#include +#include +#include +#include + +#include namespace saw { -namespace rmt { -struct Network {}; -} -template<> -class remote { +/** + * Representing data on the remote + */ +template +class remote_data { private: - std::string addr_str_; + id id_; public: - remote(std::string addr_str); + remote_data(const id& id): + id_{id} + {} - template - conveyor> connect(); + /** + * Wait until data arrives + */ + error_or> wait(wait_scope& wait); - template - conveyor> listen(network& net){ + /** + * 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 rpc_server { +/** + * 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"); + }; -template