5#include <Foundation/Basics.h>
7#include <Foundation/Containers/HashSet.h>
8#include <Foundation/Containers/HashTable.h>
9#include <Foundation/Containers/Map.h>
10#include <Foundation/Containers/Set.h>
11#include <Foundation/Containers/SmallArray.h>
12#include <Foundation/Containers/StaticArray.h>
13#include <Foundation/Reflection/Implementation/RTTI.h>
14#include <Foundation/Types/Bitflags.h>
15#include <Foundation/Types/Enum.h>
24 static constexpr bool value =
false;
30 static constexpr bool value =
true;
37 static constexpr bool value = std::is_enum<T>::value;
43 static constexpr bool value =
true;
49 using StorageType = plUInt16;
77 StorageType StandardType : 1;
78 StorageType IsEnum : 1;
79 StorageType Bitflags : 1;
80 StorageType Class : 1;
82 StorageType Const : 1;
83 StorageType Reference : 1;
84 StorageType Pointer : 1;
86 StorageType PointerOwner : 1;
87 StorageType ReadOnly : 1;
88 StorageType Hidden : 1;
89 StorageType Phantom : 1;
98 if constexpr (std::is_same<CleanType, plVariant>::value ||
99 std::is_same<Type, const char*>::value ||
109 if constexpr (std::is_const<typename plTypeTraits<Type>::NonReferencePointerType>::value)
112 if constexpr (std::is_pointer<Type>::value && !std::is_same<Type, const char*>::value)
115 if constexpr (std::is_reference<Type>::value)
133 using StorageType = plUInt8;
182 PL_ASSERT_DEV(pAttrib1 !=
nullptr,
"invalid attribute");
184 m_Attributes.PushBack(pAttrib1);
186 m_Attributes.PushBack(pAttrib2);
188 m_Attributes.PushBack(pAttrib3);
190 m_Attributes.PushBack(pAttrib4);
192 m_Attributes.PushBack(pAttrib5);
194 m_Attributes.PushBack(pAttrib6);
202 template <
typename Type>
203 const Type* GetAttributeByType()
const;
207 const char* m_szPropertyName;
263 virtual void GetValuePtr(
const void* pInstance,
void* out_pObject)
const = 0;
267 virtual void SetValuePtr(
void* pInstance,
const void* pObject)
const = 0;
285 virtual plUInt32
GetCount(
const void* pInstance)
const = 0;
288 virtual void GetValue(
const void* pInstance, plUInt32 uiIndex,
void* pObject)
const = 0;
291 virtual void SetValue(
void* pInstance, plUInt32 uiIndex,
const void* pObject)
const = 0;
294 virtual void Insert(
void* pInstance, plUInt32 uiIndex,
const void* pObject)
const = 0;
297 virtual void Remove(
void* pInstance, plUInt32 uiIndex)
const = 0;
300 virtual void Clear(
void* pInstance)
const = 0;
303 virtual void SetCount(
void* pInstance, plUInt32 uiCount)
const = 0;
305 virtual void* GetValuePointer(
void* pInstance, plUInt32 uiIndex)
const {
return nullptr; }
325 virtual bool IsEmpty(
const void* pInstance)
const = 0;
328 virtual void Clear(
void* pInstance)
const = 0;
331 virtual void Insert(
void* pInstance,
const void* pObject)
const = 0;
334 virtual void Remove(
void* pInstance,
const void* pObject)
const = 0;
337 virtual bool Contains(
const void* pInstance,
const void* pObject)
const = 0;
360 virtual bool IsEmpty(
const void* pInstance)
const = 0;
363 virtual void Clear(
void* pInstance)
const = 0;
366 virtual void Insert(
void* pInstance,
const char* szKey,
const void* pObject)
const = 0;
369 virtual void Remove(
void* pInstance,
const char* szKey)
const = 0;
372 virtual bool Contains(
const void* pInstance,
const char* szKey)
const = 0;
375 virtual bool GetValue(
const void* pInstance,
const char* szKey,
void* pObject)
const = 0;
382template <
int _Index,
class... Args>
385template <
class Head,
class... Tail>
391template <
int _Index,
class Head,
class... Tail>
394 using Type =
typename getArgument<_Index - 1, Tail...>::Type;
398template <
int I,
typename FUNC>
403template <
int I,
typename R,
typename... P>
408 Arguments =
sizeof...(P),
410 static_assert(I < Arguments,
"I needs to be smaller than the number of function parameters.");
411 using ParameterType =
typename getArgument<I, P...>::Type;
412 using ReturnType = R;
415template <
int I,
class Class,
typename R,
typename... P>
420 Arguments =
sizeof...(P),
422 static_assert(I < Arguments,
"I needs to be smaller than the number of function parameters.");
423 using ParameterType =
typename getArgument<I, P...>::Type;
424 using ReturnType = R;
427template <
int I,
class Class,
typename R,
typename... P>
432 Arguments =
sizeof...(P),
434 static_assert(I < Arguments,
"I needs to be smaller than the number of function parameters.");
435 using ParameterType =
typename getArgument<I, P...>::Type;
436 using ReturnType = R;
440template <
typename FUNC>
445template <
class Class,
typename R,
typename P>
448 using ParameterType = P;
449 using ReturnType = R;
453template <
typename CONTAINER>
470template <
typename T, plUInt32 Size>
476template <
typename T, plUInt32 Size>
482template <
typename T, plUInt16 Size>
506template <
typename K,
typename T>
512template <
typename K,
typename T>
522 using StorageType = plUInt8;
The base class for a property that represents an array of values.
Definition AbstractProperty.h:273
virtual void Insert(void *pInstance, plUInt32 uiIndex, const void *pObject) const =0
Inserts the target of pObject into the array at index uiIndex.
virtual void Clear(void *pInstance) const =0
Clears the array.
plAbstractArrayProperty(const char *szPropertyName)
Passes the property name through to plAbstractProperty.
Definition AbstractProperty.h:276
virtual void SetValue(void *pInstance, plUInt32 uiIndex, const void *pObject) const =0
Writes the target of pObject to the element at index uiIndex.
virtual plUInt32 GetCount(const void *pInstance) const =0
Returns number of elements.
virtual void Remove(void *pInstance, plUInt32 uiIndex) const =0
Removes the element in the array at index uiIndex.
virtual void GetValue(const void *pInstance, plUInt32 uiIndex, void *pObject) const =0
Writes element at index uiIndex to the target of pObject.
virtual plPropertyCategory::Enum GetCategory() const override
Returns plPropertyCategory::Array.
Definition AbstractProperty.h:282
virtual void SetCount(void *pInstance, plUInt32 uiCount) const =0
Resizes the array to uiCount.
This is the base class for all constant properties that are stored inside the RTTI data.
Definition AbstractProperty.h:213
virtual void * GetPropertyPointer() const =0
Returns a pointer to the constant data or nullptr. See plAbstractMemberProperty::GetPropertyPointer f...
virtual plVariant GetConstant() const =0
Returns the constant value as an plVariant.
virtual plPropertyCategory::Enum GetCategory() const override
Returns plPropertyCategory::Constant.
Definition AbstractProperty.h:222
plAbstractConstantProperty(const char *szPropertyName)
Passes the property name through to plAbstractProperty.
Definition AbstractProperty.h:216
The base class for a property that represents a function.
Definition AbstractProperty.h:535
virtual plFunctionType::Enum GetFunctionType() const =0
Returns the type of function, see plFunctionPropertyType::Enum.
plAbstractFunctionProperty * AddFlags(plBitflags< plPropertyFlags > flags)
Adds flags to the property. Returns itself to allow to be called during initialization.
Definition AbstractProperty.h:573
plAbstractFunctionProperty * AddAttributes(plPropertyAttribute *pAttrib1, plPropertyAttribute *pAttrib2=nullptr, plPropertyAttribute *pAttrib3=nullptr, plPropertyAttribute *pAttrib4=nullptr, plPropertyAttribute *pAttrib5=nullptr, plPropertyAttribute *pAttrib6=nullptr)
Adds attributes to the property. Returns itself to allow to be called during initialization....
Definition AbstractProperty.h:580
plAbstractFunctionProperty(const char *szPropertyName)
Passes the property name through to plAbstractProperty.
Definition AbstractProperty.h:538
virtual plBitflags< plPropertyFlags > GetArgumentFlags(plUInt32 uiParamIndex) const =0
Returns the property flags of the given argument.
virtual plPropertyCategory::Enum GetCategory() const override
Returns the category of this property. Cast this property to the next higher type for more informatio...
Definition AbstractProperty.h:543
virtual const plRTTI * GetArgumentType(plUInt32 uiParamIndex) const =0
Returns the type of the given argument.
virtual plUInt32 GetArgumentCount() const =0
Returns the number of arguments.
virtual plBitflags< plPropertyFlags > GetReturnFlags() const =0
Returns property flags of the return value.
virtual const plRTTI * GetReturnType() const =0
Returns the type of the return value.
virtual const plRTTI * GetSpecificType() const override
Returns the type information of the constant property. Use this to cast this property to a specific v...
Definition AbstractProperty.h:570
virtual void Execute(void *pInstance, plArrayPtr< plVariant > arguments, plVariant &out_returnValue) const =0
Calls the function. Provide the instance on which the function is supposed to be called.
The base class for a property that represents a set of values.
Definition AbstractProperty.h:348
virtual void Insert(void *pInstance, const char *szKey, const void *pObject) const =0
Inserts the target of pObject into the set.
plAbstractMapProperty(const char *szPropertyName)
Passes the property name through to plAbstractProperty.
Definition AbstractProperty.h:351
virtual bool IsEmpty(const void *pInstance) const =0
Returns whether the set is empty.
virtual void GetKeys(const void *pInstance, plHybridArray< plString, 16 > &out_keys) const =0
Writes the content of the set to out_keys.
virtual void Remove(void *pInstance, const char *szKey) const =0
Removes the target of pObject from the set.
virtual bool Contains(const void *pInstance, const char *szKey) const =0
Returns whether the target of pObject is in the set.
virtual bool GetValue(const void *pInstance, const char *szKey, void *pObject) const =0
Writes element at index uiIndex to the target of pObject.
virtual plPropertyCategory::Enum GetCategory() const override
Returns plPropertyCategory::Map.
Definition AbstractProperty.h:357
virtual void Clear(void *pInstance) const =0
Clears the set.
This is the base class for all properties that are members of a class. It provides more information a...
Definition AbstractProperty.h:237
virtual void * GetPropertyPointer(const void *pInstance) const =0
Returns a pointer to the property data or nullptr. If a valid pointer is returned,...
virtual plPropertyCategory::Enum GetCategory() const override
Returns plPropertyCategory::Member.
Definition AbstractProperty.h:246
virtual void GetValuePtr(const void *pInstance, void *out_pObject) const =0
Writes the value of this property in pInstance to pObject. pObject needs to point to an instance of t...
virtual void SetValuePtr(void *pInstance, const void *pObject) const =0
Sets the value of pObject to the property in pInstance. pObject needs to point to an instance of this...
plAbstractMemberProperty(const char *szPropertyName)
Passes the property name through to plAbstractProperty.
Definition AbstractProperty.h:240
This is the base interface for all properties in the reflection system. It provides enough informatio...
Definition AbstractProperty.h:150
plAbstractProperty * AddFlags(plBitflags< plPropertyFlags > flags)
Adds flags to the property. Returns itself to allow to be called during initialization.
Definition AbstractProperty.h:171
virtual plPropertyCategory::Enum GetCategory() const =0
Returns the category of this property. Cast this property to the next higher type for more informatio...
plAbstractProperty * AddAttributes(plPropertyAttribute *pAttrib1, plPropertyAttribute *pAttrib2=nullptr, plPropertyAttribute *pAttrib3=nullptr, plPropertyAttribute *pAttrib4=nullptr, plPropertyAttribute *pAttrib5=nullptr, plPropertyAttribute *pAttrib6=nullptr)
Adds attributes to the property. Returns itself to allow to be called during initialization....
Definition AbstractProperty.h:179
plAbstractProperty(const char *szPropertyName)
The constructor must get the name of the property. The string must be a compile-time constant.
Definition AbstractProperty.h:153
const plBitflags< plPropertyFlags > & GetFlags() const
Returns the flags of the property.
Definition AbstractProperty.h:168
plArrayPtr< const plPropertyAttribute *const > GetAttributes() const
Returns the array of property attributes.
Definition AbstractProperty.h:199
const char * GetPropertyName() const
Returns the name of the property.
Definition AbstractProperty.h:158
virtual const plRTTI * GetSpecificType() const =0
Returns the type information of the constant property. Use this to cast this property to a specific v...
The base class for a property that represents a set of values.
Definition AbstractProperty.h:313
virtual plPropertyCategory::Enum GetCategory() const override
Returns plPropertyCategory::Set.
Definition AbstractProperty.h:322
virtual bool IsEmpty(const void *pInstance) const =0
Returns whether the set is empty.
virtual void Remove(void *pInstance, const void *pObject) const =0
Removes the target of pObject from the set.
virtual void GetValues(const void *pInstance, plDynamicArray< plVariant > &out_keys) const =0
Writes the content of the set to out_keys.
virtual void Clear(void *pInstance) const =0
Clears the set.
virtual void Insert(void *pInstance, const void *pObject) const =0
Inserts the target of pObject into the set.
plAbstractSetProperty(const char *szPropertyName)
Passes the property name through to plAbstractProperty.
Definition AbstractProperty.h:316
virtual bool Contains(const void *pInstance, const void *pObject) const =0
Returns whether the target of pObject is in the set.
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition ArrayPtr.h:37
Definition DynamicArray.h:81
Definition HashTable.h:333
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
Base class of all attributes can be used to decorate a RTTI property.
Definition PropertyAttributes.h:11
This class holds information about reflected types. Each instance represents one type that is known t...
Definition RTTI.h:30
Definition SmallArray.h:219
Wraps a C-style array, which has a fixed size at compile-time, with a more convenient interface.
Definition StaticArray.h:13
plVariant is a class that can store different types of variables, which is useful in situations where...
Definition Variant.h:44
Use getArgument<N, Args...>::Type to get the type of the Nth argument in Args.
Definition AbstractProperty.h:383
The plBitflags class allows you to work with type-safe bitflags.
Definition Bitflags.h:82
PL_ALWAYS_INLINE void Add(const plBitflags< T > &rhs)
Sets the given flag.
Definition Bitflags.h:151
Template that allows to probe a container for its element type.
Definition AbstractProperty.h:455
A custom enum implementation that allows to define the underlying storage type to control its memory ...
Definition Enum.h:37
Template that allows to probe a function for a parameter and return type.
Definition AbstractProperty.h:400
Describes what kind of function a property is.
Definition AbstractProperty.h:521
Enum
Definition AbstractProperty.h:525
@ StaticMember
A static member function, instance pointer will be ignored.
Definition AbstractProperty.h:527
@ Member
A normal member function, a valid instance pointer must be provided to call.
Definition AbstractProperty.h:526
@ Constructor
A constructor. Return value is a void* pointing to the new instance allocated with the default alloca...
Definition AbstractProperty.h:528
Determines whether a type is plIsBitflags.
Definition AbstractProperty.h:23
Determines whether a type is plIsBitflags.
Definition AbstractProperty.h:36
Template that allows to probe a single parameter function for parameter and return type.
Definition AbstractProperty.h:442
Describes what category a property belongs to.
Definition AbstractProperty.h:132
Enum
Definition AbstractProperty.h:136
@ Member
The property is a 'member property', i.e. it represents some accessible value. Cast to plAbstractMemb...
Definition AbstractProperty.h:138
@ Set
The property is actually a set of values. Cast to plAbstractSetProperty.
Definition AbstractProperty.h:141
@ Function
The property is a function which can be called. Cast to plAbstractFunctionProperty.
Definition AbstractProperty.h:139
@ Map
The property is actually a map from string to values. Cast to plAbstractMapProperty.
Definition AbstractProperty.h:142
@ Constant
The property is a constant value that is stored inside the RTTI data.
Definition AbstractProperty.h:137
@ Array
The property is actually an array of values. The array dimensions might be changeable....
Definition AbstractProperty.h:140
Definition AbstractProperty.h:76
Flags used to describe a property and its type.
Definition AbstractProperty.h:48
Enum
Definition AbstractProperty.h:52
@ ReadOnly
Can only be read but not modified.
Definition AbstractProperty.h:63
@ Const
Property value is const.
Definition AbstractProperty.h:58
@ Reference
Property value is a reference.
Definition AbstractProperty.h:59
@ IsEnum
enum property, cast to plAbstractEnumerationProperty.
Definition AbstractProperty.h:54
@ Phantom
Definition AbstractProperty.h:65
@ StandardType
Anything that can be stored inside an plVariant except for pointers and containers.
Definition AbstractProperty.h:53
@ VarOut
Tag for non-const-ref function parameters to indicate usage 'out'.
Definition AbstractProperty.h:68
@ Hidden
This property should not appear in the UI.
Definition AbstractProperty.h:64
@ Bitflags
Bitflags property, cast to plAbstractEnumerationProperty.
Definition AbstractProperty.h:55
@ VarInOut
Tag for non-const-ref function parameters to indicate usage 'inout'.
Definition AbstractProperty.h:69
@ Class
A struct or class. All of the above are mutually exclusive.
Definition AbstractProperty.h:56
@ Pointer
Property value is a pointer.
Definition AbstractProperty.h:60
@ PointerOwner
This pointer property takes ownership of the passed pointer.
Definition AbstractProperty.h:62
typename std::remove_const< typename std::remove_reference< T >::type >::type NonConstReferenceType
removes reference and const qualifier
Definition TypeTraits.h:218
typename std::remove_const< typename std::remove_reference< typename std::remove_pointer< T >::type >::type >::type NonConstReferencePointerType
removes reference, const and pointer qualifier Note that this removes the const and reference of the ...
Definition TypeTraits.h:225
A helper struct to convert the C++ type, which is passed as the template argument,...
Definition VariantType.h:97
Enum
This enum describes the type of data that is currently stored inside the variant. Note that changes t...
Definition VariantType.h:26
@ FirstStandardType
*** Types that are flagged as 'StandardTypes' (see DetermineTypeFlags) ***
Definition VariantType.h:30