diff options
Diffstat (limited to 'modules/remote/c++/transfer.hpp')
-rw-r--r-- | modules/remote/c++/transfer.hpp | 14 |
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> |