![]() |
ezEngine Release 26.3
|
Core class of ezEngine's reflection system that holds complete runtime type information. More...
#include <RTTI.h>

Classes | |
| struct | ForEachOptions |
Public Types | |
| using | PredicateFunc = ezDelegate< bool(const ezRTTI *), 48 > |
| using | VisitorFunc = ezDelegate< void(const ezRTTI *), 48 > |
Public Member Functions | |
| ezRTTI (ezStringView sName, const ezRTTI *pParentType, ezUInt32 uiTypeSize, ezUInt32 uiTypeVersion, ezUInt8 uiVariantType, ezBitflags< ezTypeFlags > flags, ezRTTIAllocator *pAllocator, ezArrayPtr< const ezAbstractProperty * > properties, ezArrayPtr< const ezAbstractFunctionProperty * > functions, ezArrayPtr< const ezPropertyAttribute * > attributes, ezArrayPtr< ezAbstractMessageHandler * > messageHandlers, ezArrayPtr< ezMessageSenderInfo > messageSenders, const ezRTTI *(*fnVerifyParent)()) | |
| The constructor requires all the information about the type that this object represents. | |
| void | VerifyCorrectness () const |
| Can be called in debug builds to check that all reflected objects are correctly set up. | |
| EZ_ALWAYS_INLINE ezStringView | GetTypeName () const |
| Returns the name of this type. | |
| EZ_ALWAYS_INLINE ezUInt64 | GetTypeNameHash () const |
| Returns the hash of the name of this type. | |
| EZ_ALWAYS_INLINE const ezRTTI * | GetParentType () const |
| Returns the type that is the base class of this type. May be nullptr if this type has no base class. | |
| EZ_ALWAYS_INLINE ezVariantType::Enum | GetVariantType () const |
| Returns the corresponding variant type for this type or Invalid if there is none. | |
| EZ_ALWAYS_INLINE bool | IsDerivedFrom (const ezRTTI *pBaseType) const |
| Fast O(1) check if this type is derived from the given type (or is the same type). | |
| template<typename BASE > | |
| EZ_ALWAYS_INLINE bool | IsDerivedFrom () const |
| Returns true if this type is derived from or identical to the given type. | |
| EZ_ALWAYS_INLINE ezRTTIAllocator * | GetAllocator () const |
| Returns the object through which instances of this type can be allocated. | |
| EZ_ALWAYS_INLINE ezArrayPtr< const ezAbstractProperty *const > | GetProperties () const |
| Returns the array of properties that this type has. Does NOT include properties from base classes. | |
| EZ_ALWAYS_INLINE ezArrayPtr< const ezAbstractFunctionProperty *const > | GetFunctions () const |
| EZ_ALWAYS_INLINE ezArrayPtr< const ezPropertyAttribute *const > | GetAttributes () const |
| template<typename Type > | |
| const Type * | GetAttributeByType () const |
| Returns the first attribute that derives from the given type, or nullptr if nothing is found. | |
| void | GetAllProperties (ezDynamicArray< const ezAbstractProperty * > &out_properties) const |
| Returns the list of properties that this type has, including derived properties from all base classes. | |
| EZ_ALWAYS_INLINE ezUInt32 | GetTypeSize () const |
| Returns the size (in bytes) of an instance of this type. | |
| EZ_ALWAYS_INLINE ezUInt32 | GetTypeVersion () const |
| Returns the version number of this type. | |
| EZ_ALWAYS_INLINE const ezBitflags< ezTypeFlags > & | GetTypeFlags () const |
| Returns the type flags. | |
| const ezAbstractProperty * | FindPropertyByName (ezStringView sName, bool bSearchBaseTypes=true) const |
| Will iterate over all properties of this type and (optionally) the base types to search for a property with the given name. | |
| EZ_ALWAYS_INLINE ezStringView | GetPluginName () const |
| Returns the name of the plugin which this type is declared in. | |
| EZ_ALWAYS_INLINE const ezArrayPtr< ezAbstractMessageHandler * > & | GetMessageHandlers () const |
| Returns the array of message handlers that this type has. | |
| bool | DispatchMessage (void *pInstance, ezMessage &ref_msg) const |
| Dispatches a message to the appropriate handler for this type. | |
| bool | DispatchMessage (const void *pInstance, ezMessage &ref_msg) const |
| Dispatches a message to the appropriate handler (const version). | |
| template<typename MessageType > | |
| EZ_ALWAYS_INLINE bool | CanHandleMessage () const |
| Returns whether this type can handle the given message type. | |
| bool | CanHandleMessage (ezMessageId id) const |
| Returns whether this type can handle the message type with the given id. | |
| EZ_ALWAYS_INLINE const ezArrayPtr< ezMessageSenderInfo > & | GetMessageSender () const |
Static Public Member Functions | |
| static void | VerifyCorrectnessForAllTypes () |
| Calls VerifyCorrectness() on all ezRTTI objects. | |
| static const ezRTTI * | FindTypeByName (ezStringView sName) |
| Searches all ezRTTI instances for the one with the given name, or nullptr if no such type exists. | |
| static const ezRTTI * | FindTypeByNameHash (ezUInt64 uiNameHash) |
| Searches all ezRTTI instances for the one with the given hashed name, or nullptr if no such type exists. | |
| static const ezRTTI * | FindTypeByNameHash32 (ezUInt32 uiNameHash) |
| static const ezRTTI * | FindTypeIf (PredicateFunc func) |
| Searches all ezRTTI instances for one where the given predicate function returns true. | |
| static void | ForEachType (VisitorFunc func, ezBitflags< ForEachOptions > options=ForEachOptions::Default) |
| static void | ForEachDerivedType (const ezRTTI *pBaseType, VisitorFunc func, ezBitflags< ForEachOptions > options=ForEachOptions::Default) |
| template<typename T > | |
| static EZ_ALWAYS_INLINE void | ForEachDerivedType (VisitorFunc func, ezBitflags< ForEachOptions > options=ForEachOptions::Default) |
Protected Member Functions | |
| void | UpdateType (const ezRTTI *pParentType, ezUInt32 uiTypeSize, ezUInt32 uiTypeVersion, ezUInt8 uiVariantType, ezBitflags< ezTypeFlags > flags) |
| void | RegisterType () |
| void | UnregisterType () |
| void | GatherDynamicMessageHandlers () |
| void | SetupParentHierarchy () |
Protected Attributes | |
| ezStringView | m_sPluginName |
| ezStringView | m_sTypeName |
| ezArrayPtr< const ezAbstractProperty *const > | m_Properties |
| ezArrayPtr< const ezAbstractFunctionProperty *const > | m_Functions |
| ezArrayPtr< const ezPropertyAttribute *const > | m_Attributes |
| const ezRTTI * | m_pParentType = nullptr |
| ezRTTIAllocator * | m_pAllocator = nullptr |
| ezUInt32 | m_uiTypeSize = 0 |
| ezUInt32 | m_uiTypeVersion = 0 |
| ezUInt64 | m_uiTypeNameHash = 0 |
| ezUInt32 | m_uiTypeIndex = 0 |
| ezBitflags< ezTypeFlags > | m_TypeFlags |
| ezUInt8 | m_uiVariantType = 0 |
| ezUInt16 | m_uiMsgIdOffset = ezSmallInvalidIndex |
| const ezRTTI *(* | m_VerifyParent )() |
| ezArrayPtr< ezAbstractMessageHandler * > | m_MessageHandlers |
| ezSmallArray< ezAbstractMessageHandler *, 1, ezStaticsAllocatorWrapper > | m_DynamicMessageHandlers |
| ezArrayPtr< ezMessageSenderInfo > | m_MessageSenders |
| ezSmallArray< const ezRTTI *, 7, ezStaticsAllocatorWrapper > | m_ParentHierarchy |
Core class of ezEngine's reflection system that holds complete runtime type information.
Each ezRTTI instance represents one reflected type and contains all metadata needed for runtime introspection, serialization, and object creation. The reflection system enables:
Key features:
Performance considerations:
Usage: Types are typically registered using macros (EZ_BEGIN_STATIC_REFLECTED_TYPE, etc.) rather than creating ezRTTI instances manually.
| bool ezRTTI::DispatchMessage | ( | const void * | pInstance, |
| ezMessage & | ref_msg | ||
| ) | const |
Dispatches a message to the appropriate handler (const version).
Same as the non-const version but for read-only message handlers. Some messages may only be handled by const handlers for safety reasons.
| bool ezRTTI::DispatchMessage | ( | void * | pInstance, |
| ezMessage & | ref_msg | ||
| ) | const |
Dispatches a message to the appropriate handler for this type.
Uses optimized message dispatch tables for fast O(1) message routing. Returns true if a handler was found and the message was processed, false if no handler exists for this message type. The message system enables decoupled communication between components.
|
inline |
Fast O(1) check if this type is derived from the given type (or is the same type).
Uses pre-computed parent hierarchy arrays for constant-time inheritance checks. Returns true if this type inherits from pBaseType or if they are the same type. This is the preferred method for inheritance testing in performance-critical code.