LiteFX::Builder¶
Describes an generic builder type.
Synopsis¶
Declared in <litefx/containers.hpp>
template<
typename T,
typename TParent = std::nullptr_t,
typename TPointer = UniquePtr<T>>
class Builder;
Description¶
Builders are helper classes to create objects or object hierarchies. A builder is called root builder, if TParent is set to std::nullptr_t, otherwise it is called child builder and TParent is set to the type of the parent builder in the hierarchy. A builder can be a child builder to either a root builder or another child builder. However, at the top of the hierarchy there needs to be one root builder and each hierarchy can only have one root builder.
Building a child object using a child builder can be terminated by calling add on it. This will call use on the parent builder and pass the object instance to it. If any work needs to be done by the builder before passing it to the parent builder, it is possible to overwrite the build method. For root builders no additional call is required. Instead a root builder provides a move-assignment operator for T. Assigning the builder instance to an instance of TPointer will return the instance object. Similar to child builders, it is possible to overwrite the build method, to perform any additional pre-construction work.
Builders create the object instances they manage in form of smart pointers. The TPointer can either be set to any smart pointer type that wraps T for convenience.
Type Aliases¶
Member Functions¶
| Name | Description |
|---|---|
Builder [constructor] | Constructors |
~Builder [destructor] [virtual] | Destructor |
operator= | Assignment operators |
add | First, calls build, then use on the parent builder using the current object instance and finally returns the parent builder. |
instance | Returns a pointer to the current instance of the object that is built by the builder. |
parent | Returns a reference of the parent builder. |
use [deleted] | Called by child builders to pass a constructed object back to the parent builder. |
Protected Member Functions¶
| Name | Description |
|---|---|
build [virtual] | Can be overwritten to perform any pre-construction work before the builder returns the final object instance. |
instance | Returns a pointer to the current instance of the object that is built by the builder. |
Specializations¶
| Name | Description |
|---|---|
Builder<T, std::nullptr_t, TPointer> | Describes a root builder. |
Derived Classes¶
| Name | Description |
|---|---|
AppBuilder | Creates a new builder for an App. |
BarrierBuilder | Base class for a builder that builds a Barrier. |
ComputePipelineBuilder | Describes the interface of a compute pipeline builder. |
DescriptorSetLayoutBuilder | Builds a DescriptorSetLayout for a PipelineLayout. |
InputAssemblerBuilder | Builds a InputAssembler. |
PipelineLayoutBuilder | Base class for a builder of a PipelineLayout. |
PushConstantsLayoutBuilder | Builds a PushConstantsLayout for a PipelineLayout. |
RasterizerBuilder | Builds a Rasterizer. |
RayTracingPipelineBuilder | Describes the interface of a ray-tracing pipeline builder. |
RenderPassBuilder | Describes the interface of a render pass builder. |
RenderPipelineBuilder | Describes the interface of a render pipeline builder. |
ShaderProgramBuilder | Base class for a builder that builds a ShaderProgram. |
VertexBufferLayoutBuilder | Builds a IVertexBufferLayout. |
Template Parameters¶
| Name | Description |
|---|---|
| T | The type of the object the builder builds. |
| TParent | The type of the parent builder or std::nullptr_t. |
| TPointer | The type of the pointer, used to access the instance of T this builder builds. |
See Also¶
https://github.com/crud89/LiteFX/wiki/Builders