From 816760c8480e8e76c7f4021a845161eb697e215c Mon Sep 17 00:00:00 2001 From: Claudius 'keldu' Holeksa Date: Mon, 15 Jul 2024 15:29:12 +0200 Subject: Moving remote definitions from codec to remote module --- modules/remote/c++/remote.hpp | 116 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 modules/remote/c++/remote.hpp (limited to 'modules/remote/c++/remote.hpp') diff --git a/modules/remote/c++/remote.hpp b/modules/remote/c++/remote.hpp new file mode 100644 index 0000000..5803154 --- /dev/null +++ b/modules/remote/c++/remote.hpp @@ -0,0 +1,116 @@ +#pragma once + +#include +#include + +#include "data.hpp" +#include "interface.hpp" + +#include + +namespace saw { +/** + * This class acts as a helper for rpc calls and representing data on the remote. + */ +template +class data_or_id { +private: + /** + * Variant representing the either id or data class. + */ + std::variant, data> doi_; +public: + /** + * Constructor for instantiating. + */ + data_or_id(const id& val): + doi_{val} + {} + + /** + * Constructor for instantiating. + */ + data_or_id(data val): + doi_{std::move(val)} + {} + + /** + * Check if this class holds an id. + */ + bool is_id() const { + return std::holds_alternative>(doi_); + } + + /** + * Check if this class holds data. + */ + bool is_data() const { + return std::holds_alternative>(doi_); + } + + /** + * Returns the id. + */ + id get_id() const { + return std::get>(doi_); + } + + /** + * Return a data reference. + */ + data& get_data(){ + return std::get>(doi_); + } + + /** + * Return a data reference. + */ + const data& get_data() const { + return std::get>(doi_); + } +}; + + +/** + * Representing data on the remote + */ +template +class remote_data; + +template +class rpc_client; + +/** + * 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"); + + /** + * + */ +}; + +/** + * Reference Backend structure + */ +template +class remote { + static_assert(always_false, "Type of backend not supported"); +}; +} -- cgit v1.2.3