Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
RTTI.h File Reference

Go to the source code of this file.

Classes

class  RTTI
 
struct  RTTI::BaseClass
 Base class information. More...
 

Macros

#define JPH_DECLARE_RTTI_NON_VIRTUAL(linkage, class_name)
 
#define JPH_IMPLEMENT_RTTI_NON_VIRTUAL(class_name)
 
#define JPH_DECLARE_RTTI_OUTSIDE_CLASS(linkage, class_name)
 
#define JPH_IMPLEMENT_RTTI_OUTSIDE_CLASS(class_name)
 
#define JPH_DECLARE_RTTI_HELPER(linkage, class_name, modifier)
 
#define JPH_DECLARE_RTTI_VIRTUAL(linkage, class_name)    JPH_DECLARE_RTTI_HELPER(linkage, class_name, override)
 
#define JPH_IMPLEMENT_RTTI_VIRTUAL(class_name)
 
#define JPH_DECLARE_RTTI_VIRTUAL_BASE(linkage, class_name)    JPH_DECLARE_RTTI_HELPER(linkage, class_name, )
 
#define JPH_IMPLEMENT_RTTI_VIRTUAL_BASE(class_name)    JPH_IMPLEMENT_RTTI_VIRTUAL(class_name)
 
#define JPH_DECLARE_RTTI_ABSTRACT(linkage, class_name)    JPH_DECLARE_RTTI_HELPER(linkage, class_name, override)
 
#define JPH_IMPLEMENT_RTTI_ABSTRACT(class_name)
 
#define JPH_DECLARE_RTTI_ABSTRACT_BASE(linkage, class_name)    JPH_DECLARE_RTTI_HELPER(linkage, class_name, )
 
#define JPH_IMPLEMENT_RTTI_ABSTRACT_BASE(class_name)    JPH_IMPLEMENT_RTTI_ABSTRACT(class_name)
 
#define JPH_DECLARE_RTTI_FOR_FACTORY(linkage, class_name)    linkage RTTI * GetRTTIOfType(class class_name *);
 
#define JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(linkage, name_space, class_name)
 
#define JPH_RTTI(class_name)   GetRTTIOfType(static_cast<class_name *>(nullptr))
 
#define JPH_RENAME_CLASS(class_name, new_name)    inRTTI.SetName(#new_name);
 
#define JPH_BASE_CLASS_OFFSET(inClass, inBaseClass)   ((int(uint64((inBaseClass *)((inClass *)0x10000))))-0x10000)
 Define very dirty macro to get the offset of a baseclass into a class.
 
#define JPH_ADD_BASE_CLASS(class_name, base_class_name)    inRTTI.AddBaseClass(JPH_RTTI(base_class_name), JPH_BASE_CLASS_OFFSET(class_name, base_class_name));
 

Functions

template<class Type >
bool IsType (const Type *inObject, const RTTI *inRTTI)
 Check if inObject is of DstType.
 
template<class Type >
bool IsType (const RefConst< Type > &inObject, const RTTI *inRTTI)
 
template<class Type >
bool IsType (const Ref< Type > &inObject, const RTTI *inRTTI)
 
template<class Type >
bool IsKindOf (const Type *inObject, const RTTI *inRTTI)
 Check if inObject is or is derived from DstType.
 
template<class Type >
bool IsKindOf (const RefConst< Type > &inObject, const RTTI *inRTTI)
 
template<class Type >
bool IsKindOf (const Ref< Type > &inObject, const RTTI *inRTTI)
 
template<class DstType , class SrcType , std::enable_if_t< std::is_base_of_v< DstType, SrcType >||std::is_base_of_v< SrcType, DstType >, bool > = true>
const DstType * StaticCast (const SrcType *inObject)
 Cast inObject to DstType, asserts on failure.
 
template<class DstType , class SrcType , std::enable_if_t< std::is_base_of_v< DstType, SrcType >||std::is_base_of_v< SrcType, DstType >, bool > = true>
DstType * StaticCast (SrcType *inObject)
 
template<class DstType , class SrcType , std::enable_if_t< std::is_base_of_v< DstType, SrcType >||std::is_base_of_v< SrcType, DstType >, bool > = true>
const DstType * StaticCast (const RefConst< SrcType > &inObject)
 
template<class DstType , class SrcType , std::enable_if_t< std::is_base_of_v< DstType, SrcType >||std::is_base_of_v< SrcType, DstType >, bool > = true>
DstType * StaticCast (const Ref< SrcType > &inObject)
 
template<class DstType , class SrcType >
const DstType * DynamicCast (const SrcType *inObject)
 Cast inObject to DstType, returns nullptr on failure.
 
template<class DstType , class SrcType >
DstType * DynamicCast (SrcType *inObject)
 
template<class DstType , class SrcType >
const DstType * DynamicCast (const RefConst< SrcType > &inObject)
 
template<class DstType , class SrcType >
DstType * DynamicCast (const Ref< SrcType > &inObject)
 

Macro Definition Documentation

◆ JPH_ADD_BASE_CLASS

