summaryrefslogtreecommitdiff
path: root/modules/remote/c++/transfer.hpp
blob: f68497b632c3de2e882ff665bfe6467d9ab0dfc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once

#include <map>

#include <forstio/common.hpp>

namespace saw {
template<typename Remote>
class i_data_server {
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>
class data_server;

template<typename Schema, typename Encoding, typename Remote>
class data_client;

namespace impl {
template<typename Encoding, typename Storage, typename T>
struct data_server_redux {
	using type = std::tuple<>;
};

template<typename Encoding, typename Storage, typename... Schema>
struct data_server_redux<Encoding, Storage, tmpl_group<Schema...>> {
	using type = std::tuple<std::unordered_map<uint64_t, data<Schema, Encoding, Storage>>...>;
};
}
}