30 #ifndef __CLAW_FACTORY_HPP__
31 #define __CLAW_FACTORY_HPP__
33 #ifdef CLAW_FACTORY_IS_SINGLETON
56 :
exception("No type has this identifier.")
72 template<
typename BaseClass,
typename IdentifierType>
73 #ifdef CLAW_FACTORY_IS_SINGLETON
75 public basic_singleton< factory<BaseClass, IdentifierType> >
85 class class_creator_base
88 virtual ~class_creator_base();
89 virtual BaseClass*
create()
const = 0;
102 template<
typename Derived>
104 public class_creator_base
107 virtual Derived*
create()
const;
112 typedef IdentifierType identifier_type;
115 typedef BaseClass base_class;
118 typedef std::map<identifier_type, class_creator_base*> class_map;
126 base_class*
create(
const identifier_type&
id )
const;
141 #endif // __CLAW_FACTORY_HPP__
A simple class to use as exception with string message.
bool is_known_type(const identifier_type &id) const
Tell in a type with a given id is known by the factory.
The design pattern of the factory allow to dynamically instanciate classes of various types given an ...
A (really) basic implementation of the singleton design pattern.
bool register_type(const identifier_type &id)
Register a type in the factory.
Exception thrown when an incorrect identifier is given to a type.
A simple class to use as exception with string message.
base_class * create(const identifier_type &id) const
Create a new instance.
bad_type_identifier()
Constructor.
Implementation of the claw::pattern::factory class.