Class to manage all creators and provide factory access.
More...
#include <CreatorManager.h>
|
static void | registerCreatorFactory (const std::string &name, CreatorFactory *factory) |
| Register a new creator by providing a name and a pointer to a factory for this kind of creator.
|
|
static CreatorBase * | getCreator (const std::string &name, const std::string &library="") |
| Return a new instance of a creator with the given name.
|
|
Class to manage all creators and provide factory access.
Definition at line 24 of file CreatorManager.h.
◆ CreatorFactory
◆ CreatorManager()
◆ getCreator()
CreatorBase * getCreator |
( |
const std::string & |
name, |
|
|
const std::string & |
library = "" |
|
) |
| |
|
static |
Return a new instance of a creator with the given name.
If library is not empty, the specified library will be loaded before attempting to create the creator to allow for on-demand loading of libraries.
Returns 0 if no creator with the given name is registered. Ownership of the creator is transferred to the caller who is responsible of freeing the creator.
- Parameters
-
name | Name of the Creator to be created |
library | Short name of the library which should be loaded before trying to create the creator. When library is "foo", libfoo.so will be loaded |
Definition at line 31 of file CreatorManager.cc.
32{
33 if (!library.empty()) {
35 }
36
40 B2ERROR("Could not find a geometry creator named " << name);
41 return nullptr;
42 }
43 return it->second();
44}
static bool loadLibrary(std::string library, bool fullname=true)
Load a shared library.
Class to manage all creators and provide factory access.
std::map< std::string, CreatorFactory * > m_creatorFactories
Static map to hold all registered factories.
static CreatorManager & getInstance()
getter for the singleton instance
◆ getInstance()
getter for the singleton instance
Definition at line 18 of file CreatorManager.cc.
19{
21 return *instance;
22}
CreatorManager()
singleton, hide constructor
◆ registerCreatorFactory()
void registerCreatorFactory |
( |
const std::string & |
name, |
|
|
CreatorFactory * |
factory |
|
) |
| |
|
static |
Register a new creator by providing a name and a pointer to a factory for this kind of creator.
- Parameters
-
name | Name of the creator to be registered |
factory | Pointer to a function returning new instances of the creator |
Definition at line 26 of file CreatorManager.cc.
◆ m_creatorFactories
Static map to hold all registered factories.
Definition at line 63 of file CreatorManager.h.
The documentation for this class was generated from the following files: