OpenLexocad  27.1
entt::meta_factory< Type > Class Template Reference

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

#include <entt.hpp>

Inheritance diagram for entt::meta_factory< Type >:
entt::extended_meta_factory< Type, Spec >

Public Member Functions

auto type (const ENTT_ID_TYPE identifier) ENTT_NOEXCEPT
 Extends a meta type by assigning it an identifier. More...
 
auto type () ENTT_NOEXCEPT
 Extends a meta type by assigning it an identifier. More...
 
template<typename Base >
auto base () ENTT_NOEXCEPT
 Assigns a meta base to a meta type. More...
 
template<typename To >
auto conv () ENTT_NOEXCEPT
 Assigns a meta conversion function to a meta type. More...
 
template<auto Candidate>
auto conv () ENTT_NOEXCEPT
 Assigns a meta conversion function to a meta type. More...
 
template<auto Func, typename Policy = as_is_t>
auto ctor () ENTT_NOEXCEPT
 Assigns a meta constructor to a meta type. More...
 
template<typename... Args>
auto ctor () ENTT_NOEXCEPT
 Assigns a meta constructor to a meta type. More...
 
template<auto Func>
auto dtor () ENTT_NOEXCEPT
 Assigns a meta destructor to a meta type. More...
 
template<auto Data, typename Policy = as_is_t>
auto data (const ENTT_ID_TYPE identifier) ENTT_NOEXCEPT
 Assigns a meta data to a meta type. More...
 
template<auto Setter, auto Getter, typename Policy = as_is_t>
auto data (const ENTT_ID_TYPE identifier) ENTT_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>
auto func (const ENTT_ID_TYPE identifier) ENTT_NOEXCEPT
 Assigns a meta funcion to a meta type. More...
 
void reset () ENTT_NOEXCEPT
 Resets a meta type and all its parts. More...
 

Detailed Description

template<typename Type>
class entt::meta_factory< Type >

A meta factory to be used for reflection purposes.

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.

Member Function Documentation

◆ base()

template<typename Type >
template<typename Base >
auto entt::meta_factory< Type >::base ( )
inline

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.

◆ conv() [1/2]

template<typename Type >
template<typename To >
auto entt::meta_factory< Type >::conv ( )
inline

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.

◆ conv() [2/2]

template<typename Type >
template<auto Candidate>
auto entt::meta_factory< Type >::conv ( )
inline

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.

◆ ctor() [1/2]

template<typename Type >
template<auto Func, typename Policy = as_is_t>
auto entt::meta_factory< Type >::ctor ( )
inline

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).
Returns
An extended meta factory for the parent type.

◆ ctor() [2/2]

template<typename Type >
template<typename... Args>
auto entt::meta_factory< Type >::ctor ( )
inline

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.
Returns
An extended meta factory for the parent type.

◆ data() [1/2]

template<typename Type >
template<auto Data, typename Policy = as_is_t>
auto entt::meta_factory< Type >::data ( const ENTT_ID_TYPE  identifier)
inline

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).
Parameters
identifierUnique identifier.
Returns
An extended meta factory for the parent type.

◆ data() [2/2]

template<typename Type >
template<auto Setter, auto Getter, typename Policy = as_is_t>
auto entt::meta_factory< Type >::data ( const ENTT_ID_TYPE  identifier)
inline

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).
Parameters
identifierUnique identifier.
Returns
An extended meta factory for the parent type.

◆ dtor()

template<typename Type >
template<auto Func>
auto entt::meta_factory< Type >::dtor ( )
inline

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.

◆ func()

template<typename Type >
template<auto Candidate, typename Policy = as_is_t>
auto entt::meta_factory< Type >::func ( const ENTT_ID_TYPE  identifier)
inline

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).
Parameters
identifierUnique identifier.
Returns
An extended meta factory for the parent type.

◆ reset()

template<typename Type >
void entt::meta_factory< Type >::reset ( )
inline

Resets a meta type and all its parts.

This function resets 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 reset but the link between the two types is removed.

◆ type() [1/2]

template<typename Type >
auto entt::meta_factory< Type >::type ( const ENTT_ID_TYPE  identifier)
inline

Extends a meta type by assigning it an identifier.

This function is intended only for unnamed types.

Parameters
identifierUnique identifier.
Returns
An extended meta factory for the parent type.

◆ type() [2/2]

template<typename Type >
auto entt::meta_factory< Type >::type ( )
inline

Extends a meta type by assigning it an identifier.

This function is intended only for named types

Returns
An extended meta factory for the parent type.

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