LiteFX 0.3.1.2022
Computer Graphics Engine
LiteFX::Builder< TDerived, T, std::nullptr_t, typename TPointer > Class Template Reference

Describes a root builder. More...

#include <containers.hpp>

Public Types

using derived_type = TDerived
 
using instance_type = T
 
using parent_type = std::nullptr_t
 
using pointer_type = TPointer
 
using builder_type = Builder< derived_type, instance_type, parent_type, pointer_type >
 

Public Member Functions

const T * instance () const noexcept
 Returns a pointer to the current instance of the object that is built by the builder. More...
 
 Builder (TPointer &&instance) noexcept
 Initializes the builder instance. More...
 
 Builder (builder_type &&_other) noexcept
 Initializes the builder instance by taking over another instance. More...
 
 Builder (const builder_type &)=delete
 
virtual ~Builder () noexcept=default
 
template<typename TInstance >
void use (pointer_type &&)=delete
 Called by child builders to pass a constructed object back to the parent builder. More...
 
 operator TPointer && ()
 Calls build and returns the instance. More...
 

Protected Member Functions

T * instance () noexcept
 Returns a pointer to the current instance of the object that is built by the builder. More...
 
virtual void build ()
 Can be overwritten to perform any pre-construction work before the builder returns the final object instance. More...
 

Detailed Description

template<typename TDerived, typename T, typename TPointer>
class LiteFX::Builder< TDerived, T, std::nullptr_t, typename TPointer >

Describes a root builder.

Template Parameters
TDerivedThe concrete implementation of the builder itself.
TThe type of the object the builder builds.
TPointerThe type of the pointer, used to access the instance of T this builder builds.

Member Typedef Documentation

◆ builder_type

template<typename TDerived , typename T , typename TPointer >
using LiteFX::Builder< TDerived, T, std::nullptr_t, typename TPointer >::builder_type = Builder<derived_type, instance_type, parent_type, pointer_type>

◆ derived_type

template<typename TDerived , typename T , typename TPointer >
using LiteFX::Builder< TDerived, T, std::nullptr_t, typename TPointer >::derived_type = TDerived

◆ instance_type

template<typename TDerived , typename T , typename TPointer >
using LiteFX::Builder< TDerived, T, std::nullptr_t, typename TPointer >::instance_type = T

◆ parent_type

template<typename TDerived , typename T , typename TPointer >
using LiteFX::Builder< TDerived, T, std::nullptr_t, typename TPointer >::parent_type = std::nullptr_t

◆ pointer_type

template<typename TDerived , typename T , typename TPointer >
using LiteFX::Builder< TDerived, T, std::nullptr_t, typename TPointer >::pointer_type = TPointer

Constructor & Destructor Documentation

◆ Builder() [1/3]

template<typename TDerived , typename T , typename TPointer >
LiteFX::Builder< TDerived, T, std::nullptr_t, typename TPointer >::Builder ( TPointer &&  instance)
inlineexplicitnoexcept

Initializes the builder instance.

Parameters
instanceThe instance of the object to build.

◆ Builder() [2/3]

template<typename TDerived , typename T , typename TPointer >
LiteFX::Builder< TDerived, T, std::nullptr_t, typename TPointer >::Builder ( builder_type &&  _other)
inlinenoexcept

Initializes the builder instance by taking over another instance.

Parameters
_otherThe instance of another builder object to take over.

◆ Builder() [3/3]

template<typename TDerived , typename T , typename TPointer >
LiteFX::Builder< TDerived, T, std::nullptr_t, typename TPointer >::Builder ( const builder_type )
delete

◆ ~Builder()

template<typename TDerived , typename T , typename TPointer >
virtual LiteFX::Builder< TDerived, T, std::nullptr_t, typename TPointer >::~Builder ( )
virtualdefaultnoexcept

Member Function Documentation

◆ build()

template<typename TDerived , typename T , typename TPointer >
virtual void LiteFX::Builder< TDerived, T, std::nullptr_t, typename TPointer >::build ( )
inlineprotectedvirtual

Can be overwritten to perform any pre-construction work before the builder returns the final object instance.

◆ instance() [1/2]

template<typename TDerived , typename T , typename TPointer >
const T * LiteFX::Builder< TDerived, T, std::nullptr_t, typename TPointer >::instance ( ) const
inlinenoexcept

Returns a pointer to the current instance of the object that is built by the builder.

Returns
A pointer to the current object instance.

◆ instance() [2/2]

template<typename TDerived , typename T , typename TPointer >
T * LiteFX::Builder< TDerived, T, std::nullptr_t, typename TPointer >::instance ( )
inlineprotectednoexcept

Returns a pointer to the current instance of the object that is built by the builder.

Returns
A pointer to the current object instance.

◆ operator TPointer &&()

template<typename TDerived , typename T , typename TPointer >
LiteFX::Builder< TDerived, T, std::nullptr_t, typename TPointer >::operator TPointer && ( )
inline

Calls build and returns the instance.

◆ use()

template<typename TDerived , typename T , typename TPointer >
template<typename TInstance >
void LiteFX::Builder< TDerived, T, std::nullptr_t, typename TPointer >::use ( pointer_type &&  )
delete

Called by child builders to pass a constructed object back to the parent builder.

This method must be implemented for each child builder, a builder can create. This introduces a hard dependency between child and parent builders. It is not possible to define a child builder without implementing the counter part in the parent builder.