14 #ifndef FACTORY_INCLUDED
15 #define FACTORY_INCLUDED
35 template<
class AbstractProduct,
typename ProductCreator>
39 typedef std::map<IdentifierType, ProductCreator>
Map;
55 typename Map::const_iterator i =
m_map.find(subtype);
56 if (i !=
m_map.end()) {
59 fprintf(stderr,
"Factory::find: unknown type \"%s\"\n", subtype.c_str());
72 m_map.insert(
typename Map::value_type(subtype, creator)).second) {
75 fprintf(stderr,
"Factory::append: duplicate key \"%s\"\n", subtype.c_str());
112 template<
class AbstractProduct,
typename ProductCreator>
static FactoryTemplate & Instance()
static bool Register(const IdentifierType &subtype, ProductCreator creator)
static void create_instance()
static ProductCreator Find(const IdentifierType &subtype)
static FactoryTemplate * s_instance
bool append(const IdentifierType &subtype, ProductCreator creator)
virtual ~FactoryTemplate()
std::map< IdentifierType, ProductCreator > Map
ProductCreator find(const IdentifierType &subtype)
FactoryTemplate & operator=(const FactoryTemplate &)
FactoryTemplate(const FactoryTemplate &)
std::string IdentifierType
Factory template class.