NW4F Sys
Loading...
Searching...
No Matches
ut_RuntimeTypeInfo.h
Go to the documentation of this file.
1#ifndef NW_UT_RUNTIMETYPEINFO_H_
2#define NW_UT_RUNTIMETYPEINFO_H_
3
4#include <nw/types.h>
5
6namespace nw { namespace ut {
7
8#define NW_UT_RUNTIME_TYPEINFO_ROOT()
9 static const nw::ut::internal::RuntimeTypeInfo* GetRuntimeTypeInfoStatic();
10 virtual const nw::ut::internal::RuntimeTypeInfo* GetRuntimeTypeInfo() const
11 {
12 return GetRuntimeTypeInfoStatic();
13 }
14
15#define NW_UT_RUNTIME_TYPEINFO(base)
16 static const nw::ut::internal::RuntimeTypeInfo* GetRuntimeTypeInfoStatic();
17 virtual const nw::ut::internal::RuntimeTypeInfo* GetRuntimeTypeInfo() const override
18 {
19 return GetRuntimeTypeInfoStatic();
20 }
21
22#define NW_UT_RUNTIME_TYPEINFO_ROOT_IMPL(clazz)
23 const nw::ut::internal::RuntimeTypeInfo* clazz::GetRuntimeTypeInfoStatic() {
24 static const nw::ut::internal::RuntimeTypeInfo s_TypeInfo(NULL);
25 return &s_TypeInfo;
26 }
27
28#define NW_UT_RUNTIME_TYPEINFO_IMPL(base, clazz)
29 const nw::ut::internal::RuntimeTypeInfo* clazz::GetRuntimeTypeInfoStatic() {
30 static const nw::ut::internal::RuntimeTypeInfo s_TypeInfo(base::GetRuntimeTypeInfoStatic());
31 return &s_TypeInfo;
32 }
33
34namespace internal {
35
37{
39
40 explicit RuntimeTypeInfo(const RuntimeTypeInfo* parent)
41 : m_ParentTypeInfo(parent)
42 {
43 }
44
45 bool IsDerivedFrom(const RuntimeTypeInfo* s_TypeInfo) const
46 {
47 const RuntimeTypeInfo* self = this;
48 while (self)
49 {
50 if (self == s_TypeInfo)
51 return true;
52
53 self = self->m_ParentTypeInfo;
54 }
55 return false;
56 }
57};
58
59} // namespace internal
60
61} } // namespace nw::ut
62
63#endif // NW_UT_RUNTIMETYPEINFO_H_
Definition ut_LinkList.h:12
Definition ut_CriticalSection.h:6
Definition math_Constant.cpp:5
Definition ut_RuntimeTypeInfo.h:37
RuntimeTypeInfo(const RuntimeTypeInfo *parent)
Definition ut_RuntimeTypeInfo.h:40
bool IsDerivedFrom(const RuntimeTypeInfo *s_TypeInfo) const
Definition ut_RuntimeTypeInfo.h:45
const RuntimeTypeInfo * m_ParentTypeInfo
Definition ut_RuntimeTypeInfo.h:38