-
Notifications
You must be signed in to change notification settings - Fork 59
/
main.cpp
44 lines (34 loc) · 922 Bytes
/
main.cpp
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
#include <UDRefl/UDRefl.hpp>
#include <iostream>
using namespace Ubpa;
using namespace Ubpa::UDRefl;
struct A { float a; };
struct B : A { float b; };
struct C : A { float c; };
struct D : B, C { float d; };
int main() {
{ // register
Mngr.RegisterType<A>();
Mngr.AddField<&A::a>("a");
Mngr.RegisterType<B>();
Mngr.AddBases<B, A>();
Mngr.AddField<&B::b>("b");
Mngr.RegisterType<C>();
Mngr.AddBases<C, A>();
Mngr.AddField<&C::c>("c");
Mngr.RegisterType<D>();
Mngr.AddBases<D, B, C>();
Mngr.AddField<&D::d>("d");
}
auto d = Mngr.MakeShared(Type_of<D>);
d.Var(Type_of<B>, "a") = 1.f;
d.Var(Type_of<C>, "a") = 2.f;
d.Var("b") = 3.f;
d.Var("c") = 4.f;
d.Var("d") = 5.f;
for (const auto& [name, fieldinfo] : FieldRange_of<D>)
std::cout << name.GetView() << std::endl;
for (const auto& [name, var] : d.GetVars())
std::cout << name.GetView() << ": " << var << std::endl;
return 0;
}