OpenMS  2.7.0
Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
Factory< FactoryProduct > Class Template Reference

Returns FactoryProduct* based on the name of the desired concrete FactoryProduct. More...

#include <OpenMS/CONCEPT/Factory.h>

Inheritance diagram for Factory< FactoryProduct >:
[legend]
Collaboration diagram for Factory< FactoryProduct >:
[legend]

Static Public Member Functions

static FactoryProduct * create (const String &name)
 return FactoryProduct according to unique identifier name More...
 
static void registerProduct (const String &name, const FunctionType creator)
 register new concrete FactoryProduct More...
 
static bool isRegistered (const String &name)
 Returns if a factory product is registered. More...
 
static std::vector< StringregisteredProducts ()
 Returns a list of registered products. More...
 

Private Types

typedef FactoryProduct *(* FunctionType) ()
 Function signature of creator function. More...
 
typedef std::map< String, FunctionTypeMap
 
typedef Map::const_iterator MapIterator
 
typedef Factory< FactoryProduct > FactoryType
 

Private Member Functions

 ~Factory () override
 Destructor. More...
 
 Factory ()
 Constructor. More...
 

Static Private Member Functions

static Factoryinstance_ ()
 singleton access to Factory More...
 

Private Attributes

Map inventory_
 

Static Private Attributes

static Factoryinstance_ptr_ = nullptr
 

Friends

class singletonsNeedNoFriends
 

Additional Inherited Members

- Public Member Functions inherited from FactoryBase
virtual ~FactoryBase ()
 destructor More...
 

Detailed Description

template<typename FactoryProduct>
class OpenMS::Factory< FactoryProduct >

Returns FactoryProduct* based on the name of the desired concrete FactoryProduct.

Every factory product base class T has to implement the static function registerChildren that registers all classes S derived from T at Factory<T>.

Every class S derived from T has to implement the function "static T* create()" which is going to be registered at Factory<T>. Additionally the function "static String getProductName()" is required, which returns the name the class is registered by.

Member Typedef Documentation

◆ FactoryType

typedef Factory<FactoryProduct> FactoryType
private

◆ FunctionType

typedef FactoryProduct*(* FunctionType) ()
private

Function signature of creator function.

◆ Map

typedef std::map<String, FunctionType> Map
private

◆ MapIterator

typedef Map::const_iterator MapIterator
private

Constructor & Destructor Documentation

◆ ~Factory()

~Factory ( )
inlineoverrideprivate

Destructor.

◆ Factory()

Factory ( )
inlineprivate

Constructor.

Referenced by Factory< FactoryProduct >::instance_().

Member Function Documentation

◆ create()

static FactoryProduct* create ( const String name)
inlinestatic

return FactoryProduct according to unique identifier name

References Factory< FactoryProduct >::instance_(), and Factory< FactoryProduct >::inventory_.

◆ instance_()

static Factory* instance_ ( )
inlinestaticprivate

◆ isRegistered()

static bool isRegistered ( const String name)
inlinestatic

Returns if a factory product is registered.

References Factory< FactoryProduct >::instance_(), and Factory< FactoryProduct >::inventory_.

◆ registeredProducts()

static std::vector<String> registeredProducts ( )
inlinestatic

Returns a list of registered products.

References Factory< FactoryProduct >::instance_(), and Factory< FactoryProduct >::inventory_.

◆ registerProduct()

static void registerProduct ( const String name,
const FunctionType  creator 
)
inlinestatic

register new concrete FactoryProduct

Parameters
nameunique name for concrete FactoryProduct
creatordefault constructor for concrete FactoryProduct

References Factory< FactoryProduct >::instance_(), and Factory< FactoryProduct >::inventory_.

Referenced by QApplicationTOPP::QApplicationTOPP(), and BaseLabeler::registerChildren().

Friends And Related Function Documentation

◆ singletonsNeedNoFriends

friend class singletonsNeedNoFriends
friend

Member Data Documentation

◆ instance_ptr_

Factory< FactoryProduct > * instance_ptr_ = nullptr
staticprivate

◆ inventory_

Map inventory_
private