Twilight Princess
Decompilation of The Legend of Zelda: Twilight Princess
Loading...
Searching...
No Matches
RuntimeTypeInfo.h
Go to the documentation of this file.
1#ifndef NW4HBM_UT_RUNTIME_TYPE_INFO_H
2#define NW4HBM_UT_RUNTIME_TYPE_INFO_H
3
4#include <revolution/types.h>
5
6namespace nw4hbm {
7 namespace ut {
8
9#define NW4HBM_UT_RUNTIME_TYPEINFO \
10 virtual const nw4hbm::ut::detail::RuntimeTypeInfo* GetRuntimeTypeInfo() const { \
11 return &typeInfo; \
12 } \
13 static const nw4hbm::ut::detail::RuntimeTypeInfo typeInfo
14
15#define NW4HBM_UT_GET_RUNTIME_TYPEINFO(T) \
16 const nw4hbm::ut::detail::RuntimeTypeInfo T::typeInfo(NULL);
17
18#define NW4HBM_UT_GET_DERIVED_RUNTIME_TYPEINFO(T, D) \
19 const nw4hbm::ut::detail::RuntimeTypeInfo T::typeInfo(&D::typeInfo);
20
21 namespace detail {
24
25 bool IsDerivedFrom(const RuntimeTypeInfo* base) const {
26 for (const RuntimeTypeInfo* it = this; it != NULL; it = it->mParentTypeInfo) {
27 if (it == base) {
28 return true;
29 }
30 }
31 return false;
32 }
33
35 }; // size = 0x04
36
37 template <typename T>
38 inline const RuntimeTypeInfo* GetTypeInfoFromPtr_(T* pPtr) {
39 return &pPtr->typeInfo;
40 }
41 } // namespace detail
42
43 template <typename TDerived, typename TBase>
44 inline TDerived DynamicCast(TBase* pPtr) {
45 const detail::RuntimeTypeInfo* pDerivedTypeInfo =
46 detail::GetTypeInfoFromPtr_(static_cast<TDerived>(NULL));
47 if (pPtr->GetRuntimeTypeInfo()->IsDerivedFrom(pDerivedTypeInfo)) {
48 return static_cast<TDerived>(pPtr);
49 }
50 return NULL;
51 }
52
53 } // namespace ut
54} // namespace nw4hbm
55
56#endif
static u8 base[0x2A]
Definition WPADEncrypt.c:10
const RuntimeTypeInfo * GetTypeInfoFromPtr_(T *pPtr)
Definition RuntimeTypeInfo.h:38
TDerived DynamicCast(TBase *pPtr)
Definition RuntimeTypeInfo.h:44
Definition HBMAnmController.h:6
Definition RuntimeTypeInfo.h:22
RuntimeTypeInfo(const RuntimeTypeInfo *base)
Definition RuntimeTypeInfo.h:23
const RuntimeTypeInfo * mParentTypeInfo
Definition RuntimeTypeInfo.h:34
bool IsDerivedFrom(const RuntimeTypeInfo *base) const
Definition RuntimeTypeInfo.h:25