Generic Factory class that can take objects with constructor parameters.
More...
#include <imstkFactory.h>
|
using | BaseType = T |
|
using | Creator = std::function< T(Args...)> |
| Type of the function to generate a new object.
|
|
|
static T | create (const std::string &name, Args &&... args) |
| tries to construct the object give name, it will forward the given paramters More...
|
|
static void | add (const std::string &name, Creator c) |
| adds a new creation function to the factory More...
|
|
static bool | contains (const std::string &name) |
|
static const std::vector< std::string > | getNames () |
|
template<typename T, class ... Args>
class imstk::ObjectFactory< T, Args >
Generic Factory class that can take objects with constructor parameters.
All the objects in the factory need to be convertible to a common base class
- Template Parameters
-
T | The base class type, is also the return type of create() |
Args | Parameter pack argument for the list of params used to pass into create |
Definition at line 24 of file imstkFactory.h.
◆ add()
template<typename T, class ... Args>
adds a new creation function to the factory
- Parameters
-
name | Name to use, will overwrite an already defined name |
c | function to be called when create() is called with the given name |
Definition at line 44 of file imstkFactory.h.
◆ contains()
template<typename T, class ... Args>
- Returns
- true if the name can be found in the registry
Definition at line 50 of file imstkFactory.h.
◆ create()
template<typename T, class ... Args>
tries to construct the object give name, it will forward the given paramters
- Parameters
-
name | Name to use for lookup |
args | parameters to pass into the creation function |
- Exceptions
-
if | name was not registered |
Definition at line 35 of file imstkFactory.h.
◆ getNames()
template<typename T, class ... Args>
- Returns
- a list of all registered names in the registry
Definition at line 56 of file imstkFactory.h.
The documentation for this class was generated from the following file: