OpenBarnyard
 
Loading...
Searching...
No Matches
TObject.h File Reference
#include "TClass.h"
#include <type_traits>
#include <Core/TMemoryDebugOff.h>

Go to the source code of this file.

Classes

class  TObject
 

Macros

#define TClassObjectName   ms_oClass
 
#define TGetClass(CLASS)
 
#define TDECLARE_CLASS_BODY(THIS_CLASS, PARENT_CLASS)
 
#define TDECLARE_CLASS(THIS_CLASS, PARENT_CLASS)
 
#define TDECLARE_CLASS_COMPILETIME(THIS_CLASS, PARENT_CLASS)
 
#define TDEFINE_CLASS_CORE(CLASS)
 
#define TDEFINE_CLASS_CORE_NORUNTIME(CLASS)
 
#define TDEFINE_CLASS_CORE_COMPILETIME(CLASS)
 
#define TDEFINE_CLASS_FULL(CLASS)
 
#define TDEFINE_CLASS_FULL_NORUNTIME(CLASS)
 
#define TDEFINE_CLASS_FULL_COMPILETIME(CLASS)
 
#define TDEFINE_CLASS(...)
 
#define TDEFINE_CLASS1(CLASS)
 
#define TDEFINE_CLASS3(CLASS, VER_MAJOR, VER_MINOR)
 
#define TDEFINE_CLASS_NORUNTIME1(CLASS)
 
#define TDEFINE_CLASS_NORUNTIME3(CLASS, VER_MAJOR, VER_MINOR)
 
#define TDEFINE_CLASS_NORUNTIME(...)
 
#define TDEFINE_CLASS_INIT1(CLASS)
 
#define TDEFINE_CLASS_INIT3(CLASS, VER_MAJOR, VER_MINOR)
 
#define TDEFINE_CLASS_INIT(...)
 
#define TDEFINE_CLASS_INIT_NORUNTIME1(CLASS)
 
#define TDEFINE_CLASS_INIT_NORUNTIME3(CLASS, VER_MAJOR, VER_MINOR)
 
#define TDEFINE_CLASS_INIT_NORUNTIME(...)
 
#define TDEFINE_CLASS_COMPILETIME(CLASS, VER_MAJOR, VER_MINOR)
 
#define TDYNAMICCAST(T, OBJECT)
 

Functions

template<class T>
TOSHI_NAMESPACE_END TFORCEINLINE T * TDynamicCast (Toshi::TObject *a_pObject)
 

Macro Definition Documentation

◆ TClassObjectName

#define TClassObjectName   ms_oClass

Definition at line 12 of file TObject.h.

◆ TDECLARE_CLASS

#define TDECLARE_CLASS ( THIS_CLASS,
PARENT_CLASS )
Value:
TDECLARE_CLASS_BODY( THIS_CLASS, PARENT_CLASS ); \
static Toshi::TClass TClassObjectName
#define TClassObjectName
Definition TObject.h:12
#define TDECLARE_CLASS_BODY(THIS_CLASS, PARENT_CLASS)
Definition TObject.h:19

Definition at line 38 of file TObject.h.

38#define TDECLARE_CLASS( THIS_CLASS, PARENT_CLASS ) \
39 TDECLARE_CLASS_BODY( THIS_CLASS, PARENT_CLASS ); \
40 static Toshi::TClass TClassObjectName

◆ TDECLARE_CLASS_BODY

#define TDECLARE_CLASS_BODY ( THIS_CLASS,
PARENT_CLASS )
Value:
public: \
using ThisClass = THIS_CLASS; \
using BaseClass = PARENT_CLASS; \
static constexpr Toshi::TClass* PARENTCLASS = &TGetClass( PARENT_CLASS ); \
\
virtual Toshi::TClass* GetClass() override; \
\
static Toshi::TObject* CreateTObject(); \
static Toshi::TObject* CreateTObjectInPlace( void* a_pPtr ); \
static void InitialiseClass(); \
static void DeinitialiseClass(); \
\
static TFORCEINLINE Toshi::TClass* GetClassStatic() { return std::addressof( TClassObjectName ); }
#define TFORCEINLINE
Definition Defines.h:74
#define TGetClass(CLASS)
Definition TObject.h:13

