Factory
template <class AbstractClass> class Factory
@brief A factory for managing Karabo classes
The factory uses something like a hidden (private) Singleton-Pattern. This solves the problem of static initialization order but leaves a simple looking API to the user.
A single instance of a factory holds the function objects to all registered constructors. Constructors with zero or more parameters may be registered and directly called.
Functions
| Name | Description |
|---|---|
| registerClass | Register a base class identified by a key in the factory system factoryKey : |
| registerClass | Register a class A1 derived from ConcreteClass identified by a key in the factory system factoryKey : |
| create | Create an Object of the class identified by factoryKey factoryKey : Return : a shared pointer to the created object |
| create | Create an Object of the class identified by factoryKey factoryKey : Return : a shared pointer to the created object cast to A1 |
| getRegisteredClasses | Return the classIds registered in the factory Return : |
| has | Check if a class identified by factoryKey is known to the factory factoryKey : Return : |
Function Details
create
static std::shared_ptr<AbstractClass> create(const std::string& factoryKey)
Create an Object of the class identified by factoryKey
factoryKey
:
Return : a shared pointer to the created object
template <typename A1> static std::shared_ptr<AbstractClass> create(const std::string& factoryKey, const A1& a1)
Create an Object of the class identified by factoryKey
factoryKey
:
Return : a shared pointer to the created object cast to A1
getRegisteredClasses
static std::vector<std::string> getRegisteredClasses()
Return the classIds registered in the factory
Return :
has
static bool has(const std::string& factoryKey)
Check if a class identified by factoryKey is known to the factory
factoryKey
:
Return :
registerClass
template <class ConcreteClass> static void registerClass(const std::string& factoryKey)
Register a base class identified by a key in the factory system
factoryKey
:
template <class ConcreteClass, typename A1> static void registerClass(const std::string& factoryKey)
Register a class A1 derived from ConcreteClass identified by a key in the factory system
factoryKey
: