13 #ifndef FACTORY_INCLUDED
14 #define FACTORY_INCLUDED
34 template<
class AbstractProduct,
typename ProductCreator>
38 typedef std::map<IdentifierType, ProductCreator>
Map;
54 typename Map::const_iterator i =
m_map.find(subtype);
55 if (i !=
m_map.end()) {
58 fprintf(stderr,
"Factory::find: unknown type \"%s\"\n", subtype.c_str());
71 m_map.insert(
typename Map::value_type(subtype, creator)).second) {
74 fprintf(stderr,
"Factory::append: duplicate key \"%s\"\n", subtype.c_str());
111 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.