5#include <Foundation/Reflection/Implementation/MemberProperty.h>
6#include <Foundation/Reflection/Implementation/StaticRTTI.h>
21 virtual plInt64
GetValue(
const void* pInstance)
const = 0;
26 virtual void SetValue(
void* pInstance, plInt64 value)
const = 0;
28 virtual void GetValuePtr(
const void* pInstance,
void* pObject)
const override
30 *
static_cast<plInt64*
>(pObject) =
GetValue(pInstance);
33 virtual void SetValuePtr(
void* pInstance,
const void* pObject)
const override
35 SetValue(pInstance, *
static_cast<const plInt64*
>(pObject));
41template <
typename EnumType>
55 return plGetStaticRTTI<typename plTypeTraits<EnumType>::NonConstReferenceType>();
61template <
typename Class,
typename EnumType,
typename Type>
66 using GetterFunc = Type (Class::*)()
const;
67 using SetterFunc = void (Class::*)(Type value);
73 PL_ASSERT_DEBUG(getter !=
nullptr,
"The getter of a property cannot be nullptr.");
79 if (m_Setter ==
nullptr)
89 virtual plInt64
GetValue(
const void* pInstance)
const override
91 plEnum<EnumType> enumTemp = (
static_cast<const Class*
>(pInstance)->*m_Getter)();
95 virtual void SetValue(
void* pInstance, plInt64 value)
const override
99 (
static_cast<Class*
>(pInstance)->*m_Setter)((
typename EnumType::Enum)value);
109template <
typename Class,
typename EnumType,
typename Type>
113 using GetterFunc = Type (*)(
const Class* pInstance);
114 using SetterFunc = void (*)(Class* pInstance, Type value);
115 using PointerFunc =
void* (*)(
const Class* pInstance);
121 PL_ASSERT_DEBUG(getter !=
nullptr,
"The getter of a property cannot be nullptr.");
128 if (m_Setter ==
nullptr)
132 virtual void*
GetPropertyPointer(
const void* pInstance)
const override {
return m_Pointer(
static_cast<const Class*
>(pInstance)); }
134 virtual plInt64
GetValue(
const void* pInstance)
const override
140 virtual void SetValue(
void* pInstance, plInt64 value)
const override
145 m_Setter(
static_cast<Class*
>(pInstance), (
typename EnumType::Enum)value);
151 PointerFunc m_Pointer;
The base class for enum and bitflags member properties.
Definition EnumProperty.h:12
virtual plInt64 GetValue(const void *pInstance) const =0
Returns the value of the property. Pass the instance pointer to the surrounding class along.
plAbstractEnumerationProperty(const char *szPropertyName)
Passes the property name through to plAbstractMemberProperty.
Definition EnumProperty.h:15
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 t...
Definition EnumProperty.h:28
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...
Definition EnumProperty.h:33
virtual void SetValue(void *pInstance, plInt64 value) const =0
Modifies the value of the property. Pass the instance pointer to the surrounding class along.
This is the base class for all properties that are members of a class. It provides more information a...
Definition AbstractProperty.h:237
const char * GetPropertyName() const
Returns the name of the property.
Definition AbstractProperty.h:158
[internal] An implementation of plTypedEnumProperty that uses custom getter / setter functions to acc...
Definition EnumProperty.h:63
virtual plInt64 GetValue(const void *pInstance) const override
Returns the value of the property. Pass the instance pointer to the surrounding class along.
Definition EnumProperty.h:89
virtual void SetValue(void *pInstance, plInt64 value) const override
Modifies the value of the property. Pass the instance pointer to the surrounding class along.
Definition EnumProperty.h:95
plEnumAccessorProperty(const char *szPropertyName, GetterFunc getter, SetterFunc setter)
Constructor.
Definition EnumProperty.h:70
virtual void * GetPropertyPointer(const void *pInstance) const override
Returns a pointer to the property data or nullptr. If a valid pointer is returned,...
Definition EnumProperty.h:83
[internal] An implementation of plTypedEnumProperty that accesses the enum property data directly.
Definition EnumProperty.h:111
virtual void SetValue(void *pInstance, plInt64 value) const override
Modifies the value of the property. Pass the instance pointer to the surrounding class along.
Definition EnumProperty.h:140
plEnumMemberProperty(const char *szPropertyName, GetterFunc getter, SetterFunc setter, PointerFunc pointer)
Constructor.
Definition EnumProperty.h:118
virtual void * GetPropertyPointer(const void *pInstance) const override
Returns a pointer to the property data or nullptr. If a valid pointer is returned,...
Definition EnumProperty.h:132
virtual plInt64 GetValue(const void *pInstance) const override
Returns the value of the property. Pass the instance pointer to the surrounding class along.
Definition EnumProperty.h:134
This class holds information about reflected types. Each instance represents one type that is known t...
Definition RTTI.h:30
[internal] Base class for enum / bitflags properties that already defines the type.
Definition EnumProperty.h:43
virtual const plRTTI * GetSpecificType() const override
Returns the actual type of the property. You can then test whether it derives from plEnumBase or plBi...
Definition EnumProperty.h:53
plTypedEnumProperty(const char *szPropertyName)
Passes the property name through to plAbstractEnumerationProperty.
Definition EnumProperty.h:46
PL_ALWAYS_INLINE void Add(const plBitflags< T > &rhs)
Sets the given flag.
Definition Bitflags.h:151
A custom enum implementation that allows to define the underlying storage type to control its memory ...
Definition Enum.h:37
PL_ALWAYS_INLINE StorageType GetValue() const
Returns the enum value as an integer.
Definition Enum.h:98
@ ReadOnly
Can only be read but not modified.
Definition AbstractProperty.h:63
@ IsEnum
enum property, cast to plAbstractEnumerationProperty.
Definition AbstractProperty.h:54
typename std::remove_const< typename std::remove_reference< T >::type >::type NonConstReferenceType
removes reference and const qualifier
Definition TypeTraits.h:218