diff options
Diffstat (limited to 'modules/remote-filesystem/c++')
-rw-r--r-- | modules/remote-filesystem/c++/SConscript | 38 | ||||
-rw-r--r-- | modules/remote-filesystem/c++/remote.hpp | 59 |
2 files changed, 97 insertions, 0 deletions
diff --git a/modules/remote-filesystem/c++/SConscript b/modules/remote-filesystem/c++/SConscript new file mode 100644 index 0000000..2bf03be --- /dev/null +++ b/modules/remote-filesystem/c++/SConscript @@ -0,0 +1,38 @@ +#!/bin/false + +import os +import os.path +import glob + + +Import('env') + +dir_path = Dir('.').abspath + +# Environment for base library +remote-filesystem_env = env.Clone(); + +remote-filesystem_env.sources = sorted(glob.glob(dir_path + "/*.cpp")) +remote-filesystem_env.headers = sorted(glob.glob(dir_path + "/*.hpp")) + +env.sources += remote-filesystem_env.sources; +env.headers += remote-filesystem_env.headers; + +## Shared lib +objects_shared = [] +remote-filesystem_env.add_source_files(objects_shared, remote-filesystem_env.sources, shared=True); +env.library_shared = remote-filesystem_env.SharedLibrary('#build/forstio-remote-filesystem', [objects_shared]); + +## Static lib +objects_static = [] +remote-filesystem_env.add_source_files(objects_static, remote-filesystem_env.sources, shared=False); +env.library_static = remote-filesystem_env.StaticLibrary('#build/forstio-remote-filesystem', [objects_static]); + +# Set Alias +env.Alias('library_remote-filesystem', [env.library_shared, env.library_static]); + +env.targets += ['library_remote-filesystem']; + +# Install +env.Install('$prefix/lib/', [env.library_shared, env.library_static]); +env.Install('$prefix/include/forstio/remote/filesystem/', [remote-filesystem_env.headers]); 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)}; + } +}; +} |