#define JPH_ADD_BASE_CLASS (   class_name,
  base_class_name 
)     inRTTI.AddBaseClass(JPH_RTTI(base_class_name), JPH_BASE_CLASS_OFFSET(class_name, base_class_name));

◆ JPH_BASE_CLASS_OFFSET

#define JPH_BASE_CLASS_OFFSET (   inClass,
  inBaseClass 
)    ((int(uint64((inBaseClass *)((inClass *)0x10000))))-0x10000)

Define very dirty macro to get the offset of a baseclass into a class.

◆ JPH_DECLARE_RTTI_ABSTRACT

#define JPH_DECLARE_RTTI_ABSTRACT (   linkage,
  class_name 
)     JPH_DECLARE_RTTI_HELPER(linkage, class_name, override)

◆ JPH_DECLARE_RTTI_ABSTRACT_BASE

#define JPH_DECLARE_RTTI_ABSTRACT_BASE (   linkage,
  class_name 
)     JPH_DECLARE_RTTI_HELPER(linkage, class_name, )

◆ JPH_DECLARE_RTTI_FOR_FACTORY

#define JPH_DECLARE_RTTI_FOR_FACTORY (   linkage,
  class_name 
)     linkage RTTI * GetRTTIOfType(class class_name *);

◆ JPH_DECLARE_RTTI_HELPER

#define JPH_DECLARE_RTTI_HELPER (   linkage,
  class_name,
  modifier 
)
Value:
public: \
JPH_OVERRIDE_NEW_DELETE \
friend linkage RTTI * GetRTTIOfType(class_name *); \
friend inline const RTTI * GetRTTI(const class_name *inObject) { return inObject->GetRTTI(); } \
virtual const RTTI * GetRTTI() const modifier; \
virtual const void * CastTo(const RTTI *inRTTI) const modifier; \
static void sCreateRTTI(RTTI &inRTTI); \
Definition RTTI.h:122

◆ JPH_DECLARE_RTTI_NON_VIRTUAL

#define JPH_DECLARE_RTTI_NON_VIRTUAL (   linkage,
  class_name 
)
Value:
public: \
JPH_OVERRIDE_NEW_DELETE \
friend linkage RTTI * GetRTTIOfType(class_name *); \
friend inline const RTTI * GetRTTI([[maybe_unused]] const class_name *inObject) { return GetRTTIOfType(static_cast<class_name *>(nullptr)); }\
static void sCreateRTTI(RTTI &inRTTI); \

◆ JPH_DECLARE_RTTI_OUTSIDE_CLASS

#define JPH_DECLARE_RTTI_OUTSIDE_CLASS (   linkage,
  class_name 
)
Value:
linkage RTTI * GetRTTIOfType(class_name *); \
inline const RTTI * GetRTTI(const class_name *inObject) { return GetRTTIOfType((class_name *)nullptr); }\
void CreateRTTI##class_name(RTTI &inRTTI); \

◆ JPH_DECLARE_RTTI_VIRTUAL

#define JPH_DECLARE_RTTI_VIRTUAL (   linkage,
  class_name 
)     JPH_DECLARE_RTTI_HELPER(linkage, class_name, override)

◆ JPH_DECLARE_RTTI_VIRTUAL_BASE

#define JPH_DECLARE_RTTI_VIRTUAL_BASE (   linkage,
  class_name 
)     JPH_DECLARE_RTTI_HELPER(linkage, class_name, )

◆ JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY

#define JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY (   linkage,
  name_space,
  class_name 
)
Value:
namespace name_space { \
class class_name; \
linkage RTTI * GetRTTIOfType(class class_name *); \
}

◆ JPH_IMPLEMENT_RTTI_ABSTRACT

