summaryrefslogtreecommitdiff
path: root/modules/remote/c++/transfer.hpp
diff options
context:
space:
mode:
authorClaudius 'keldu' Holeksa <mail@keldu.de>2024-08-12 13:42:48 +0200
committerClaudius 'keldu' Holeksa <mail@keldu.de>2024-08-12 13:42:48 +0200
commite13f6a5e91ffeac86c32ab3a9048b810b1931061 (patch)
tree1eec0e8f5ca6edfd99581f5b175371a21c8f652b /modules/remote/c++/transfer.hpp
parentb9a4cf706cf0145c814ef5987dad21ebc4172ac6 (diff)
wip
Diffstat (limited to 'modules/remote/c++/transfer.hpp')
-rw-r--r--modules/remote/c++/transfer.hpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/modules/remote/c++/transfer.hpp b/modules/remote/c++/transfer.hpp
index 32416de..f68497b 100644
--- a/modules/remote/c++/transfer.hpp
+++ b/modules/remote/c++/transfer.hpp
@@ -2,6 +2,8 @@
#include <map>
+#include <forstio/common.hpp>
+
namespace saw {
template<typename Remote>
class i_data_server {
@@ -9,6 +11,18 @@ protected:
~i_data_server() = default;
public:
virtual std::pair<uint32_t,uint32_t> get_class_id() const = 0;
+
+ template<typename To>
+ error_or<ptr<To>> cast_to(){
+ {
+ auto rhs = get_class_id();
+ if(To::class_id.first == rhs.first && To::class_id.second == rhs.second){
+ return {ptr<To>{*static_cast<To*>(this)}};
+ }
+ }
+
+ return make_error<err::invalid_state>("Class IDs are not matching.");
+ }
};
template<typename Schema, typename Encoding, typename Remote>