34template <
class AbstractProduct,
typename IdentifierType,
typename ReturnType = std::unique_ptr<AbstractProduct>,
35 class ProductCreator = std::function<ReturnType()>,
class... Args>
44 MBool add(
const IdentifierType&
id, ProductCreator creator) {
45 return m_assoc.insert(
typename AssocMap::value_type(
id, creator)).second;
61 ReturnType
create(
const IdentifierType&
id, Args... args)
const {
64 return (i->second)(args...);
66 TERMM(1,
"Identifier not found.");
71 typedef std::map<IdentifierType, ProductCreator>
AssocMap;
Class implementing the object factory pattern.
std::map< IdentifierType, ProductCreator > AssocMap
MBool remove(const IdentifierType &id)
Function to remove existing types from the factory.
ReturnType create(const IdentifierType &id, Args... args) const
Function to create a new instance of a type.
MBool add(const IdentifierType &id, ProductCreator creator)
Function to add new types to the factory.