![]() |
ImFusion SDK 4.3
|
#include <ImFusion/Base/DataComponentFactory.h>
Factory singleton for creating DataComponents from string IDs. More...
Factory singleton for creating DataComponents from string IDs.
Every DataComponent implements the id() method returning a unique string identifier for that specific type of DataComponent. DataComponents have to be registered with DataComponentFactory using this string ID and a factory method for instantiating a DataComponent of such type. During registration DataComponentFactory ensures the uniqueness of the registered DataComponents and otherwise raises an assertion/logs a warning.
Public Types | |
using | FactoryMethod = std::function<std::unique_ptr<DataComponentBase>()> |
Alias for a DataComponentFactory factory method creating a specific DataComponent. | |
Public Member Functions | |
void | registerComponent (const std::string &id, FactoryMethod factoryMethod) |
Registers a DataComponent with the DataComponentFactory. | |
std::unique_ptr< DataComponentBase > | createComponent (const std::string &id, const Properties *p=nullptr) |
Instantiates a DataComponent specified by the given ID. | |
std::vector< std::string > | registeredComponentIds () const |
Returns the Unique IDs of all DataComponents registered with this factory. | |
![]() | |
FactoryBase () | |
No license check is performed for the module instantiated with this constructor. | |
FactoryBase (std::string module, bool checkLicense=true) | |
std::string | moduleName () const |
Returns the module name of the factory. | |
Static Public Member Functions | |
static DataComponentFactory & | get () |
Returns the DataComponentFactory singleton object. | |
Additional Inherited Members | |
![]() | |
virtual | ~FactoryBase () |
Virtual destructor. | |
std::string | getComponentPath (const std::string &componentName) const |
Returns the path to the component referred to by name . | |
bool | isLicensed (const std::string &name) |
Return true if the license allows the use of the component referred to by name . | |
![]() | |
static std::string | getComponentPath (const std::string &moduleName, const std::string &componentName) |
Returns the path to the component referred to by name . | |
static bool | isLicensed (const std::string &moduleName, const std::string &name) |
Return true if the license allows the use of the component referred to by name . | |
![]() | |
std::string | m_factoryModule |
bool | m_checkLicense |
void registerComponent | ( | const std::string & | id, |
FactoryMethod | factoryMethod ) |
Registers a DataComponent with the DataComponentFactory.
id | Unique string ID for the DataComponent to register. |
factoryMethod | Method to use for instantiating the DataComponent to register. |
std::unique_ptr< DataComponentBase > createComponent | ( | const std::string & | id, |
const Properties * | p = nullptr ) |
Instantiates a DataComponent specified by the given ID.
id | Unique ID of the DataComponent to create. |
p | Optional pointer to a Properties object. If not 0, it will used to configure the newly created DataComponent. |