meta  1.4.9
Public Member Functions | List of all members
meta::factory< Type > Class Template Reference

A meta factory to be used for reflection purposes. More...

#include <factory.hpp>

Public Member Functions

 factory () noexcept=default
 Default constructor.
 
template<typename... Property>
factory type (const std::size_t identifier, Property &&... property) noexcept
 Extends a meta type by assigning it an identifier and properties. More...
 
template<typename Base >
factory base () noexcept
 Assigns a meta base to a meta type. More...
 
template<typename To >
factory conv () noexcept
 Assigns a meta conversion function to a meta type. More...
 
template<auto Candidate>
factory conv () noexcept
 Assigns a meta conversion function to a meta type. More...
 
template<auto Func, typename Policy = as_is_t, typename... Property>
factory ctor (Property &&... property) noexcept
 Assigns a meta constructor to a meta type. More...
 
template<typename... Args, typename... Property>
factory ctor (Property &&... property) noexcept
 Assigns a meta constructor to a meta type. More...
 
template<auto Func>
factory dtor () noexcept
 Assigns a meta destructor to a meta type. More...
 
template<auto Data, typename Policy = as_is_t, typename... Property>
factory data (const std::size_t identifier, Property &&... property) noexcept
 Assigns a meta data to a meta type. More...
 
template<auto Setter, auto Getter, typename Policy = as_is_t, typename... Property>
factory data (const std::size_t identifier, Property &&... property) noexcept
 Assigns a meta data to a meta type by means of its setter and getter. More...
 
template<auto Candidate, typename Policy = as_is_t, typename... Property>
factory func (const std::size_t identifier, Property &&... property) noexcept
 Assigns a meta funcion to a meta type. More...
 
bool unregister () noexcept
 Unregisters a meta type and all its parts. More...
 

Detailed Description

template<typename Type>
class meta::factory< Type >

A meta factory to be used for reflection purposes.

TURN_OFF_DOXYGEN A meta factory is an utility class used to reflect types, data and functions of all sorts. This class ensures that the underlying web of types is built correctly and performs some checks in debug mode to ensure that there are no subtle errors at runtime.

Template Parameters
TypeReflected type for which the factory was created.

Definition at line 249 of file factory.hpp.

Member Function Documentation

◆ base()

template<typename Type >
template<typename Base >
factory meta::factory< Type >::base ( )
inlinenoexcept

Assigns a meta base to a meta type.

A reflected base class must be a real base class of the reflected type.

Template Parameters
BaseType of the base class to assign to the meta type.
Returns
A meta factory for the parent type.

Definition at line 358 of file factory.hpp.

◆ conv() [1/2]

template<typename Type >
template<typename To >
factory meta::factory< Type >::conv ( )
inlinenoexcept

Assigns a meta conversion function to a meta type.

The given type must be such that an instance of the reflected type can be converted to it.

Template Parameters
ToType of the conversion function to assign to the meta type.
Returns
A meta factory for the parent type.

Definition at line 393 of file factory.hpp.

◆ conv() [2/2]

template<typename Type >
template<auto Candidate>
factory meta::factory< Type >::conv ( )
inlinenoexcept

Assigns a meta conversion function to a meta type.

Conversion functions can be either free functions or member functions.
In case of free functions, they must accept a const reference to an instance of the parent type as an argument. In case of member functions, they should have no arguments at all.

Template Parameters
CandidateThe actual function to use for the conversion.
Returns
A meta factory for the parent type.

Definition at line 431 of file factory.hpp.

◆ ctor() [1/2]

template<typename Type >
template<auto Func, typename Policy = as_is_t, typename... Property>
factory meta::factory< Type >::ctor ( Property &&...  property)
inlinenoexcept

Assigns a meta constructor to a meta type.

Free functions can be assigned to meta types in the role of constructors. All that is required is that they return an instance of the underlying type.
From a client's point of view, nothing changes if a constructor of a meta type is a built-in one or a free function.

Template Parameters
FuncThe actual function to use as a constructor.
PolicyOptional policy (no policy set by default).
PropertyTypes of properties to assign to the meta data.
Parameters
propertyProperties to assign to the meta data.
Returns
A meta factory for the parent type.

Definition at line 472 of file factory.hpp.

◆ ctor() [2/2]

template<typename Type >
template<typename... Args, typename... Property>
factory meta::factory< Type >::ctor ( Property &&...  property)
inlinenoexcept

