cubos::core::reflection::ConstructibleTrait class

Describes how a reflected type may be constructed and destructed.

Public types

template<typename T>
class Builder
Builder for ConstructibleTrait.
class CustomConstructor
Custom constructor of a type.
using Destructor = memory::Function<void(void*instance) const >
Destructor of a type.
using DefaultConstructor = memory::Function<void(void*instance) const >
Default constructor of a type.
using CopyConstructor = memory::Function<void(void*instance, const void*other) const >
Copy constructor of a type.
using MoveConstructor = memory::Function<void(void*instance, void*other) const >
Move constructor of a type.

Public static functions

template<typename T>
static auto typed() -> Builder<T>
Returns a trait builder for the given type.

Constructors, destructors, conversion operators

ConstructibleTrait(std::size_t size, std::size_t alignment, Destructor destructor)
Constructs.

Public functions

auto withDefaultConstructor(DefaultConstructor defaultConstructor) && -> ConstructibleTrait&&
Sets the default constructor of the type.
auto withCopyConstructor(CopyConstructor copyConstructor) && -> ConstructibleTrait&&
Sets the copy constructor of the type.
auto withMoveConstructor(MoveConstructor moveConstructor) && -> ConstructibleTrait&&
Sets the move constructor of the type.
auto withCustomConstructor(CustomConstructor customConstructor) && -> ConstructibleTrait&&
Adds a custom constructor to the type.
void addCustomConstructor(CustomConstructor customConstructor)
Adds a custom constructor to the type.
template<typename T, typename... Args>
void addCustomConstructor(std::initializer_list<std::string> argNames)
Adds a custom constructor to the type.
auto size() const -> std::size_t
Returns the size of the type in bytes.
auto alignment() const -> std::size_t
Returns the alignment of the type in bytes.
auto hasDefaultConstruct() const -> bool
Checks if default construction is supported.
auto hasCopyConstruct() const -> bool
Checks if copy construction is supported.
auto hasMoveConstruct() const -> bool
Checks if move construction is supported.
auto customConstructorCount() const -> std::size_t
Returns the number of custom constructors.
void destruct(void* instance) const
Destructs an instance of the type.
void defaultConstruct(void* instance) const
Default constructs an instance of the type.
void copyConstruct(void* instance, const void* other) const
Copy constructs an instance of the type.
void moveConstruct(void* instance, void* other) const
Move constructs an instance of the type.
void customConstruct(std::size_t index, void* instance, void** args) const
Calls a custom constructor.
auto destructor() const -> Destructor
Gets the destructor of the type.
auto defaultConstructor() const -> DefaultConstructor
Gets the default constructor of the type.
auto copyConstructor() const -> CopyConstructor
Gets the copy constructor of the type.
auto moveConstructor() const -> MoveConstructor
Gets the move constructor of the type.
auto customConstructor(std::size_t index) const -> const CustomConstructor&
Gets the custom constructor of the type.

Function documentation

template<typename T>
static Builder<T> cubos::core::reflection::ConstructibleTrait::typed()

Returns a trait builder for the given type.

Template parameters
T Type to build a trait for.
Returns Trait builder.

cubos::core::reflection::ConstructibleTrait::ConstructibleTrait(std::size_t size, std::size_t alignment, Destructor destructor)

Constructs.

Parameters
size Size of the type in bytes.
alignment Alignment of the type in bytes (must be a power of two).
destructor Destructor of the type.

ConstructibleTrait&& cubos::core::reflection::ConstructibleTrait::withDefaultConstructor(DefaultConstructor defaultConstructor) &&

Sets the default constructor of the type.

Parameters
defaultConstructor Function pointer to the default constructor of the type.
Returns Trait.

Aborts if the default constructor has already been set.

ConstructibleTrait&& cubos::core::reflection::ConstructibleTrait::withCopyConstructor(CopyConstructor copyConstructor) &&

Sets the copy constructor of the type.

Parameters
copyConstructor Function pointer to the copy constructor of the type.
Returns Trait.

