35 #ifndef OPENMS_CONCEPT_FACTORY_H 36 #define OPENMS_CONCEPT_FACTORY_H 60 template <
typename FactoryProduct>
68 typedef FactoryProduct * (*FunctionType)();
69 typedef std::map<String, FunctionType>
Map;
98 FactoryProduct::registerChildren();
117 return (*(it->second))();
121 throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
"This FactoryProduct is not registered!", name.c_str());
149 std::vector<String> list;
152 list.push_back(it->first);
163 template <
typename FactoryProduct>
167 #endif //OPENMS_CONCEPT_FACTORY_H static bool isRegistered(String name)
Returns if a factory is registered.
Definition: SingletonRegistry.h:108
A more convenient string class.
Definition: String.h:57
Factory< FactoryProduct > FactoryType
Definition: Factory.h:71
static Factory * instance_()
singleton access to Factory
Definition: Factory.h:82
FactoryProduct *(* FunctionType)()
Function signature of creator function.
Definition: Factory.h:68
Returns FactoryProduct* based on the name of the desired concrete FactoryProduct. ...
Definition: Factory.h:61
static void registerProduct(const String &name, const FunctionType creator)
register new concrete FactoryProduct
Definition: Factory.h:131
static bool isRegistered(const String &name)
Returns if a factory product is registered.
Definition: Factory.h:137
static Factory * instance_ptr_
Definition: Factory.h:160
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
static FactoryProduct * create(const String &name)
return FactoryProduct according to unique identifier name
Definition: Factory.h:112
Factory()
Constructor.
Definition: Factory.h:77
virtual ~Factory()
Destructor.
Definition: Factory.h:74
Base class for Factory<T>
Definition: FactoryBase.h:49
static FactoryBase * getFactory(const String &name)
return DefaultParamHandler according to unique identifier name
Definition: SingletonRegistry.h:83
Invalid value exception.
Definition: Exception.h:336
static std::vector< String > registeredProducts()
Returns a list of registered products.
Definition: Factory.h:147
friend class singletonsNeedNoFriends
Definition: Factory.h:64
Map inventory_
Definition: Factory.h:159
Map::const_iterator MapIterator
Definition: Factory.h:70
std::map< String, FunctionType > Map
Definition: Factory.h:69
static void registerFactory(const String &name, FactoryBase *instance)
register new concrete Factory
Definition: SingletonRegistry.h:102