138 inline const char *
GetName()
const {
return mName; }
141 bool IsAbstract()
const {
return mCreate ==
nullptr || mDestruct ==
nullptr; }
142 int GetBaseClassCount()
const;
143 const RTTI * GetBaseClass(
int inIdx)
const;
147 void * CreateObject()
const;
150 void DestructObject(
void *
inObject)
const;
156 bool operator == (
const RTTI &
inRHS)
const;
167 int GetAttributeCount()
const;
191#define JPH_DECLARE_RTTI_NON_VIRTUAL(linkage, class_name) \
193 JPH_OVERRIDE_NEW_DELETE \
194 friend linkage RTTI * GetRTTIOfType(class_name *); \
195 friend inline const RTTI * GetRTTI([[maybe_unused]] const class_name *inObject) { return GetRTTIOfType(static_cast<class_name *>(nullptr)); }\
196 static void sCreateRTTI(RTTI &inRTTI); \
199#define JPH_IMPLEMENT_RTTI_NON_VIRTUAL(class_name) \
200 RTTI * GetRTTIOfType(class_name *) \
202 static RTTI rtti(#class_name, sizeof(class_name), []() -> void * { return new class_name; }, [](void *inObject) { delete (class_name *)inObject; }, &class_name::sCreateRTTI); \
205 void class_name::sCreateRTTI(RTTI &inRTTI) \
213#define JPH_DECLARE_RTTI_OUTSIDE_CLASS(linkage, class_name) \
214 linkage RTTI * GetRTTIOfType(class_name *); \
215 inline const RTTI * GetRTTI(const class_name *inObject) { return GetRTTIOfType((class_name *)nullptr); }\
216 void CreateRTTI##class_name(RTTI &inRTTI); \
219#define JPH_IMPLEMENT_RTTI_OUTSIDE_CLASS(class_name) \
220 RTTI * GetRTTIOfType(class_name *) \
222 static RTTI rtti((const char *)#class_name, sizeof(class_name), []() -> void * { return new class_name; }, [](void *inObject) { delete (class_name *)inObject; }, &CreateRTTI##class_name); \
225 void CreateRTTI##class_name(RTTI &inRTTI)
231#define JPH_DECLARE_RTTI_HELPER(linkage, class_name, modifier) \
233 JPH_OVERRIDE_NEW_DELETE \
234 friend linkage RTTI * GetRTTIOfType(class_name *); \
235 friend inline const RTTI * GetRTTI(const class_name *inObject) { return inObject->GetRTTI(); } \
236 virtual const RTTI * GetRTTI() const modifier; \
237 virtual const void * CastTo(const RTTI *inRTTI) const modifier; \
238 static void sCreateRTTI(RTTI &inRTTI); \
241#define JPH_DECLARE_RTTI_VIRTUAL(linkage, class_name) \
242 JPH_DECLARE_RTTI_HELPER(linkage, class_name, override)
245#define JPH_IMPLEMENT_RTTI_VIRTUAL(class_name) \
246 RTTI * GetRTTIOfType(class_name *) \
248 static RTTI rtti(#class_name, sizeof(class_name), []() -> void * { return new class_name; }, [](void *inObject) { delete (class_name *)inObject; }, &class_name::sCreateRTTI); \
251 const RTTI * class_name::GetRTTI() const \
253 return JPH_RTTI(class_name); \
255 const void * class_name::CastTo(const RTTI *inRTTI) const \
257 return JPH_RTTI(class_name)->CastTo((const void *)this, inRTTI); \
259 void class_name::sCreateRTTI(RTTI &inRTTI) \
262#define JPH_DECLARE_RTTI_VIRTUAL_BASE(linkage, class_name) \
263 JPH_DECLARE_RTTI_HELPER(linkage, class_name, )
266#define JPH_IMPLEMENT_RTTI_VIRTUAL_BASE(class_name) \
267 JPH_IMPLEMENT_RTTI_VIRTUAL(class_name)
270#define JPH_DECLARE_RTTI_ABSTRACT(linkage, class_name) \
271 JPH_DECLARE_RTTI_HELPER(linkage, class_name, override)
274#define JPH_IMPLEMENT_RTTI_ABSTRACT(class_name) \
275 RTTI * GetRTTIOfType(class_name *) \
277 static RTTI rtti(#class_name, sizeof(class_name), nullptr, [](void *inObject) { delete (class_name *)inObject; }, &class_name::sCreateRTTI); \
280 const RTTI * class_name::GetRTTI() const \
282 return JPH_RTTI(class_name); \
284 const void * class_name::CastTo(const RTTI *inRTTI) const \
286 return JPH_RTTI(class_name)->CastTo((const void *)this, inRTTI); \
288 void class_name::sCreateRTTI(RTTI &inRTTI) \
291#define JPH_DECLARE_RTTI_ABSTRACT_BASE(linkage, class_name) \
292 JPH_DECLARE_RTTI_HELPER(linkage, class_name, )
295#define JPH_IMPLEMENT_RTTI_ABSTRACT_BASE(class_name) \
296 JPH_IMPLEMENT_RTTI_ABSTRACT(class_name)
302#define JPH_DECLARE_RTTI_FOR_FACTORY(linkage, class_name) \
303 linkage RTTI * GetRTTIOfType(class class_name *);
305#define JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(linkage, name_space, class_name) \
306 namespace name_space { \
308 linkage RTTI * GetRTTIOfType(class class_name *); \
315#define JPH_RTTI(class_name) GetRTTIOfType(static_cast<class_name *>(nullptr))
326#define JPH_RENAME_CLASS(class_name, new_name) \
327 inRTTI.SetName(#new_name);
334#define JPH_BASE_CLASS_OFFSET(inClass, inBaseClass) ((int(uint64((inBaseClass *)((inClass *)0x10000))))-0x10000)
337#define JPH_ADD_BASE_CLASS(class_name, base_class_name) \
338 inRTTI.AddBaseClass(JPH_RTTI(base_class_name), JPH_BASE_CLASS_OFFSET(class_name, base_class_name));
383template <
class DstType,
class SrcType>
390template <
class DstType,
class SrcType>
397template <
class DstType,
class SrcType>
404template <
class DstType,
class SrcType>
412template <
class DstType,
class SrcType>
418template <
class DstType,
class SrcType>
424template <
class DstType,
class SrcType>
430template <
class DstType,
class SrcType>
#define JPH_EXPORT
Definition Core.h:227
#define JPH_NAMESPACE_END
Definition Core.h:367
std::uint32_t uint32
Definition Core.h:442
#define JPH_NAMESPACE_BEGIN
Definition Core.h:361
#define JPH_ASSERT(...)
Definition IssueReporting.h:33
AllocateFunction Allocate
Definition Memory.cpp:59
const DstType * StaticCast(const SrcType *inObject)
Cast inObject to DstType, asserts on failure.
Definition RTTI.h:384
bool IsType(const Type *inObject, const RTTI *inRTTI)
Check if inObject is of DstType.
Definition RTTI.h:346
bool IsKindOf(const Type *inObject, const RTTI *inRTTI)
Check if inObject is or is derived from DstType.
Definition RTTI.h:365
#define JPH_RTTI(class_name)
Definition RTTI.h:315
const DstType * DynamicCast(const SrcType *inObject)
Cast inObject to DstType, returns nullptr on failure.
Definition RTTI.h:413
pDestructObjectFunction mDestruct
Pointer to a function that will destruct an object of this class.
Definition RTTI.h:182
pCreateObjectFunction mCreate
Pointer to a function that will create a new instance of this class.
Definition RTTI.h:181
const char * GetName() const
Definition RTTI.h:138
StaticArray< SerializableAttribute, 32 > mAttributes
All attributes of this class.
Definition RTTI.h:183
void *(*)() pCreateObjectFunction
Function to create an object.
Definition RTTI.h:125
StaticArray< BaseClass, 4 > mBaseClasses
Names of base classes.
Definition RTTI.h:180
int GetSize() const
Definition RTTI.h:140
bool IsAbstract() const
Definition RTTI.h:141
void(*)(RTTI &inRTTI) pCreateRTTIFunction
Function to initialize the runtime type info structure.
Definition RTTI.h:131
void(*)(void *inObject) pDestructObjectFunction
Function to destroy an object.
Definition RTTI.h:128
void SetName(const char *inName)
Definition RTTI.h:139
const char * mName
Class name.
Definition RTTI.h:178
int mSize
Class size.
Definition RTTI.h:179
Definition Reference.h:151
Definition Reference.h:101
Attributes are members of classes that need to be serialized.
Definition SerializableAttribute.h:35
Simple variable length array backed by a fixed size buffer.
Definition StaticArray.h:12
Base class information.
Definition RTTI.h:173
const RTTI * mRTTI
Definition RTTI.h:174
int mOffset
Definition RTTI.h:175