template<typename _Type>
BipedalLocomotion::System::Factory class

Factory implements the factory design patter for constructing a an object of a given Type given its id.

Public types

using Type = _Type
using Builder = typename std::add_pointer<std::shared_ptr<Type>()>::type
Pointer to the Type builder.

Public static functions

static auto registerBuilder(std::string idKey, Builder classBuilder) -> std::string
Add a Builder for a given Type.
static auto createInstance(const std::string& idKey) -> std::shared_ptr<Type>
Create an instance of a Type given its id.

Constructors, destructors, conversion operators

~Factory() defaulted virtual

Function documentation

template<typename _Type>
static std::string BipedalLocomotion::System::Factory<_Type>::registerBuilder(std::string idKey, Builder classBuilder)

Add a Builder for a given Type.

Parameters
idKey the string representing the type of the Type. i.e., the stringify version of the class type
classBuilder pointer to the function that creates a given Type.
Returns the idKey

template<typename _Type>
static std::shared_ptr<Type> BipedalLocomotion::System::Factory<_Type>::createInstance(const std::string& idKey)

Create an instance of a Type given its id.

Parameters
idKey the string representing the type of the Type. i.e., the stringify version of the class type
Returns a pointer to the Type. In case of issues, the pointer will be a nullptr.