12 static constexpr auto name =
"Null";
13 static constexpr auto properties = std::make_tuple();
14 static constexpr auto propertyCount = 0u;
15 static constexpr auto isPrimitive =
false;
18#define REGISTER_TYPE(Class, ...) \
19template<> struct Type<Class> \
21 static constexpr const char* name = #Class; \
22 static constexpr auto properties = std::make_tuple(__VA_ARGS__); \
23 static constexpr auto propertyCount = std::tuple_size<decltype(properties)>::value; \
24 static constexpr bool isPrimitive = false; \
27#define REGISTER_PRIMITIVE_TYPE(Class) \
28template<> struct Type<Class> \
30 static constexpr const char* name = #Class; \
31 static constexpr auto properties = std::make_tuple(); \
32 static constexpr auto propertyCount = 0u; \
33 static constexpr bool isPrimitive = true; \
34 static auto Get(Class obj) -> Class { return obj; } \
35 static auto Set(Class* ptr, Class v) { *ptr = v; } \
40 static constexpr uint32_t None = 0b0000;
41 static constexpr uint32_t Nonnegative = 0b0001;
42 static constexpr uint32_t Position = 0b0010;
43 static constexpr uint32_t Scale = 0b0100;
44 static constexpr uint32_t Angles = 0b1000;
50 : name{
"Null"}, flags{PropertyFlags::None}
55 : name{tag}, flags{flags_}
63template<
class T,
class P>
66 using parent_type = T;
67 using property_type = P;
69 constexpr Property(P T::*ptr,
const char* tag, uint32_t propertyFlags)
77#define PROPERTY(Class, Member) \
78Property<Class, decltype(Class::Member)>{&Class::Member, #Member, PropertyFlags::None}
80#define PROPERTY_F(Class, Member, Flags) \
81Property<Class, decltype(Class::Member)>{&Class::Member, #Member, Flags}
83template<
class T,
class P>
84auto GetProperty(
const T& obj) -> P
87 return obj.*(
property.member);
90template<
class T,
class Func>
91constexpr void ForEachMember(Func&& func)
93 std::apply([&func](
auto&& ... args) { (func(args), ...); }, Type<T>::properties);
96REGISTER_PRIMITIVE_TYPE(
float);
97REGISTER_PRIMITIVE_TYPE(
int);
98REGISTER_PRIMITIVE_TYPE(
char);
99REGISTER_PRIMITIVE_TYPE(
const char*);