Generic factory that can be subclassed to create factories for specific types.
More...
#include <factory.h>
|
using | base_factory = factory |
| Convenience typedef for the derived classes.
|
|
using | pointer = std::unique_ptr< Type > |
| The return type for the create method.
|
|
using | factory_method = std::function< pointer(Arguments...)> |
| Convenience typedef for the factory methods used to create objects.
|
|
|
template<class Function > |
void | add (const std::string &identifier, Function &&fn) |
| Associates the given identifier with the given factory method. More...
|
|
template<class... Args> |
pointer | create (const std::string &identifier, Args &&...args) |
| Creates a new object based on the factory method parameters. More...
|
|
|
static DerivedFactory & | get () |
| Obtains the singleton. More...
|
|
|
std::unordered_map< std::string, factory_method > | methods_ |
| The internal map of identifiers to factory_methods.
|
|
template<class DerivedFactory, class Type, class... Arguments>
class meta::util::factory< DerivedFactory, Type, Arguments >
Generic factory that can be subclassed to create factories for specific types.
template<class DerivedFactory, class Type, class... Arguments>
Obtains the singleton.
- Returns
- a singleton of type DerivedFactory
template<class DerivedFactory, class Type, class... Arguments>
template<class Function >
void meta::util::factory< DerivedFactory, Type, Arguments >::add |
( |
const std::string & |
identifier, |
|
|
Function && |
fn |
|
) |
| |
|
inline |
Associates the given identifier with the given factory method.
- Parameters
-
identifier | The identifier to associate the factory method with |
fn | The factory method |
template<class DerivedFactory, class Type, class... Arguments>
template<class... Args>
Creates a new object based on the factory method parameters.
- Parameters
-
identifier | The identifier to use to select a factory method |
args | The arguments to forward to that factory method |
- Returns
- a unique_ptr to the new object created
The documentation for this class was generated from the following file:
- /home/chase/projects/meta/include/util/factory.h