![]() |
Home | Libraries | License | Support | People | ALPS Web Site |
alps::factory
// In header: <alps/factory.h> template<typename KEY, typename BASE> class factory { public: // types typedef BASE base_type; // the type of the base class from which all objects created by the factory are derived typedef KEY key_type; // the type of the key used to identify derived classes // construct/copy/destruct factory(); ~factory(); // public member functions template<typename T> bool register_type(key_type); bool unregister_type(key_type); base_type * create(key_type) const; };
a factory class
factory
public member functionstemplate<typename T> bool register_type(key_type k);register a type
a new derived type is registered by passing the type as template parameter and the key as argument. A second call with the same key will override the registration done by the previous call.
Parameters: |
|
||
Returns: |
|
bool unregister_type(key_type k);unregister a type
the registration information for the key given is deleted
Parameters: |
|
||
Returns: |
|
base_type * create(key_type k) const;create an object
attempts to create an object of the type previously associated with the key.
Parameters: |
|
||
Returns: |
a pointer to a new object of the type registered with the key |
||
Throws: |
\c std::runtime_error if no type was associated with the key |
Copyright © 1994, 2002-2005 Matthias Troyer, Synge Todo |