ezEngine Release 26.3
Loading...
Searching...
No Matches
ezTypedMemberProperty< Type > Class Template Referenceabstract

Type-safe base class for accessing member properties with known data types. More...

#include <MemberProperty.h>

Inheritance diagram for ezTypedMemberProperty< Type >:

Public Member Functions

 ezTypedMemberProperty (const char *szPropertyName)
 Passes the property name through to ezAbstractMemberProperty.
 
virtual const ezRTTIGetSpecificType () const override
 Returns the actual type of the property. You can then compare that with known types, eg. compare it to ezGetStaticRTTI<int>() to see whether this is an int property.
 
virtual Type GetValue (const void *pInstance) const =0
 Returns the value of the property. Pass the instance pointer to the surrounding class along.
 
virtual void SetValue (void *pInstance, Type value) const =0
 Modifies the value of the property. Pass the instance pointer to the surrounding class along.
 
virtual void GetValuePtr (const void *pInstance, void *pObject) const override
 Writes the value of this property in pInstance to pObject. pObject needs to point to an instance of this property's type.
 
virtual void SetValuePtr (void *pInstance, const void *pObject) const override
 Sets the value of pObject to the property in pInstance. pObject needs to point to an instance of this property's type.
 
- Public Member Functions inherited from ezAbstractMemberProperty
 ezAbstractMemberProperty (const char *szPropertyName)
 Passes the property name through to ezAbstractProperty.
 
virtual ezPropertyCategory::Enum GetCategory () const override
 Returns ezPropertyCategory::Member.
 
virtual void * GetPropertyPointer (const void *pInstance) const =0
 Returns a pointer to the property data or nullptr. If a valid pointer is returned, that pointer and the information from GetSpecificType() can be used to step deeper into the type (if required).
 
- Public Member Functions inherited from ezAbstractProperty
 ezAbstractProperty (const char *szPropertyName)
 The constructor must get the name of the property. The string must be a compile-time constant.
 
const char * GetPropertyName () const
 Returns the name of the property.
 
const ezBitflags< ezPropertyFlags > & GetFlags () const
 Returns the flags of the property.
 
ezAbstractPropertyAddFlags (ezBitflags< ezPropertyFlags > flags)
 Adds flags to the property. Returns itself to allow to be called during initialization.
 
ezAbstractPropertyAddAttributes (ezPropertyAttribute *pAttrib1, ezPropertyAttribute *pAttrib2=nullptr, ezPropertyAttribute *pAttrib3=nullptr, ezPropertyAttribute *pAttrib4=nullptr, ezPropertyAttribute *pAttrib5=nullptr, ezPropertyAttribute *pAttrib6=nullptr)
 Adds attributes to the property. Returns itself to allow to be called during initialization. Allocate an attribute using standard 'new'.
 
ezArrayPtr< const ezPropertyAttribute *const > GetAttributes () const
 Returns the array of property attributes.
 
template<typename Type >
const Type * GetAttributeByType () const
 Returns the first attribute that derives from the given type, or nullptr if nothing is found.
 

Additional Inherited Members

- Protected Attributes inherited from ezAbstractProperty
ezBitflags< ezPropertyFlagsm_Flags
 
const char * m_szPropertyName
 
ezHybridArray< const ezPropertyAttribute *, 2, ezStaticsAllocatorWrapperm_Attributes
 

Detailed Description

template<typename Type>
class ezTypedMemberProperty< Type >

Type-safe base class for accessing member properties with known data types.

Once you determine a property's type through the reflection system, you can safely cast the abstract property pointer to this typed version. This provides type-safe access to property values without the overhead of variant conversions.

Example usage:

auto* abstractProp = rtti->FindPropertyByName("someProperty");
if (abstractProp->GetSpecificType() == ezGetStaticRTTI<int>())
{
auto* intProp = static_cast<ezTypedMemberProperty<int>*>(abstractProp);
int value = intProp->GetValue(instance);
}
Type-safe base class for accessing member properties with known data types.
Definition MemberProperty.h:30
virtual Type GetValue(const void *pInstance) const =0
Returns the value of the property. Pass the instance pointer to the surrounding class along.

Member Function Documentation

◆ GetSpecificType()

template<typename Type >
virtual const ezRTTI * ezTypedMemberProperty< Type >::GetSpecificType ( ) const
inlineoverridevirtual

Returns the actual type of the property. You can then compare that with known types, eg. compare it to ezGetStaticRTTI<int>() to see whether this is an int property.

Implements ezAbstractProperty.

◆ GetValue()

template<typename Type >
virtual Type ezTypedMemberProperty< Type >::GetValue ( const void *  pInstance) const
pure virtual

Returns the value of the property. Pass the instance pointer to the surrounding class along.

Implemented in ezResourceAccessorProperty< Class, Type >, ezAccessorProperty< Class, Type >, and ezMemberProperty< Class, Type >.

◆ GetValuePtr()

template<typename Type >
virtual void ezTypedMemberProperty< Type >::GetValuePtr ( const void *  pInstance,
void *  out_pObject 
) const
inlineoverridevirtual

Writes the value of this property in pInstance to pObject. pObject needs to point to an instance of this property's type.

Implements ezAbstractMemberProperty.

◆ SetValue()

template<typename Type >
virtual void ezTypedMemberProperty< Type >::SetValue ( void *  pInstance,
Type  value 
) const
pure virtual

Modifies the value of the property. Pass the instance pointer to the surrounding class along.

Note
Make sure the property is not read-only before calling this, otherwise an assert will fire.

Implemented in ezResourceAccessorProperty< Class, Type >, and ezMemberProperty< Class, Type >.

◆ SetValuePtr()

template<typename Type >
virtual void ezTypedMemberProperty< Type >::SetValuePtr ( void *  pInstance,
const void *  pObject 
) const
inlineoverridevirtual

Sets the value of pObject to the property in pInstance. pObject needs to point to an instance of this property's type.

Implements ezAbstractMemberProperty.


The documentation for this class was generated from the following file: