5#include <Foundation/Reflection/Implementation/EnumProperty.h>
6#include <Foundation/Reflection/Implementation/StaticRTTI.h>
9template <
typename Class,
typename EnumType,
typename Type>
14 using GetterFunc = Type (Class::*)()
const;
15 using SetterFunc = void (Class::*)(Type value);
21 PL_ASSERT_DEBUG(getter !=
nullptr,
"The getter of a property cannot be nullptr.");
27 if (m_Setter ==
nullptr)
37 virtual plInt64
GetValue(
const void* pInstance)
const override
39 typename EnumType::StorageType enumTemp = (
static_cast<const Class*
>(pInstance)->*m_Getter)().
GetValue();
40 return (plInt64)enumTemp;
43 virtual void SetValue(
void* pInstance, plInt64 value)
const override
47 (
static_cast<Class*
>(pInstance)->*m_Setter)((
typename EnumType::Enum)value);
57template <
typename Class,
typename EnumType,
typename Type>
61 using GetterFunc = Type (*)(
const Class* pInstance);
62 using SetterFunc = void (*)(Class* pInstance, Type value);
63 using PointerFunc =
void* (*)(
const Class* pInstance);
69 PL_ASSERT_DEBUG(getter !=
nullptr,
"The getter of a property cannot be nullptr.");
76 if (m_Setter ==
nullptr)
80 virtual void*
GetPropertyPointer(
const void* pInstance)
const override {
return m_Pointer(
static_cast<const Class*
>(pInstance)); }
82 virtual plInt64
GetValue(
const void* pInstance)
const override
84 typename EnumType::StorageType enumTemp = m_Getter(
static_cast<const Class*
>(pInstance)).GetValue();
85 return (plInt64)enumTemp;
88 virtual void SetValue(
void* pInstance, plInt64 value)
const override
93 m_Setter(
static_cast<Class*
>(pInstance), (
typename EnumType::Enum)value);
99 PointerFunc m_Pointer;
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 BitflagsProperty.h:11
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 BitflagsProperty.h:43
virtual plInt64 GetValue(const void *pInstance) const override
Returns the value of the property. Pass the instance pointer to the surrounding class along.
Definition BitflagsProperty.h:37
virtual void * GetPropertyPointer(const void *pInstance) const override
Returns a pointer to the property data or nullptr. If a valid pointer is returned,...
Definition BitflagsProperty.h:31
plBitflagsAccessorProperty(const char *szPropertyName, GetterFunc getter, SetterFunc setter)
Constructor.
Definition BitflagsProperty.h:18
[internal] An implementation of plTypedEnumProperty that accesses the bitflags property data directly...
Definition BitflagsProperty.h:59
virtual void * GetPropertyPointer(const void *pInstance) const override
Returns a pointer to the property data or nullptr. If a valid pointer is returned,...
Definition BitflagsProperty.h:80
plBitflagsMemberProperty(const char *szPropertyName, GetterFunc getter, SetterFunc setter, PointerFunc pointer)
Constructor.
Definition BitflagsProperty.h:66
virtual plInt64 GetValue(const void *pInstance) const override
Returns the value of the property. Pass the instance pointer to the surrounding class along.
Definition BitflagsProperty.h:82
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 BitflagsProperty.h:88
[internal] Base class for enum / bitflags properties that already defines the type.
Definition EnumProperty.h:43
PL_ALWAYS_INLINE void Add(const plBitflags< T > &rhs)
Sets the given flag.
Definition Bitflags.h:151
@ ReadOnly
Can only be read but not modified.
Definition AbstractProperty.h:63
@ Bitflags
Bitflags property, cast to plAbstractEnumerationProperty.
Definition AbstractProperty.h:55
typename std::remove_const< typename std::remove_reference< T >::type >::type NonConstReferenceType
removes reference and const qualifier
Definition TypeTraits.h:218