Aborts if the copy constructor has already been set.

ConstructibleTrait&& cubos::core::reflection::ConstructibleTrait::withMoveConstructor(MoveConstructor moveConstructor) &&

Sets the move constructor of the type.

Parameters
moveConstructor Function pointer to the move constructor of the type.
Returns Trait.

Aborts if the copy constructor has already been set.

ConstructibleTrait&& cubos::core::reflection::ConstructibleTrait::withCustomConstructor(CustomConstructor customConstructor) &&

Adds a custom constructor to the type.

Parameters
customConstructor Custom constructor to add.
Returns Trait.

void cubos::core::reflection::ConstructibleTrait::addCustomConstructor(CustomConstructor customConstructor)

Adds a custom constructor to the type.

Parameters
customConstructor Custom constructor to add.

template<typename T, typename... Args>
void cubos::core::reflection::ConstructibleTrait::addCustomConstructor(std::initializer_list<std::string> argNames)

Adds a custom constructor to the type.

Template parameters
Args Argument types of the constructor.
Parameters
argNames Names of the arguments to the constructor.

std::size_t cubos::core::reflection::ConstructibleTrait::size() const

Returns the size of the type in bytes.

Returns Size of the type in bytes.

std::size_t cubos::core::reflection::ConstructibleTrait::alignment() const

Returns the alignment of the type in bytes.

Returns Alignment of the type in bytes.

bool cubos::core::reflection::ConstructibleTrait::hasDefaultConstruct() const

Checks if default construction is supported.

Returns Whether the operation is supported.

bool cubos::core::reflection::ConstructibleTrait::hasCopyConstruct() const

Checks if copy construction is supported.

Returns Whether the operation is supported.

bool cubos::core::reflection::ConstructibleTrait::hasMoveConstruct() const

Checks if move construction is supported.

Returns Whether the operation is supported.

std::size_t cubos::core::reflection::ConstructibleTrait::customConstructorCount() const

Returns the number of custom constructors.

Returns Number of custom constructors.

void cubos::core::reflection::ConstructibleTrait::destruct(void* instance) const

Destructs an instance of the type.

Parameters
instance Pointer to the instance to destruct.

void cubos::core::reflection::ConstructibleTrait::defaultConstruct(void* instance) const

Default constructs an instance of the type.

Parameters
instance Pointer to the location to construct the instance at.

void cubos::core::reflection::ConstructibleTrait::copyConstruct(void* instance, const void* other) const

Copy constructs an instance of the type.

Parameters
instance Pointer to the location to construct the instance at.
other Pointer to the instance to copy construct from.

void cubos::core::reflection::ConstructibleTrait::moveConstruct(void* instance, void* other) const

Move constructs an instance of the type.

Parameters
instance Pointer to the location to construct the instance at.
other Pointer to the instance to move construct from.

void cubos::core::reflection::ConstructibleTrait::customConstruct(std::size_t index, void* instance, void** args) const

Calls a custom constructor.

Parameters
index Index of the custom constructor to call.
instance Pointer to the location to construct the instance at.
args Array of pointers to the arguments to pass to the constructor.

Destructor cubos::core::reflection::ConstructibleTrait::destructor() const

Gets the destructor of the type.

Returns Destructor of the type.

DefaultConstructor cubos::core::reflection::ConstructibleTrait::defaultConstructor() const

Gets the default constructor of the type.

Returns Default constructor of the type.

CopyConstructor cubos::core::reflection::ConstructibleTrait::copyConstructor() const

Gets the copy constructor of the type.

Returns Copy constructor of the type.

MoveConstructor cubos::core::reflection::ConstructibleTrait::moveConstructor() const

Gets the move constructor of the type.

Returns Move constructor of the type.

const CustomConstructor& cubos::core::reflection::ConstructibleTrait::customConstructor(std::size_t index) const

Gets the custom constructor of the type.

Parameters
index Index of the custom constructor.
Returns Custom constructor of the type.