#define JPH_IMPLEMENT_RTTI_ABSTRACT (   class_name)
Value:
RTTI * GetRTTIOfType(class_name *) \
{ \
static RTTI rtti(#class_name, sizeof(class_name), nullptr, [](void *inObject) { delete (class_name *)inObject; }, &class_name::sCreateRTTI); \
return &rtti; \
} \
const RTTI * class_name::GetRTTI() const \
{ \
return JPH_RTTI(class_name); \
} \
const void * class_name::CastTo(const RTTI *inRTTI) const \
{ \
return JPH_RTTI(class_name)->CastTo((const void *)this, inRTTI); \
} \
void class_name::sCreateRTTI(RTTI &inRTTI) \
#define JPH_RTTI(class_name)
Definition RTTI.h:319

◆ JPH_IMPLEMENT_RTTI_ABSTRACT_BASE

#define JPH_IMPLEMENT_RTTI_ABSTRACT_BASE (   class_name)     JPH_IMPLEMENT_RTTI_ABSTRACT(class_name)

◆ JPH_IMPLEMENT_RTTI_NON_VIRTUAL

#define JPH_IMPLEMENT_RTTI_NON_VIRTUAL (   class_name)
Value:
RTTI * GetRTTIOfType(class_name *) \
{ \
static RTTI rtti(#class_name, sizeof(class_name), []() -> void * { return new class_name; }, [](void *inObject) { delete (class_name *)inObject; }, &class_name::sCreateRTTI); \
return &rtti; \
} \
void class_name::sCreateRTTI(RTTI &inRTTI) \

◆ JPH_IMPLEMENT_RTTI_OUTSIDE_CLASS

#define JPH_IMPLEMENT_RTTI_OUTSIDE_CLASS (   class_name)
Value:
RTTI * GetRTTIOfType(class_name *) \
{ \
static RTTI rtti((const char *)#class_name, sizeof(class_name), []() -> void * { return new class_name; }, [](void *inObject) { delete (class_name *)inObject; }, &CreateRTTI##class_name); \
return &rtti; \
} \
void CreateRTTI##class_name(RTTI &inRTTI)

◆ JPH_IMPLEMENT_RTTI_VIRTUAL

#define JPH_IMPLEMENT_RTTI_VIRTUAL (   class_name)
Value:
RTTI * GetRTTIOfType(class_name *) \
{ \
static RTTI rtti(#class_name, sizeof(class_name), []() -> void * { return new class_name; }, [](void *inObject) { delete (class_name *)inObject; }, &class_name::sCreateRTTI); \
return &rtti; \
} \
const RTTI * class_name::GetRTTI() const \
{ \
return JPH_RTTI(class_name); \
} \
const void * class_name::CastTo(const RTTI *inRTTI) const \
{ \
return JPH_RTTI(class_name)->CastTo((const void *)this, inRTTI); \
} \
void class_name::sCreateRTTI(RTTI &inRTTI) \

◆ JPH_IMPLEMENT_RTTI_VIRTUAL_BASE

#define JPH_IMPLEMENT_RTTI_VIRTUAL_BASE (   class_name)     JPH_IMPLEMENT_RTTI_VIRTUAL(class_name)

◆ JPH_RENAME_CLASS

#define JPH_RENAME_CLASS (   class_name,
  new_name 
)     inRTTI.SetName(#new_name);

◆ JPH_RTTI

#define JPH_RTTI (   class_name)    GetRTTIOfType(static_cast<class_name *>(nullptr))

Function Documentation

◆ DynamicCast() [1/4]

template<class DstType , class SrcType >
DstType * DynamicCast ( const Ref< SrcType > &  inObject)
inline

◆ DynamicCast() [2/4]

template<class DstType , class SrcType >
const DstType * DynamicCast ( const RefConst< SrcType > &  inObject)
inline

◆ DynamicCast() [3/4]

template<class DstType , class SrcType >
const DstType * DynamicCast ( const SrcType *  inObject)
inline

Cast inObject to DstType, returns nullptr on failure.

◆ DynamicCast() [4/4]

template<class DstType , class SrcType >
DstType * DynamicCast ( SrcType *  inObject)
inline

◆ IsKindOf() [1/3]

template<class Type >
bool IsKindOf ( const Ref< Type > &  inObject,
const RTTI inRTTI 
)
inline

◆ IsKindOf() [2/3]

template<class Type >
bool IsKindOf ( const RefConst< Type > &  inObject,
const RTTI inRTTI 
)
inline

◆ IsKindOf() [3/3]

template<class Type >
bool IsKindOf ( const Type *  inObject,
const RTTI inRTTI 
)
inline

Check if inObject is or is derived from DstType.

◆ IsType() [1/3]

template<class Type >
bool IsType ( const Ref< Type > &  inObject,
const RTTI inRTTI 
)
inline

◆ IsType() [2/3]

template<class Type >
bool IsType ( const RefConst< Type > &  inObject,
const RTTI inRTTI 
)
inline

◆ IsType() [3/3]

template<class Type >
bool IsType ( const Type *  inObject,
const RTTI inRTTI 
)
inline

Check if inObject is of DstType.

◆ StaticCast() [1/4]

template<class DstType , class SrcType , std::enable_if_t< std::is_base_of_v< DstType, SrcType >||std::is_base_of_v< SrcType, DstType >, bool > = true>
DstType * StaticCast ( const Ref< SrcType > &  inObject)
inline

◆ StaticCast() [2/4]

template<class DstType , class SrcType , std::enable_if_t< std::is_base_of_v< DstType, SrcType >||std::is_base_of_v< SrcType, DstType >, bool > = true>
const DstType * StaticCast ( const RefConst< SrcType > &  inObject)
inline

◆ StaticCast() [3/4]

template<class DstType , class SrcType , std::enable_if_t< std::is_base_of_v< DstType, SrcType >||std::is_base_of_v< SrcType, DstType >, bool > = true>
const DstType * StaticCast ( const SrcType *  inObject)
inline

Cast inObject to DstType, asserts on failure.

◆ StaticCast() [4/4]

template<class DstType , class SrcType , std::enable_if_t< std::is_base_of_v< DstType, SrcType >||std::is_base_of_v< SrcType, DstType >, bool > = true>
DstType * StaticCast ( SrcType *  inObject)
inline