Plasma Engine  2.0
Loading...
Searching...
No Matches
ConstantProperty.h
1#pragma once
2
4
5#include <Foundation/Reflection/Implementation/AbstractProperty.h>
6#include <Foundation/Reflection/Implementation/StaticRTTI.h>
7
13template <typename Type>
15{
16public:
18 plTypedConstantProperty(const char* szPropertyName)
19 : plAbstractConstantProperty(szPropertyName)
20 {
21 m_Flags = plPropertyFlags::GetParameterFlags<Type>();
22 }
23
26 virtual const plRTTI* GetSpecificType() const override // [tested]
27 {
28 return plGetStaticRTTI<typename plTypeTraits<Type>::NonConstReferenceType>();
29 }
30
32 virtual Type GetValue() const = 0;
33};
34
36template <typename Type>
38{
39public:
41 plConstantProperty(const char* szPropertyName, Type value)
42 : plTypedConstantProperty<Type>(szPropertyName)
43 , m_Value(value)
44 {
45 PL_ASSERT_DEBUG(this->m_Flags.IsSet(plPropertyFlags::StandardType), "Only constants that can be put in an plVariant are currently supported!");
46 }
47
49 virtual void* GetPropertyPointer() const override { return (void*)&m_Value; }
50
52 virtual Type GetValue() const override // [tested]
53 {
54 return m_Value;
55 }
56
57 virtual plVariant GetConstant() const override { return plVariant(m_Value); }
58
59private:
60 Type m_Value;
61};
This is the base class for all constant properties that are stored inside the RTTI data.
Definition AbstractProperty.h:213
[internal] An implementation of plTypedConstantProperty that accesses the property data directly.
Definition ConstantProperty.h:38
virtual void * GetPropertyPointer() const override
Returns a pointer to the member property.
Definition ConstantProperty.h:49
plConstantProperty(const char *szPropertyName, Type value)
Constructor.
Definition ConstantProperty.h:41
virtual Type GetValue() const override
Returns the value of the property. Pass the instance pointer to the surrounding class along.
Definition ConstantProperty.h:52
virtual plVariant GetConstant() const override
Returns the constant value as an plVariant.
Definition ConstantProperty.h:57
This class holds information about reflected types. Each instance represents one type that is known t...
Definition RTTI.h:30
The base class for all typed member properties. Ie. once the type of a property is determined,...
Definition ConstantProperty.h:15
virtual const plRTTI * GetSpecificType() const override
Returns the actual type of the property. You can then compare that with known types,...
Definition ConstantProperty.h:26
plTypedConstantProperty(const char *szPropertyName)
Passes the property name through to plAbstractMemberProperty.
Definition ConstantProperty.h:18
virtual Type GetValue() const =0
Returns the value of the property. Pass the instance pointer to the surrounding class along.
plVariant is a class that can store different types of variables, which is useful in situations where...
Definition Variant.h:44
PL_ALWAYS_INLINE bool IsSet(Enum flag) const
Checks if certain flags are set within the bitfield.
Definition Bitflags.h:127
@ StandardType
Anything that can be stored inside an plVariant except for pointers and containers.
Definition AbstractProperty.h:53