Definition at line 19 of file TObject.h.

19#define TDECLARE_CLASS_BODY( THIS_CLASS, PARENT_CLASS ) \
20public: \
21 using ThisClass = THIS_CLASS; \
22 using BaseClass = PARENT_CLASS; \
23 static constexpr Toshi::TClass* PARENTCLASS = &TGetClass( PARENT_CLASS ); \
24 \
25 virtual Toshi::TClass* GetClass() override; \
26 \
27 static Toshi::TObject* CreateTObject(); \
28 static Toshi::TObject* CreateTObjectInPlace( void* a_pPtr ); \
29 static void InitialiseClass(); \
30 static void DeinitialiseClass(); \
31 \
32 static TFORCEINLINE Toshi::TClass* GetClassStatic() { return std::addressof( TClassObjectName ); }

◆ TDECLARE_CLASS_COMPILETIME

#define TDECLARE_CLASS_COMPILETIME ( THIS_CLASS,
PARENT_CLASS )
Value:
TDECLARE_CLASS_BODY( THIS_CLASS, PARENT_CLASS ); \
static constinit Toshi::TClass TClassObjectName;

Definition at line 46 of file TObject.h.

46#define TDECLARE_CLASS_COMPILETIME( THIS_CLASS, PARENT_CLASS ) \
47 TDECLARE_CLASS_BODY( THIS_CLASS, PARENT_CLASS ); \
48 static constinit Toshi::TClass TClassObjectName;

◆ TDEFINE_CLASS

#define TDEFINE_CLASS ( ...)
Value:
#define CALL_OVERLOAD(name,...)
Definition Defines.h:25
#define TDEFINE_CLASS(...)
Definition TObject.h:120

Definition at line 120 of file TObject.h.

◆ TDEFINE_CLASS1

