summaryrefslogtreecommitdiff
path: root/modules/io_codec
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2024-04-15 15:24:40 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2024-04-15 15:24:40 +0200
commit24d83f549a6fba7b23a0c048e1512d00ed704e0d (patch)
tree1c38294285e1fb60b5023f25f02f7c3bbd990a40 /modules/io_codec
parentc0d6895eac25040f1fa2ee766fc0f2c55c492634 (diff)
codec, io_codec: Fixed some type issues with functions and moved rpc to
io_codec due to dependency issues
Diffstat (limited to 'modules/io_codec')
-rw-r--r--modules/io_codec/.nix/derivation.nix2
-rw-r--r--modules/io_codec/SConstruct8
-rw-r--r--modules/io_codec/c++/rpc.hpp109
3 files changed, 94 insertions, 25 deletions
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 <forstio/codec/rpc.hpp>
+#include <forstio/id.hpp>
+#include <forstio/codec/data.hpp>
+#include <forstio/async/async.hpp>
+
+#include <forstio/codec/interface.hpp>
namespace saw {
-namespace rmt {
-struct Network {};
-}
-template<>
-class remote<rmt::Network> {
+/**
+ * Representing data on the remote
+ */
+template<typename T, typename Remote>
+class remote_data {
private:
- std::string addr_str_;
+ id<T> id_;
public:
- remote(std::string addr_str);
+ remote_data(const id<T>& id):
+ id_{id}
+ {}
- template<typename Interface>
- conveyor<rpc_client<rmt::Network, Interface>> connect();
+ /**
+ * Wait until data arrives
+ */
+ error_or<data<T>> wait(wait_scope& wait);
- template<typename Interface>
- conveyor<rpc_server<rmt::Network, Interface>> listen(network& net){
+ /**
+ * Asynchronously wait for a result
+ */
+ conveyor<data<T>> on_receive();
+};
- }
+/**
+ * Client RPC reference structure
+ */
+template<typename Iface, typename Remote>
+class rpc_client {
+ /**
+ * request the data from the remote
+ */
+ template<typename IdT>
+ remote_data<IdT, Remote> request_data(id<IdT> data);
+
+ /** @todo
+ * Determine type based on Name
+ */
+ /*
+ template<string_literal Name>
+ error_or<
+ id<
+ typename schema_member_type<Name, Iface>::type
+ >
+ > call(data_or_id<Input> inp);
+ */
};
-template<typename Interface>
-class rpc_server<rmt::Network, Interface> {
+/**
+ * Implementation of a remote server on the backend
+ */
+template<typename Iface, typename Remote>
+class rpc_server {
private:
+ interface<Iface> iface_;
public:
+ rpc_server(interface<Iface> iface):
+ iface_{std::move(iface)}
+ {}
+};
+
+/**
+ * Representation of a remote.
+ * Partially similar to a network address
+ */
+template<typename Remote>
+class remote_address {
+ static_assert(always_false<Remote>, "Type of remote not supported");
+
};
-template<template Interface>
-class rpc_client<rmt::Network, Interface> {
-private:
- own<async_io_stream> stream_;
-public:
- rpc_client(own<async_io_stream> stream);
+/**
+ * Reference Backend structure
+ */
+template<typename Remote>
+class remote {
+ static_assert(always_false<Remote>, "Type of backend not supported");
+
+ /**
+ * Resolves an address for the remote
+ */
+ conveyor<remote_address<Remote>> resolve_address();
+
+ /**
+ * Connect to a remote
+ */
+ template<typename Iface>
+ conveyor<rpc_client<Iface, Remote>> connect(const remote_address<Remote>& addr);
- template<typename T>
- remote_result<typename response<T>::type> call(typename request<T>::type req);
+ /**
+ * Start listening
+ */
+ template<typename Iface>
+ rpc_server<Iface, Remote> listen();
};
}