forked from phisko/kengine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SerializableComponent.hpp
48 lines (40 loc) · 1.23 KB
/
SerializableComponent.hpp
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
46
47
48
#pragma once
#include "Component.hpp"
#include "reflection/Serializable.hpp"
namespace kengine
{
template<typename CRTP, typename ...DataPackets>
class SerializableComponent : public Component<CRTP, DataPackets...>,
public putils::Serializable<CRTP, false>
{
public:
template<typename ...MemberPairs>
SerializableComponent(MemberPairs &&...pairs)
: putils::Serializable<CRTP, false>(FWD(pairs)...)
{}
SerializableComponent() = default;
std::string toString() const noexcept override
{
std::stringstream s;
this->serialize(s);
return s.str();
}
public:
static const auto get_class_name() { return pmeta_nameof(SerializableComponent); }
static const auto &get_attributes()
{
static const auto table = pmeta::make_table();
return table;
}
static const auto &get_methods()
{
static const auto table = pmeta::make_table();
return table;
}
static const auto &get_parents()
{
static const auto table = pmeta::make_table();
return table;
}
};
}