Assigns a meta constructor to a meta type.

A meta constructor is uniquely identified by the types of its arguments and is such that there exists an actual constructor of the underlying type that can be invoked with parameters whose types are those given.

Template Parameters
ArgsTypes of arguments to use to construct an instance.
PropertyTypes of properties to assign to the meta data.
Parameters
propertyProperties to assign to the meta data.
Returns
A meta factory for the parent type.

Definition at line 514 of file factory.hpp.

◆ data() [1/2]

template<typename Type >
template<auto Data, typename Policy = as_is_t, typename... Property>
factory meta::factory< Type >::data ( const std::size_t  identifier,
Property &&...  property 
)
inlinenoexcept

Assigns a meta data to a meta type.

Both data members and static and global variables, as well as constants of any kind, can be assigned to a meta type.
From a client's point of view, all the variables associated with the reflected object will appear as if they were part of the type itself.

Template Parameters
DataThe actual variable to attach to the meta type.
PolicyOptional policy (no policy set by default).
PropertyTypes of properties to assign to the meta data.
Parameters
identifierUnique identifier.
propertyProperties to assign to the meta data.
Returns
A meta factory for the parent type.

Definition at line 604 of file factory.hpp.

◆ data() [2/2]

template<typename Type >
template<auto Setter, auto Getter, typename Policy = as_is_t, typename... Property>
factory meta::factory< Type >::data ( const std::size_t  identifier,
Property &&...  property 
)
inlinenoexcept

Assigns a meta data to a meta type by means of its setter and getter.

Setters and getters can be either free functions, member functions or a mix of them.
In case of free functions, setters and getters must accept a reference to an instance of the parent type as their first argument. A setter has then an extra argument of a type convertible to that of the parameter to set.
In case of member functions, getters have no arguments at all, while setters has an argument of a type convertible to that of the parameter to set.

Template Parameters
SetterThe actual function to use as a setter.
GetterThe actual function to use as a getter.
PolicyOptional policy (no policy set by default).
PropertyTypes of properties to assign to the meta data.
Parameters
identifierUnique identifier.
propertyProperties to assign to the meta data.
Returns
A meta factory for the parent type.

Definition at line 707 of file factory.hpp.

◆ dtor()

template<typename Type >
template<auto Func>
factory meta::factory< Type >::dtor ( )
inlinenoexcept

Assigns a meta destructor to a meta type.

Free functions can be assigned to meta types in the role of destructors. The signature of the function should identical to the following:

void(Type &);

The purpose is to give users the ability to free up resources that require special treatment before an object is actually destroyed.

Template Parameters
FuncThe actual function to use as a destructor.
Returns
A meta factory for the parent type.

Definition at line 559 of file factory.hpp.

◆ func()

template<typename Type >
template<auto Candidate, typename Policy = as_is_t, typename... Property>
factory meta::factory< Type >::func ( const std::size_t  identifier,
Property &&...  property 
)
inlinenoexcept

Assigns a meta funcion to a meta type.

Both member functions and free functions can be assigned to a meta type.
From a client's point of view, all the functions associated with the reflected object will appear as if they were part of the type itself.

Template Parameters
CandidateThe actual function to attach to the meta type.
PolicyOptional policy (no policy set by default).
PropertyTypes of properties to assign to the meta function.
Parameters
identifierUnique identifier.
propertyProperties to assign to the meta function.
Returns
A meta factory for the parent type.

Definition at line 756 of file factory.hpp.

◆ type()

template<typename Type >
template<typename... Property>
factory meta::factory< Type >::type ( const std::size_t  identifier,
Property &&...  property 
)
inlinenoexcept

Extends a meta type by assigning it an identifier and properties.

Template Parameters
PropertyTypes of properties to assign to the meta type.
Parameters
identifierUnique identifier.
propertyProperties to assign to the meta type.
Returns
A meta factory for the parent type.

Definition at line 336 of file factory.hpp.

◆ unregister()

template<typename Type >
bool meta::factory< Type >::unregister ( )
inlinenoexcept

Unregisters a meta type and all its parts.

This function unregisters a meta type and all its data members, member functions and properties, as well as its constructors, destructors and conversion functions if any.
Base classes aren't unregistered but the link between the two types is removed.

Returns
True if the meta type exists, false otherwise.

Definition at line 802 of file factory.hpp.


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