4 #ifndef UTILMM_TYPES_FACTORY_HEADER 5 # define UTILMM_TYPES_FACTORY_HEADER 6 #include "utilmm/config/config.h" 8 #include "boost/utility.hpp" 42 template<
class AbstractProduct,
typename IdentifierType,
typename Result,
43 typename ProductCreator,
44 template<
typename,
class,
typename>
class FactoryErrorPolicy,
47 :
public FactoryErrorPolicy<IdentifierType, AbstractProduct, Result>,
48 public boost::noncopyable {
53 typedef std::map<IdentifierType, ProductCreator, OrderId> factory_db;
55 factory_db associations;
70 bool add(id_param
id, creator_param creator) {
71 typename factory_db::value_type to_add(
id, creator);
73 return associations.insert(to_add).second;
84 bool remove(id_param id) {
85 return associations.erase(
id)==1;
101 typename factory_db::iterator i = associations.find(to);
103 return associations.end()==i ||
add(from, i->second);
117 typename factory_db::iterator i = associations.find(
id);
119 if( associations.end()==i )
120 return this->on_unknown_id(
id);
122 return (i->second)();
134 return associations.find(
id)!=associations.end();
149 typename factory_db::const_iterator i = associations.find(
id);
151 if( associations.end()==i )
152 return this->on_unknown_type(
id);
167 # define IN_UTILMM_TYPES_FACTORY_HEADER 168 #include "utilmm/types/bits/factory.tcc" 169 # undef IN_UTILMM_TYPES_FACTORY_HEADER 170 #endif // UTILMM_TYPES_FACTORY_HEADER Forward declaration of utilmm::factory.
Generic Factory implementation.
Definition: factory.hh:46
bool add(id_param id, creator_param creator)
Add a new production method.
Definition: factory.hh:70
Forward declaration of utilmm::singleton::wrapper.
Wrapper for singleton instances.
Definition: wrapper.hh:31
Definition: auto_flag.hh:6
Definition of utilmm::arg_traits class.
ProductCreator const & get_creator(id_param id) const
Creation method access.
Definition: factory.hh:148
computed_type type
argument type
Definition: arg_traits.hh:38
bool make_alias(id_param from, id_param to)
Alias creation.
Definition: factory.hh:100
Result create(id_param id)
Creation method.
Definition: factory.hh:116
bool check_entry(id_param id) const
Check for entry.
Definition: factory.hh:133
Definition of utilmm::factory_toolbox::error.