]> git.tdb.fi Git - libs/game.git/blob - source/game/reflection.cpp
Add reflection infrastructure
[libs/game.git] / source / game / reflection.cpp
1 #include "reflection.h"
2 #include <msp/debug/demangle.h>
3
4 using namespace std;
5
6 namespace Msp::Game {
7 namespace Reflection {
8
9 ClassBase::ClassBase(Reflector &r, type_index t):
10         reflector(r),
11         type(t),
12         name(Debug::demangle(t.name()))
13 { }
14
15 bool ClassBase::is_direct_base_of(const ClassBase &other) const
16 {
17         return ranges::find(other.bases, this)!=other.bases.end();
18 }
19
20 bool ClassBase::is_base_of(const ClassBase &other) const
21 {
22         if(is_direct_base_of(other))
23                 return true;
24         return ranges::any_of(other.bases, [this](const ClassBase *b){ return is_base_of(*b); });
25 }
26
27 } // namespace Reflection
28 } // namespace Msp::Game