summaryrefslogtreecommitdiff
path: root/modules/codec/c++/remote.hpp
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2024-07-05 16:50:33 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2024-07-05 16:50:33 +0200
commit614d0bf07789457a97d194c4af9cc7393f871351 (patch)
treefffe8f702589603b397497e14ca217428c98edec /modules/codec/c++/remote.hpp
parent9f320474f1c19861d46f6c42a09f7bba9dc919bc (diff)
Working on loopback data transmission
Diffstat (limited to 'modules/codec/c++/remote.hpp')
-rw-r--r--modules/codec/c++/remote.hpp116
1 files changed, 116 insertions, 0 deletions
diff --git a/modules/codec/c++/remote.hpp b/modules/codec/c++/remote.hpp
new file mode 100644
index 0000000..5803154
--- /dev/null
+++ b/modules/codec/c++/remote.hpp
@@ -0,0 +1,116 @@
+#pragma once
+
+#include <forstio/id.hpp>
+#include <forstio/async/async.hpp>
+
+#include "data.hpp"
+#include "interface.hpp"
+
+#include <variant>
+
+namespace saw {
+/**
+ * This class acts as a helper for rpc calls and representing data on the remote.
+ */
+template<typename T, typename Encoding, typename Storage>
+class data_or_id {
+private:
+ /**
+ * Variant representing the either id or data class.
+ */
+ std::variant<id<T>, data<T,Encoding, Storage>> doi_;
+public:
+ /**
+ * Constructor for instantiating.
+ */
+ data_or_id(const id<T>& val):
+ doi_{val}
+ {}
+
+ /**
+ * Constructor for instantiating.
+ */
+ data_or_id(data<T,Encoding, Storage> val):
+ doi_{std::move(val)}
+ {}
+
+ /**
+ * Check if this class holds an id.
+ */
+ bool is_id() const {
+ return std::holds_alternative<id<T>>(doi_);
+ }
+
+ /**
+ * Check if this class holds data.
+ */
+ bool is_data() const {
+ return std::holds_alternative<data<T,Encoding,Storage>>(doi_);
+ }
+
+ /**
+ * Returns the id.
+ */
+ id<T> get_id() const {
+ return std::get<id<T>>(doi_);
+ }
+
+ /**
+ * Return a data reference.
+ */
+ data<T,Encoding, Storage>& get_data(){
+ return std::get<data<T,Encoding, Storage>>(doi_);
+ }
+
+ /**
+ * Return a data reference.
+ */
+ const data<T,Encoding,Storage>& get_data() const {
+ return std::get<data<T,Encoding,Storage>>(doi_);
+ }
+};
+
+
+/**
+ * Representing data on the remote
+ */
+template<typename T, typename Encoding, typename Storage, typename Remote>
+class remote_data;
+
+template<typename Iface, typename Encoding, typename Storage, typename Remote>
+class rpc_client;
+
+/**
+ * Implementation of a remote server on the backend
+ */
+template<typename Iface, typename Encoding, typename Storage, typename Remote>
+class rpc_server {
+private:
+ interface<Iface, Encoding, Storage> iface_;
+public:
+ rpc_server(interface<Iface, Encoding, Storage> 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");
+
+ /**
+ *
+ */
+};
+
+/**
+ * Reference Backend structure
+ */
+template<typename Remote>
+class remote {
+ static_assert(always_false<Remote>, "Type of backend not supported");
+};
+}