The registration class is the entry point for the manual registration of reflection information to the type system. More...

#include <registration.h>

Classes

class  bind
 The bind class is used to chain registration calls. More...
 
class  class_
 The class_ is used to register classes to RTTR. More...
 

Static Public Member Functions

template<typename Enum_Type >
static bind< detail::enum_, detail::invalid_type, Enum_Type > enumeration (string_view name)
 Register a global enumeration of type Enum_Type. More...
 
template<typename F >
static bind< detail::meth, detail::invalid_type, F, detail::public_accessmethod (string_view name, F f)
 Register a method to this class. More...
 
template<typename A >
static bind< detail::prop, detail::invalid_type, A, detail::public_accessproperty (string_view name, A acc)
 Register a global property with read write access. More...
 
template<typename A1 , typename A2 >
static bind< detail::prop, detail::invalid_type, A1, A2, detail::public_accessproperty (string_view name, A1 getter, A2 setter)
 Register a property to this class. More...
 
template<typename A >
static bind< detail::prop_readonly, detail::invalid_type, A, detail::public_accessproperty_readonly (string_view name, A acc)
 Register a global read only property. More...
 

Static Public Attributes

static const detail::private_access private_access
 This variable can be used to specify during registration of a class member the access level: private. More...
 
static const detail::protected_access protected_access
 This variable can be used to specify during registration of a class member the access level: protected. More...
 
static const detail::public_access public_access
 This variable can be used to specify during registration of a class member the access level: public. More...
 

Detailed Description

The registration class is the entry point for the manual registration of reflection information to the type system.

It is possible to register constructors, properties, methods and enumerations.

See following example for a typical usage:

Put the RTTR_ENABLE() macro inside the class declaration, when you will inherit from this class, otherwise you can omit the macro.

#include <rttr/type>
struct Mesh
{
Mesh();
Mesh(const std::string& name)
Vector3d getPosition() const;
void setPosition(const Vector3d& pos);
enum E_TransformSpace
{
TS_LOCAL,
TS_PARENT,
TS_WORLD
};
void setDirection(const Vector3 &vec, E_TransformSpace ts = TS_LOCAL);
private:
Vector3d _pos;
};

Then in a cpp file, register the constructors, properties and methods of the class Mesh.

#include "Mesh.cpp"
#include <rttr/registration>
using namespace rttr;
// register the class Mesh before main is called
{
using namespace rttr;
.constructor<const string&>()
.enumeration<E_TransformSpace>("E_TransformSpace")
(
value("TS_LOCAL", TS_LOCAL),
value("TS_PARENT", TS_PARENT),
value("TS_WORLD", TS_WORLD),
metadata("GUI_DESCR", "This enum describes the transformation.")
)
.property("pos", &Mesh::getPosition, &Mesh::setPosition)
(
metadata("GUI_LABEL", "Position."),
metadata("GUI_DESCR", "The position of the mesh."),
)
.method("setDirection", &Mesh::setDirection);
}
Remarks
See the usage of () operator to add additional meta data, policies or enum values.

Member Function Documentation

template<typename Enum_Type >
static bind<detail::enum_, detail::invalid_type, Enum_Type> rttr::registration::enumeration ( string_view  name)
static

Register a global enumeration of type Enum_Type.

Parameters
nameThe name of the enumeration.
Remarks
The name of the enumeration has to be unique, otherwise it will not be registered.
See also
enumeration, type::get_enumeration()
Returns
A bind object, in order to chain more calls.
template<typename F >
static bind<detail::meth, detail::invalid_type, F, detail::public_access> rttr::registration::method ( string_view  name,
f 
)
static

Register a method to this class.

Parameters
nameThe name of the method.
functionThe function accessor to this method; this can be a member function, a function or a std::function.
Remarks
The method name does not have to be unique.
See also
method, type::get_global_method(), type::invoke()
Returns
A bind object, in order to chain more calls.
template<typename A >
static bind<detail::prop, detail::invalid_type, A, detail::public_access> rttr::registration::property ( string_view  name,
acc 
)
static

Register a global property with read write access.

Parameters
nameThe name of the property.
accThe accessor to the property; a pointer to a variable.
Remarks
The name of the property has to be unique, otherwise it will not be registered.
See also
property, type::get_global_property(), type::get_property_value(), type::set_property_value
Returns
A bind object, in order to chain more calls.
template<typename A1 , typename A2 >
static bind<detail::prop, detail::invalid_type, A1, A2, detail::public_access> rttr::registration::property ( string_view  name,
A1  getter,
A2  setter 
)
static

Register a property to this class.

Parameters
nameThe name of the property.
getterThe getter accessor to the property; this can be a pointer to a function or a std::function.
setterThe setter accessor to the property; this can be a pointer to a function or a std::function.
Remarks
The name of the property has to be unique, otherwise it will not be registered.
See also
property, type::get_global_property(), type::get_property_value(), type::set_property_value
Returns
A bind object, in order to chain more calls.
template<typename A >
static bind<detail::prop_readonly, detail::invalid_type, A, detail::public_access> rttr::registration::property_readonly ( string_view  name,
acc 
)
static

Register a global read only property.

Parameters
nameThe name of the property.
accThe accessor to the property; this can be a pointer to a variable, a pointer to a function or a std::function.
Remarks
The name of the property has to be unique, otherwise it will not be registered.
See also
property, type::get_global_property(), type::get_property_value(), type::set_property_value
Returns
A bind object, in order to chain more calls.

Member Data Documentation

const detail::private_access rttr::registration::private_access
static

This variable can be used to specify during registration of a class member the access level: private.

See following example code:

using namespace rttr;
struct Foo
{
private:
void func() {}
};
{
.method("func", &Foo::func, registration::private_access);
}
See also
access_levels
const detail::protected_access rttr::registration::protected_access
static

This variable can be used to specify during registration of a class member the access level: protected.

See following example code:

using namespace rttr;
struct Foo
{
protected:
void func() {}
};
{
.method("func", &Foo::func, registration::protected_access);
}
See also
access_levels
const detail::public_access rttr::registration::public_access
static

This variable can be used to specify during registration of a class member the access level: public.

See following example code:

using namespace rttr;
struct Foo
{
void func() {}
};
{
.method("func", &Foo::func, registration::public_access);
}
See also
access_levels

The documentation for this class was generated from the following file: