summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorClaudius 'keldu' Holeksa <mail@keldu.de>2024-08-14 21:34:50 +0200
committerClaudius 'keldu' Holeksa <mail@keldu.de>2024-08-14 21:34:50 +0200
commit0e80c34f73ab0cf986675b1ac5e78e6f14eca623 (patch)
tree7ccbd983837d066b290621c531a640d0ce02eb40 /modules
parent903dc78b7b3542e7fc7e865a4acc60df68688d53 (diff)
Added Remote file server class
Diffstat (limited to 'modules')
-rw-r--r--modules/remote-filesystem/examples/SConscript3
-rw-r--r--modules/remote-filesystem/examples/remote_read_file.cpp59
-rw-r--r--modules/remote-filesystem/examples/remote_write_file.cpp2
3 files changed, 62 insertions, 2 deletions
diff --git a/modules/remote-filesystem/examples/SConscript b/modules/remote-filesystem/examples/SConscript
index 3e039b7..1a4d022 100644
--- a/modules/remote-filesystem/examples/SConscript
+++ b/modules/remote-filesystem/examples/SConscript
@@ -30,7 +30,8 @@ examples_env.remote_file_read = examples_env.Program('#bin/remote_read_file', [e
# Set Alias
env.examples = [
#, examples_env.echo_server
- examples_env.remote_file_write
+ examples_env.remote_file_write,
+ examples_env.remote_file_read
];
env.Alias('examples', env.examples);
diff --git a/modules/remote-filesystem/examples/remote_read_file.cpp b/modules/remote-filesystem/examples/remote_read_file.cpp
new file mode 100644
index 0000000..b0b2c89
--- /dev/null
+++ b/modules/remote-filesystem/examples/remote_read_file.cpp
@@ -0,0 +1,59 @@
+#include "../c++/transfer.hpp"
+
+#include <forstio/codec/simple.hpp>
+
+#include <iostream>
+
+namespace sch {
+using namespace saw::schema;
+
+using Foo = Struct<
+ Member<String, "a">,
+ Member<Int64, "b">
+>;
+}
+
+int main(){
+ using namespace saw;
+
+ remote<rmt::File> file_remote;
+
+ auto eo_addr = file_remote.parse_address("./example_file");
+ if(eo_addr.is_error()){
+ return 1;
+ }
+ auto& addr = eo_addr.get_value();
+
+ auto eo_dat_srv = file_remote.template data_listen<sch::Foo,encode::KelSimple>({*addr});
+ if(eo_dat_srv.is_error()){
+ return 2;
+ }
+ auto& dat_srv = eo_dat_srv.get_value();
+
+ std::string a = "blafoobla";
+ int64_t b = 42;
+
+ {
+
+ id<sch::Foo> foo_id{0u};
+ auto eo_recv = dat_srv->receive(foo_id);
+ if(eo_recv.is_error()){
+ auto& err = eo_recv.get_error();
+ std::cerr<<"Error: "<<err.get_category()<<" - "<<err.get_message()<<std::endl;
+ return 4;
+ }
+ auto& recv = eo_recv.get_value();
+
+ data<sch::Foo> nat_foo;
+ codec<sch::Foo, encode::KelSimple> smp_cod;
+ auto eov = smp_cod.decode(recv, nat_foo);
+ if(eov.is_error()){
+ return 3;
+ }
+
+ std::cout<<"a: ";
+ for(uint64_t i = 0; i < nat_foo.template get<"a">().size();++i) std::cout<<nat_foo.template get<"a">().at(i);
+ std::cout<<"\nb: "<<nat_foo.template get<"b">().get()<<std::endl;
+ }
+ return 0;
+}
diff --git a/modules/remote-filesystem/examples/remote_write_file.cpp b/modules/remote-filesystem/examples/remote_write_file.cpp
index 938b140..6ec1586 100644
--- a/modules/remote-filesystem/examples/remote_write_file.cpp
+++ b/modules/remote-filesystem/examples/remote_write_file.cpp
@@ -54,5 +54,5 @@ int main(){
return 4;
}
}
-
+ return 0;
}