ezconfig
Create C++ Objects from Yaml and Json
|
A Factory creates objects in a class hierarchy. More...
#include <factory.hpp>
Public Types | |
using | OutputT = std::conditional_t<many, std::vector<std::unique_ptr<Base>>, std::unique_ptr<Base>> |
using | GeneratorT = std::function<OutputT(Args...)> |
Public Member Functions | |
void | add (const std::string &tag, GeneratorT factory) |
Add a factory method to the factory. | |
OutputT | create (const std::string &tag, auto &&... args) |
Create an object. | |
Protected Attributes | |
std::map< std::string, GeneratorT > | m_tags |
A Factory creates objects in a class hierarchy.
many | whether to create a one-to-many factory or a one-to-one factory. |
Signature | type signature Base(Args...) where Base is the hierarchy base class, and Args... are the inputs to the factory methods. |
If many = false, then the factory is (Args...) -> std::unique_ptr<Base> If many = true, then the factory is (Args...) -> std::vector<std::unique_ptr<Base>>
Definition at line 30 of file factory.hpp.
using ezconfig::GeneralFactory< many, Base, Args >::GeneratorT = std::function<OutputT(Args...)> |
Definition at line 34 of file factory.hpp.
using ezconfig::GeneralFactory< many, Base, Args >::OutputT = std::conditional_t<many, std::vector<std::unique_ptr<Base>>, std::unique_ptr<Base>> |
Definition at line 33 of file factory.hpp.
|
inline |
Add a factory method to the factory.
tag | |
factory |
Definition at line 42 of file factory.hpp.
|
inline |
Create an object.
Definition at line 51 of file factory.hpp.
|
protected |
Definition at line 69 of file factory.hpp.