![]() |
ImFusion SDK 4.3
|
#include <ImFusion/GL/GlObjectFactory.h>
Factory singleton for creating GlObject from string IDs. More...
Inheritance diagram for GlObjectFactory:Factory singleton for creating GlObject from string IDs.
Every GlObject implements the typeName() method returning a unique string identifier for that specific type of GlObject. GlObjects have to be registered with GlObjectFactory using this string ID and a factory method for instantiating a GlObject of such type. During registration GlObjectFactory ensures the uniqueness of the registered GlObjects and otherwise raises an assertion/logs a warning.
Public Types | |
| using | CompatibilityFunction = std::function<bool(const Data* data, const std::vector<GlObject*>& objects)> |
| Alias for a function which checks if the corresponding FactoryFunction is compatible with the given input. | |
| using | FactoryFunctionSimple = std::function<std::unique_ptr<GlObject>()> |
| Alias for a GlObjectFactory factory function creating a specific GlObject. | |
| using | FactoryFunction = std::function<std::unique_ptr<GlObject>(const Data* data, const std::vector<GlObject*>& objects)> |
| Alias for a GlObjectFactory factory function creating a specific GlObject which can depend on Data and can wrap other GlObjects. | |
Public Member Functions | |
| void | registerObject (const std::string &id, FactoryFunction factoryFunction, CompatibilityFunction factoryCompatibilityFunction) |
| Registers a GlObject with the GlObjectFactory. | |
| void | registerObject (const std::string &id, FactoryFunctionSimple factoryFunction) |
| Registers a GlObject with the GlObjectFactory which does not require Data of GlObjects. | |
| bool | canCreateObject (const std::string &id, const Data *data=nullptr, const std::vector< GlObject * > &objects={}) |
| Test if a GlObject can be constructed with the given ID and the provided arguments. | |
| std::unique_ptr< GlObject > | createObject (const std::string &id, const Properties *p=nullptr, const Data *data=nullptr, const std::vector< GlObject * > &objects={}) |
| Instantiates a GlObject specified by the given ID. | |
Public Member Functions inherited from FactoryBase | |
| 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 GlObjectFactory & | get () |
| Returns the GlObjectFactory singleton object. | |
Additional Inherited Members | |
Protected Member Functions inherited from FactoryBase | |
| 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 Protected Member Functions inherited from FactoryBase | |
| 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. | |
Protected Attributes inherited from FactoryBase | |
| std::string | m_factoryModule |
| bool | m_checkLicense |
| void registerObject | ( | const std::string & | id, |
| FactoryFunction | factoryFunction, | ||
| CompatibilityFunction | factoryCompatibilityFunction ) |
Registers a GlObject with the GlObjectFactory.
| id | Unique string ID for the GlObject to register. |
| factoryFunction | Method to use for instantiating the GlObject to register which takes reference data and potential objects to wrap. |
| factoryCompatibilityFunction | Method to use for checking if the GlObject can be created with given data and potential objects to wrap. |
| void registerObject | ( | const std::string & | id, |
| FactoryFunctionSimple | factoryFunction ) |
Registers a GlObject with the GlObjectFactory which does not require Data of GlObjects.
| bool canCreateObject | ( | const std::string & | id, |
| const Data * | data = nullptr, | ||
| const std::vector< GlObject * > & | objects = {} ) |
Test if a GlObject can be constructed with the given ID and the provided arguments.
| std::unique_ptr< GlObject > createObject | ( | const std::string & | id, |
| const Properties * | p = nullptr, | ||
| const Data * | data = nullptr, | ||
| const std::vector< GlObject * > & | objects = {} ) |
Instantiates a GlObject specified by the given ID.