| OpenMS 2.5.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
Concept

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

`#include <OpenMS/CONCEPT/Factory.h>`

Inheritance diagram for Factory< FactoryProduct >:

## 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< String > | registeredProducts ()
| Returns a list of registered products. More...

## Private Types

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

## Private Member Functions

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

## Static Private Member Functions

static Factory * | instance_ ()
| singleton access to Factory More...

## Private Attributes

Map | inventory_

## Static Private Attributes

static Factory * | instance_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 | ( |  | ) |

inline override private

Destructor.

## ◆ Factory()

Factory | ( |  | ) |

inline private

Constructor.

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

## Member Function Documentation

## ◆ create()

static FactoryProduct* create | ( | const String & | name | ) |

inline static

return FactoryProduct according to unique identifier `name`

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

## ◆ instance_()

static Factory* instance_ | ( |  | ) |

inline static private

singleton access to Factory

References Factory< FactoryProduct >::Factory(), SingletonRegistry::getFactory(), Factory< FactoryProduct >::instance_ptr_, SingletonRegistry::isRegistered(), and SingletonRegistry::registerFactory().

Referenced by Factory< FactoryProduct >::create(), Factory< FactoryProduct >::isRegistered(), Factory< FactoryProduct >::registeredProducts(), and Factory< FactoryProduct >::registerProduct().

## ◆ isRegistered()

static bool isRegistered | ( | const String & | name | ) |

inline static

Returns if a factory product is registered.

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

## ◆ registeredProducts()

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

inline static

Returns a list of registered products.

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

## ◆ registerProduct()

static void registerProduct | ( | const String & | name,
|  | const FunctionType | creator
| ) |  |

inline static

register new concrete FactoryProduct

Parameters

  name | unique name for concrete FactoryProduct
  creator | default 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

static private

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

## ◆ inventory_

Map inventory_

private

Referenced by Factory< FactoryProduct >::create(), Factory< FactoryProduct >::isRegistered(), Factory< FactoryProduct >::registeredProducts(), and Factory< FactoryProduct >::registerProduct().