#define TDEFINE_CLASS1 ( CLASS)
Value:
TDEFINE_CLASS_FULL( CLASS ) \
Toshi::TClass CLASS::TClassObjectName = Toshi::TClass( #CLASS, CLASS::PARENTCLASS, CLASS::CreateTObject, CLASS::CreateTObjectInPlace, CLASS::InitialiseClass, CLASS::DeinitialiseClass, 0, 1, sizeof( CLASS ), alignof( CLASS ) );
#define TDEFINE_CLASS_FULL(CLASS)
Definition TObject.h:92

Definition at line 121 of file TObject.h.

121#define TDEFINE_CLASS1( CLASS ) \
122 TDEFINE_CLASS_FULL( CLASS ) \
123 Toshi::TClass CLASS::TClassObjectName = Toshi::TClass( #CLASS, CLASS::PARENTCLASS, CLASS::CreateTObject, CLASS::CreateTObjectInPlace, CLASS::InitialiseClass, CLASS::DeinitialiseClass, 0, 1, sizeof( CLASS ), alignof( CLASS ) );

◆ TDEFINE_CLASS3

#define TDEFINE_CLASS3 ( CLASS,
VER_MAJOR,
VER_MINOR )
Value:
TDEFINE_CLASS_FULL( CLASS ) \
Toshi::TClass CLASS::TClassObjectName = Toshi::TClass( #CLASS, CLASS::PARENTCLASS, CLASS::CreateTObject, CLASS::CreateTObjectInPlace, CLASS::InitialiseClass, CLASS::DeinitialiseClass, VER_MAJOR, VER_MINOR, sizeof( CLASS ), alignof( CLASS ) );

Definition at line 124 of file TObject.h.

124#define TDEFINE_CLASS3( CLASS, VER_MAJOR, VER_MINOR ) \
125 TDEFINE_CLASS_FULL( CLASS ) \
126 Toshi::TClass CLASS::TClassObjectName = Toshi::TClass( #CLASS, CLASS::PARENTCLASS, CLASS::CreateTObject, CLASS::CreateTObjectInPlace, CLASS::InitialiseClass, CLASS::DeinitialiseClass, VER_MAJOR, VER_MINOR, sizeof( CLASS ), alignof( CLASS ) );

◆ TDEFINE_CLASS_COMPILETIME

#define TDEFINE_CLASS_COMPILETIME ( CLASS,
VER_MAJOR,
VER_MINOR )
Value:
constinit Toshi::TClass CLASS::TClassObjectName = Toshi::TClass( #CLASS, CLASS::CreateTObject, CLASS::CreateTObjectInPlace, CLASS::InitialiseClass, CLASS::DeinitialiseClass, VER_MAJOR, VER_MINOR, sizeof( CLASS ), alignof( CLASS ) );
#define TDEFINE_CLASS_FULL_COMPILETIME(CLASS)
Definition TObject.h:111

Definition at line 170 of file TObject.h.

170#define TDEFINE_CLASS_COMPILETIME( CLASS, VER_MAJOR, VER_MINOR ) \
171 TDEFINE_CLASS_FULL_COMPILETIME( CLASS ) \
172 constinit Toshi::TClass CLASS::TClassObjectName = Toshi::TClass( #CLASS, CLASS::CreateTObject, CLASS::CreateTObjectInPlace, CLASS::InitialiseClass, CLASS::DeinitialiseClass, VER_MAJOR, VER_MINOR, sizeof( CLASS ), alignof( CLASS ) );

◆ TDEFINE_CLASS_CORE

#define TDEFINE_CLASS_CORE ( CLASS)
Value:
TSTATICASSERT( CLASS::IsTObject ); \
TSTATICASSERT( std::is_base_of<CLASS::BaseClass, CLASS>::value && !std::is_same<CLASS::BaseClass, CLASS>::value ); \
Toshi::TClass* CLASS::GetClass() { return CLASS::GetClassStatic(); } \
Toshi::TObject* CLASS::CreateTObject() { return new CLASS(); } \
Toshi::TObject* CLASS::CreateTObjectInPlace( void* a_pPtr ) { return new ( a_pPtr ) CLASS(); }
#define TSTATICASSERT(...)
Definition Defines.h:67

Definition at line 53 of file TObject.h.

53#define TDEFINE_CLASS_CORE( CLASS ) \
54 TSTATICASSERT( CLASS::IsTObject ); \
55 TSTATICASSERT( std::is_base_of<CLASS::BaseClass, CLASS>::value && !std::is_same<CLASS::BaseClass, CLASS>::value ); \
56 Toshi::TClass* CLASS::GetClass() { return CLASS::GetClassStatic(); } \
57 Toshi::TObject* CLASS::CreateTObject() { return new CLASS(); } \
58 Toshi::TObject* CLASS::CreateTObjectInPlace( void* a_pPtr ) { return new ( a_pPtr ) CLASS(); }

◆ TDEFINE_CLASS_CORE_COMPILETIME

#define TDEFINE_CLASS_CORE_COMPILETIME ( CLASS)
Value:
TSTATICASSERT( CLASS::IsTObject ); \
Toshi::TClass* CLASS::GetClass() { return CLASS::GetClassStatic(); } \
Toshi::TObject* CLASS::CreateTObject() { return new CLASS(); } \
Toshi::TObject* CLASS::CreateTObjectInPlace( void* a_pPtr ) { return new ( a_pPtr ) CLASS(); }

Definition at line 82 of file TObject.h.

82#define TDEFINE_CLASS_CORE_COMPILETIME( CLASS ) \
83 TSTATICASSERT( CLASS::IsTObject ); \
84 Toshi::TClass* CLASS::GetClass() { return CLASS::GetClassStatic(); } \
85 Toshi::TObject* CLASS::CreateTObject() { return new CLASS(); } \
86 Toshi::TObject* CLASS::CreateTObjectInPlace( void* a_pPtr ) { return new ( a_pPtr ) CLASS(); }

◆ TDEFINE_CLASS_CORE_NORUNTIME

#define TDEFINE_CLASS_CORE_NORUNTIME ( CLASS)
Value:
TSTATICASSERT( CLASS::IsTObject ); \
TSTATICASSERT( std::is_base_of<CLASS::BaseClass, CLASS>::value && !std::is_same<CLASS::BaseClass, CLASS>::value ); \
Toshi::TClass* CLASS::GetClass() { return CLASS::GetClassStatic(); } \
Toshi::TObject* CLASS::CreateTObject() \
{ \
TASSERT( TFALSE, "This class cannot be created at runtime!" ); \
return TNULL; \
} \
Toshi::TObject* CLASS::CreateTObjectInPlace( void* a_pPtr ) \
{ \
TASSERT( TFALSE, "This class cannot be created at runtime!" ); \
return TNULL; \
}
#define TNULL
Definition Typedefs.h:23
#define TFALSE
Definition Typedefs.h:24

Definition at line 63 of file TObject.h.

63#define TDEFINE_CLASS_CORE_NORUNTIME( CLASS ) \
64 TSTATICASSERT( CLASS::IsTObject ); \
65 TSTATICASSERT( std::is_base_of<CLASS::BaseClass, CLASS>::value && !std::is_same<CLASS::BaseClass, CLASS>::value ); \
66 Toshi::TClass* CLASS::GetClass() { return CLASS::GetClassStatic(); } \
67 Toshi::TObject* CLASS::CreateTObject() \
68 { \
69 TASSERT( TFALSE, "This class cannot be created at runtime!" ); \
70 return TNULL; \
71 } \
72 Toshi::TObject* CLASS::CreateTObjectInPlace( void* a_pPtr ) \
73 { \
74 TASSERT( TFALSE, "This class cannot be created at runtime!" ); \
75 return TNULL; \
76 }

◆ TDEFINE_CLASS_FULL

#define TDEFINE_CLASS_FULL ( CLASS)
Value:
TDEFINE_CLASS_CORE( CLASS ) \
void CLASS::InitialiseClass() {} \
void CLASS::DeinitialiseClass() {}
#define TDEFINE_CLASS_CORE(CLASS)
Definition TObject.h:53

Definition at line 92 of file TObject.h.

92#define TDEFINE_CLASS_FULL( CLASS ) \
93 TDEFINE_CLASS_CORE( CLASS ) \
94 void CLASS::InitialiseClass() {} \
95 void CLASS::DeinitialiseClass() {}

◆ TDEFINE_CLASS_FULL_COMPILETIME

#define TDEFINE_CLASS_FULL_COMPILETIME ( CLASS)
Value:
void CLASS::InitialiseClass() {} \
void CLASS::DeinitialiseClass() {}
#define TDEFINE_CLASS_CORE_COMPILETIME(CLASS)
Definition TObject.h:82

Definition at line 111 of file TObject.h.

111#define TDEFINE_CLASS_FULL_COMPILETIME( CLASS ) \
112 TDEFINE_CLASS_CORE_COMPILETIME( CLASS ) \
113 void CLASS::InitialiseClass() {} \
114 void CLASS::DeinitialiseClass() {}

◆ TDEFINE_CLASS_FULL_NORUNTIME

#define TDEFINE_CLASS_FULL_NORUNTIME ( CLASS)
Value:
void CLASS::InitialiseClass() {} \
void CLASS::DeinitialiseClass() {}
#define TDEFINE_CLASS_CORE_NORUNTIME(CLASS)
Definition TObject.h:63

Definition at line 101 of file TObject.h.

101#define TDEFINE_CLASS_FULL_NORUNTIME( CLASS ) \
102 TDEFINE_CLASS_CORE_NORUNTIME( CLASS ) \
103 void CLASS::InitialiseClass() {} \
104 void CLASS::DeinitialiseClass() {}

◆ TDEFINE_CLASS_INIT

#define TDEFINE_CLASS_INIT ( ...)
Value:
#define TDEFINE_CLASS_INIT(...)
Definition TObject.h:151

Definition at line 151 of file TObject.h.

◆ TDEFINE_CLASS_INIT1

#define TDEFINE_CLASS_INIT1 ( CLASS)
Value:
TDEFINE_CLASS_CORE( CLASS ) \
Toshi::TClass CLASS::TClassObjectName = Toshi::TClass( #CLASS, CLASS::PARENTCLASS, CLASS::CreateTObject, CLASS::CreateTObjectInPlace, CLASS::InitialiseClass, CLASS::DeinitialiseClass, 0, 1, sizeof( CLASS ), alignof( CLASS ) );

Definition at line 145 of file TObject.h.

145#define TDEFINE_CLASS_INIT1( CLASS ) \
146 TDEFINE_CLASS_CORE( CLASS ) \
147 Toshi::TClass CLASS::TClassObjectName = Toshi::TClass( #CLASS, CLASS::PARENTCLASS, CLASS::CreateTObject, CLASS::CreateTObjectInPlace, CLASS::InitialiseClass, CLASS::DeinitialiseClass, 0, 1, sizeof( CLASS ), alignof( CLASS ) );

◆ TDEFINE_CLASS_INIT3

#define TDEFINE_CLASS_INIT3 ( CLASS,
VER_MAJOR,
VER_MINOR )
Value:
TDEFINE_CLASS_CORE( CLASS ) \
Toshi::TClass CLASS::TClassObjectName = Toshi::TClass( #CLASS, CLASS::PARENTCLASS, CLASS::CreateTObject, CLASS::CreateTObjectInPlace, CLASS::InitialiseClass, CLASS::DeinitialiseClass, VER_MAJOR, VER_MINOR, sizeof( CLASS ), alignof( CLASS ) );

Definition at line 148 of file TObject.h.

148#define TDEFINE_CLASS_INIT3( CLASS, VER_MAJOR, VER_MINOR ) \
149 TDEFINE_CLASS_CORE( CLASS ) \
150 Toshi::TClass CLASS::TClassObjectName = Toshi::TClass( #CLASS, CLASS::PARENTCLASS, CLASS::CreateTObject, CLASS::CreateTObjectInPlace, CLASS::InitialiseClass, CLASS::DeinitialiseClass, VER_MAJOR, VER_MINOR, sizeof( CLASS ), alignof( CLASS ) );

◆ TDEFINE_CLASS_INIT_NORUNTIME

#define TDEFINE_CLASS_INIT_NORUNTIME ( ...)
Value:
#define TDEFINE_CLASS_INIT_NORUNTIME(...)
Definition TObject.h:164

Definition at line 164 of file TObject.h.

◆ TDEFINE_CLASS_INIT_NORUNTIME1

#define TDEFINE_CLASS_INIT_NORUNTIME1 ( CLASS)
Value:
Toshi::TClass CLASS::TClassObjectName = Toshi::TClass( #CLASS, CLASS::PARENTCLASS, CLASS::CreateTObject, CLASS::CreateTObjectInPlace, CLASS::InitialiseClass, CLASS::DeinitialiseClass, 0, 1, sizeof( CLASS ), alignof( CLASS ) );

Definition at line 158 of file TObject.h.

158#define TDEFINE_CLASS_INIT_NORUNTIME1( CLASS ) \
159 TDEFINE_CLASS_CORE_NORUNTIME( CLASS ) \
160 Toshi::TClass CLASS::TClassObjectName = Toshi::TClass( #CLASS, CLASS::PARENTCLASS, CLASS::CreateTObject, CLASS::CreateTObjectInPlace, CLASS::InitialiseClass, CLASS::DeinitialiseClass, 0, 1, sizeof( CLASS ), alignof( CLASS ) );

◆ TDEFINE_CLASS_INIT_NORUNTIME3

#define TDEFINE_CLASS_INIT_NORUNTIME3 ( CLASS,
VER_MAJOR,
VER_MINOR )
Value:
Toshi::TClass CLASS::TClassObjectName = Toshi::TClass( #CLASS, CLASS::PARENTCLASS, CLASS::CreateTObject, CLASS::CreateTObjectInPlace, CLASS::InitialiseClass, CLASS::DeinitialiseClass, VER_MAJOR, VER_MINOR, sizeof( CLASS ), alignof( CLASS ) );

Definition at line 161 of file TObject.h.

161#define TDEFINE_CLASS_INIT_NORUNTIME3( CLASS, VER_MAJOR, VER_MINOR ) \
162 TDEFINE_CLASS_CORE_NORUNTIME( CLASS ) \
163 Toshi::TClass CLASS::TClassObjectName = Toshi::TClass( #CLASS, CLASS::PARENTCLASS, CLASS::CreateTObject, CLASS::CreateTObjectInPlace, CLASS::InitialiseClass, CLASS::DeinitialiseClass, VER_MAJOR, VER_MINOR, sizeof( CLASS ), alignof( CLASS ) );

◆ TDEFINE_CLASS_NORUNTIME

#define TDEFINE_CLASS_NORUNTIME ( ...)
Value:
#define TDEFINE_CLASS_NORUNTIME(...)
Definition TObject.h:138

Definition at line 138 of file TObject.h.

◆ TDEFINE_CLASS_NORUNTIME1

#define TDEFINE_CLASS_NORUNTIME1 ( CLASS)
Value:
Toshi::TClass CLASS::TClassObjectName = Toshi::TClass( #CLASS, CLASS::PARENTCLASS, CLASS::CreateTObject, CLASS::CreateTObjectInPlace, CLASS::InitialiseClass, CLASS::DeinitialiseClass, 0, 1, sizeof( CLASS ), alignof( CLASS ) );
#define TDEFINE_CLASS_FULL_NORUNTIME(CLASS)
Definition TObject.h:101

Definition at line 132 of file TObject.h.

132#define TDEFINE_CLASS_NORUNTIME1( CLASS ) \
133 TDEFINE_CLASS_FULL_NORUNTIME( CLASS ) \
134 Toshi::TClass CLASS::TClassObjectName = Toshi::TClass( #CLASS, CLASS::PARENTCLASS, CLASS::CreateTObject, CLASS::CreateTObjectInPlace, CLASS::InitialiseClass, CLASS::DeinitialiseClass, 0, 1, sizeof( CLASS ), alignof( CLASS ) );

◆ TDEFINE_CLASS_NORUNTIME3

#define TDEFINE_CLASS_NORUNTIME3 ( CLASS,
VER_MAJOR,
VER_MINOR )
Value:
Toshi::TClass CLASS::TClassObjectName = Toshi::TClass( #CLASS, CLASS::PARENTCLASS, CLASS::CreateTObject, CLASS::CreateTObjectInPlace, CLASS::InitialiseClass, CLASS::DeinitialiseClass, VER_MAJOR, VER_MINOR, sizeof( CLASS ), alignof( CLASS ) );

Definition at line 135 of file TObject.h.

135#define TDEFINE_CLASS_NORUNTIME3( CLASS, VER_MAJOR, VER_MINOR ) \
136 TDEFINE_CLASS_FULL_NORUNTIME( CLASS ) \
137 Toshi::TClass CLASS::TClassObjectName = Toshi::TClass( #CLASS, CLASS::PARENTCLASS, CLASS::CreateTObject, CLASS::CreateTObjectInPlace, CLASS::InitialiseClass, CLASS::DeinitialiseClass, VER_MAJOR, VER_MINOR, sizeof( CLASS ), alignof( CLASS ) );

◆ TDYNAMICCAST

#define TDYNAMICCAST ( T,
OBJECT )
Value:
( TDynamicCast<T>( OBJECT ) )
TOSHI_NAMESPACE_END TFORCEINLINE T * TDynamicCast(Toshi::TObject *a_pObject)
Definition TObject.h:212

Definition at line 227 of file TObject.h.

◆ TGetClass

#define TGetClass ( CLASS)
Value:
CLASS::TClassObjectName

Definition at line 13 of file TObject.h.

Function Documentation

◆ TDynamicCast()

template<class T>
TOSHI_NAMESPACE_END TFORCEINLINE T * TDynamicCast ( Toshi::TObject * a_pObject)

Definition at line 212 of file TObject.h.

213{
214 TSTATICASSERT( T::IsTObject );
215
216 if ( a_pObject )
217 {
218 if ( a_pObject->IsA( &TGetClass( T ) ) )
219 {
220 return TSTATICCAST( T, a_pObject );
221 }
222 }
223
224 return TNULL;
225}
#define TSTATICCAST(POINTERTYPE, VALUE)
Definition Defines.h:69