summaryrefslogtreecommitdiff
path: root/modules/remote-filesystem/c++/remote.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/remote-filesystem/c++/remote.hpp')
-rw-r--r--modules/remote-filesystem/c++/remote.hpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/modules/remote-filesystem/c++/remote.hpp b/modules/remote-filesystem/c++/remote.hpp
new file mode 100644
index 0000000..42cdd03
--- /dev/null
+++ b/modules/remote-filesystem/c++/remote.hpp
@@ -0,0 +1,59 @@
+#pragma once
+
+#include <filesystem>
+
+#include <forstio/remote/remote.hpp>
+
+namespace saw {
+namespace rmt {
+struct FileSystem {};
+}
+
+template<>
+class remote_address<rmt::FileSystem> {
+private:
+ std::filesystem::path path_;
+public:
+ remote_address(const std::filesystem::path& path__):
+ path_{path__}
+ {}
+};
+
+template<typename Iface, typename Encoding, typename Storage>
+class rpc_client<Iface, Encoding, Storage, rmt::FileSystem> {
+private:
+ ptr<remote_address<rmt::FileSystem>> addr_;
+public:
+ rpc_client(ptr<remote_address<rmt::FileSystem>> addr__):
+ addr_{addr__}
+ {}
+};
+
+template<typename Iface, typename Encoding, typename Storage>
+class rpc_server<Iface, Encoding, Storage, rmt::FileSystem> {
+private:
+ ptr<remote_address<rmt::FileSystem>> addr_;
+public:
+ rpc_server(ptr<remote_address<rmt::FileSystem>> addr__):
+ addr_{addr__}
+ {}
+};
+
+template<>
+class remote<rmt::FileSystem> {
+private:
+ SAW_FORBID_COPY(remote);
+ SAW_FORBID_MOVE(remote);
+
+
+public:
+ error_or<own<remote_address<rmt::FileSystem>>> parse_address(const std::string_view& path_v){
+ return heap<remote_address<rmt::FileSystem>>(path_v);
+ }
+
+ template<typename Iface, typename Encoding, typename Storage>
+ rpc_server<Iface, Encoding, Storage, rmt::FileSystem> listen(const remote_address<rmt::FileSystem>& addr, typename rpc_server<Iface,Encoding,Storage,rmt::FileSystem>::InterfaceT iface){
+ return {addr, std::move(iface)};
+ }
+};
+}