30 #ifndef __CLAW_FACTORY_HPP__ 31 #define __CLAW_FACTORY_HPP__ 33 #ifdef CLAW_FACTORY_IS_SINGLETON 55 :
exception("No type has this identifier.")
72 template <
typename BaseClass,
typename IdentifierType>
73 #ifdef CLAW_FACTORY_IS_SINGLETON 74 class factory :
public basic_singleton<factory<BaseClass, IdentifierType> >
84 class class_creator_base
87 virtual ~class_creator_base();
88 virtual BaseClass* create()
const = 0;
101 template <
typename Derived>
102 class class_creator :
public class_creator_base
105 virtual Derived* create()
const;
110 typedef IdentifierType identifier_type;
113 typedef BaseClass base_class;
116 typedef std::map<identifier_type, class_creator_base*> class_map;
121 template <
typename T>
122 bool register_type(
const identifier_type&
id);
124 base_class* create(
const identifier_type&
id)
const;
126 bool is_known_type(
const identifier_type&
id)
const;
137 #include <claw/factory.tpp> 139 #endif // __CLAW_FACTORY_HPP__ A simple class to use as exception with string message.
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.
Exception thrown when an incorrect identifier is given to a type.
A simple class to use as exception with string message.
bad_type_identifier()
Constructor.
This is the main namespace.