|
VR-Engage
2.3
|
This template provides a factory for creating objects that inherit from a common base class. It maintains a map of creator objects indexed by name.
| BASE_T | The base type that all created objects will inherit from |
#include <factory.h>
Public Types | |
| using | CreatorMap = std::map<std::string, DtBaseCreator<BASE_T>*> |
Public Member Functions | |
| DtFactory () | |
| virtual | ~DtFactory () |
| template<typename CREATE_T> | |
| void | removeCreator (std::string name="") |
| template<typename CREATE_T> | |
| void | addCreator (std::string name="") |
| BASE_T * | create (std::string name) |
| CreatorMap & | creatorMap () |
Protected Attributes | |
| CreatorMap | myCreators |
| using makVre::DtFactory< BASE_T >::CreatorMap = std::map<std::string, DtBaseCreator<BASE_T>*> |
Type alias for the map of creators.
|
inline |
Default constructor.
|
inlinevirtual |
Virtual destructor.
Cleans up all registered creators
|
inline |
|
inline |
Registers a creator for a specific type.
Adds a creator to the factory, allowing objects of that type to be created by name. If a creator with the same name already exists, it will be replaced, but a warning will only be logged if the new creator is of a different type.
| CREATE_T | The concrete type to register, must inherit from BASE_T |
| name | The name to register the creator under. If empty, the typeid name is used. |
|
inline |
Creates an object by name.
| name | The registered name of the creator to use |
|
inline |
Gets the map of registered creators.
|
protected |
Map of creator objects indexed by name.