Support for defining reflection for types.
All reflected classes need DECLARE_REFLECTION in their declaration, (non-Dynamic types are reflected using DECLARE_STATIC_REFLECTION outside), these macros are provided in Reflection.h.
These macros unconventionally end in a function declaration without braces, the braces, and contents, are expected to be provided to define properties and otherwise initialize the class. The function will be run to setup the class when <Class.LoadClasses> is called. The function is a member function of the Class types Class::DescriptionHelper, which are designed to simplify registering contructors, properties, and metadata about the type. See PersistentClass::DescriptionHelper.Properties for the prime example of how and why this is useful.
Note: You must #include the .hpp files of any classes you are defining reflection for to get the definitions of their DescriptionHelpers.
Reflection.hpp | Support for defining reflection for types. |
Macros | |
DEFINE_REFLECTION | Defines the reflection support for a type using its class’ DescriptionHelper. |
DEFINE_TEMPLATE_REFLECTION | Defines the reflection support for a templated type using its class’ DescriptionHelper. |
DEFINE_PRIVATE_REFLECTION | Defines the reflection support for a dynamic type, allowing the reflecting (class object) type to be privately specialized. |
DEFINE_STATIC_REFLECTION | Defines reflection for a non-dynamic type. |
Defines the reflection support for a type using its class’ DescriptionHelper.
TYPE | The fully qualified type (namespaces and everything). |
NAME | The name the class will be registered as. |
#include <reflect/Class.hpp> DEFINE_REFLECTION(MyClass, "MyClass") { ReflectConstructor(); ... }
Defines the reflection support for a templated type using its class’ DescriptionHelper.
The difference between this macro and DEFINE_REFLECTION is the template<> specialization markers required for template class defintions.
TYPE | The fully qualified type (namespaces and template args). |
NAME | The name the class will be registered as. |
#include <reflect/Class.hpp> DEFINE_TEMPLATE_REFLECTION(MyClass<3>, "MyClass") { ReflectConstructor(); ... }
Defines the reflection support for a dynamic type, allowing the reflecting (class object) type to be privately specialized.
This is usually used when defining the reflection for subclass of Class, because the class <Category> of the class does not need to be defined publicly.
TYPE | The class type (fully qualified) |
NAME | The name the class will be registered as. |
CLASSTYPE | The type of class reflecting this one. (must subclass the type inferred from the declaration) |
This class defines the core interface for all runtime type identification (RTTI) in reflect.
class ReflectExport( reflect ) Dynamic
class ReflectExport( reflect ) Class : public ObjectType
Used in reflection definitions.
template<typename T> class Class::DescriptionHelper : public ObjectType::DescriptionHelper<T>
Used to help register properties in a reflection definition.
PropertyCollector Properties