summaryrefslogtreecommitdiff
path: root/modules/remote
diff options
context:
space:
mode:
authorClaudius 'keldu' Holeksa <mail@keldu.de>2024-07-22 17:44:27 +0200
committerClaudius 'keldu' Holeksa <mail@keldu.de>2024-07-22 17:44:27 +0200
commit977ac8bce989285eaabc76c4ed8571ce5fd6793a (patch)
tree08df4e53e4f2ea947662cc6b1d207ed852292474 /modules/remote
parentfdf1b23129d73b27b28756e77da9b02215878721 (diff)
wip
Diffstat (limited to 'modules/remote')
-rw-r--r--modules/remote/c++/remote.hpp2
-rw-r--r--modules/remote/c++/remote_loopback.hpp15
-rw-r--r--modules/remote/c++/transfer.hpp6
-rw-r--r--modules/remote/c++/transfer_loopback.hpp4
-rw-r--r--modules/remote/tests/remote_loopback.cpp39
5 files changed, 52 insertions, 14 deletions
diff --git a/modules/remote/c++/remote.hpp b/modules/remote/c++/remote.hpp
index fd6f4e6..72c9cce 100644
--- a/modules/remote/c++/remote.hpp
+++ b/modules/remote/c++/remote.hpp
@@ -8,6 +8,8 @@
#include <variant>
+#include "transfer.hpp"
+
namespace saw {
/**
* This class acts as a helper for rpc calls and representing data on the remote.
diff --git a/modules/remote/c++/remote_loopback.hpp b/modules/remote/c++/remote_loopback.hpp
index 76aab69..10ac79c 100644
--- a/modules/remote/c++/remote_loopback.hpp
+++ b/modules/remote/c++/remote_loopback.hpp
@@ -55,6 +55,16 @@ class rpc_client<Iface, Encoding, Storage, rmt::Loopback> {
template<>
class remote_address<rmt::Loopback> {
+private:
+ data<schema::UInt64> addr_id_;
+public:
+ remote_address(data<schema::UInt64> addr_id__):
+ addr_id_{addr_id__}
+ {}
+
+ const data<schema::UInt64>& get_address_id() const {
+ return addr_id_;
+ }
};
template<typename Iface, typename Encode, typename Storage>
@@ -75,12 +85,13 @@ public:
template<>
class remote<rmt::Loopback> {
+private:
public:
/**
* Resolves an address for the remote
*/
- error_or<own<remote_address<rmt::Loopback>>> parse_address(){
- return heap<remote_address<rmt::Loopback>>();
+ error_or<own<remote_address<rmt::Loopback>>> parse_address(data<schema::UInt64> id){
+ return heap<remote_address<rmt::Loopback>>(id);
}
/**
diff --git a/modules/remote/c++/transfer.hpp b/modules/remote/c++/transfer.hpp
index 2fdd0b9..ea61d56 100644
--- a/modules/remote/c++/transfer.hpp
+++ b/modules/remote/c++/transfer.hpp
@@ -1,6 +1,12 @@
#pragma once
namespace saw {
+template<typename Remote>
+class i_data_server {
+protected:
+ virtual ~i_data_server() = default;
+};
+
template<typename Schema, typename Encoding, typename Remote>
class data_server;
diff --git a/modules/remote/c++/transfer_loopback.hpp b/modules/remote/c++/transfer_loopback.hpp
index abea83f..9d026f2 100644
--- a/modules/remote/c++/transfer_loopback.hpp
+++ b/modules/remote/c++/transfer_loopback.hpp
@@ -13,7 +13,11 @@ template<typename... Schema, typename Encoding>
class data_server<tmpl_group<Schema...>, Encoding, rmt::Loopback> {
private:
typename impl::data_server_redux<Encoding, storage::Default, typename tmpl_reduce<tmpl_group<Schema...>>::type>::type values_;
+
+ ptr<remote<rmt::Loopback>> remote_;
public:
+ data_server(remote_address<rmt::Loopback>& addr)
+
/**
* Get data from client
*/
diff --git a/modules/remote/tests/remote_loopback.cpp b/modules/remote/tests/remote_loopback.cpp
index e78f646..2430029 100644
--- a/modules/remote/tests/remote_loopback.cpp
+++ b/modules/remote/tests/remote_loopback.cpp
@@ -21,20 +21,17 @@ using GroupedSchemas = saw::tmpl_group<
SAW_TEST("Remote Loopback Data"){
using namespace saw;
+ event_loop loop;
+ wait_scope wait{loop};
+
remote<rmt::Loopback> rmt;
- auto eov = rmt.parse_address();
+ auto eov = rmt.parse_address(0u);
SAW_EXPECT(eov.is_value(), "Didn't parse correctly");
auto& val = eov.get_value();
- interface<sch::TestInterface, encode::Native, storage::Default> iface{
- [](data<sch::UInt32>& foo){
- return foo.template cast_to<sch::Int64>();
- }
- };
-
- auto srv = data_server<sch::GroupedSchemas, encode::Native, rmt::Loopback>{};
- auto client = data_client<sch::GroupedSchemas, encode::Native, rmt::Loopback>{srv};
+ auto srv = data_server<sch::GroupedSchemas, encode::Native, rmt::Loopback>{val};
+ auto client = data_client<sch::GroupedSchemas, encode::Native, rmt::Loopback>{val};
data<sch::UInt64> foo{421};
id<sch::UInt64> sent_id = [&](){
@@ -43,9 +40,6 @@ SAW_TEST("Remote Loopback Data"){
return eov.get_value();
}();
- event_loop loop;
- wait_scope wait{loop};
-
{
auto conv = client.receive(sent_id);
auto eov = conv.take();
@@ -82,5 +76,26 @@ SAW_TEST("Remote Loopback Data"){
SAW_EXPECT(f_val, "Nullptr in find.");
f_val->set(5u);
}
+ {
+ auto conv = client.receive(alloc_id);
+ auto eov = conv.take();
+ SAW_EXPECT(eov.is_value(), "Failed receive.");
+ SAW_EXPECT(eov.get_value().get() == 5u, "Wrong received value.");
+ }
+
+ data<sch::FixedArray<sch::UInt64,1>> arr_meta{{128u}};
+
+ id<sch::Array<sch::Int32>> arr_alloc_id = [&](){
+ auto eov = client.allocate<sch::Array<sch::Int32>>(arr_meta);
+ SAW_EXPECT(eov.is_value(), "Failed send.");
+ return eov.get_value();
+ }();
+ {
+ auto eov = client.find(arr_alloc_id);
+ SAW_EXPECT(eov.is_value(), "Failed find.");
+ auto& f_val = eov.get_value();
+ SAW_EXPECT(f_val, "Nullptr in find.");
+ SAW_EXPECT(f_val->size() == arr_meta.at(0).get(), "Wrong initialized size.");
+ }
}
}