summaryrefslogtreecommitdiff
path: root/modules/io_codec/c++
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/c++
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/c++')
-rw-r--r--modules/io_codec/c++/rpc.hpp109
1 files changed, 86 insertions, 23 deletions
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();
};
}