#include <nub/objfactory.h>
Public Types | |
typedef factory_base::fallback_t | fallback_t |
typedef nub::soft_ref < nub::object > | base_t |
Public Member Functions | |
const char * | register_creator (rutz::creator_base< base_t > *creator, const char *name) |
Registers a creation object with the factory. | |
const char * | register_creator (derived_t(*func)(), const char *key=0) |
Registers a creation function with the factory. | |
void | register_alias (const char *orig_key, const char *alias_key) |
Introduces an alternate key for an existing key. | |
bool | is_valid_key (const char *key) const |
Query whether a given key is a valid, known key in the factory. | |
rutz::fstring | get_known_keys (const char *sep) const |
Get a list of known keys, separated by sep. | |
base_t | new_object (const rutz::fstring &type) const |
Returns a new object of a given type. | |
base_t | new_checked_object (const rutz::fstring &type) const |
Returns a new object of a given type. | |
void | set_fallback (rutz::shared_ptr< factory_fallback > f) |
Change the fallback object. | |
void | set_fallback (fallback_t *fptr) |
Change the fallback function. | |
Static Public Member Functions | |
static obj_factory & | instance () |
Return the singleton instance. | |
Protected Member Functions | |
obj_factory () | |
Default constructor. | |
virtual | ~obj_factory () throw () |
Virtual destructor. | |
rutz::creator_base< base_t > * | find_creator (const rutz::fstring &key) const |
Find a creator for the given key; otherwise return null. |
Definition at line 49 of file objfactory.h.
const char* rutz::factory< nub::soft_ref< nub::object > >::register_creator | ( | rutz::creator_base< base_t > * | creator, | |
const char * | name | |||
) | [inline, inherited] |
Registers a creation object with the factory.
The function returns the actual key that was paired with the creation function.
Definition at line 225 of file factory.h.
References rutz::assoc_array< value_t >::set_ptr_for_key().
const char* rutz::factory< nub::soft_ref< nub::object > >::register_creator | ( | derived_t(*)() | func, | |
const char * | key = 0 | |||
) | [inline, inherited] |
Registers a creation function with the factory.
The default key associated with the creation function will be given by the type's actual C++ name. The function returns the actual key that was paired with the creation function.
Definition at line 240 of file factory.h.
References rutz::demangled_name(), and rutz::assoc_array< value_t >::set_ptr_for_key().
void rutz::factory< nub::soft_ref< nub::object > >::register_alias | ( | const char * | orig_key, | |
const char * | alias_key | |||
) | [inline, inherited] |
Introduces an alternate key for an existing key.
There must already have been a creation function registered for the original key.
Definition at line 258 of file factory.h.
References rutz::creator_base< T >::clone(), rutz::assoc_array< value_t >::get_ptr_for_key(), and rutz::assoc_array< value_t >::set_ptr_for_key().
base_t rutz::factory< nub::soft_ref< nub::object > >::new_object | ( | const rutz::fstring & | type | ) | const [inline, inherited] |
Returns a new object of a given type.
If the given type has not been registered with the factory, a null pointer is returned.
Definition at line 288 of file factory.h.
References rutz::creator_base< T >::create(), and rutz::factory< T >::find_creator().
base_t rutz::factory< nub::soft_ref< nub::object > >::new_checked_object | ( | const rutz::fstring & | type | ) | const [inline, inherited] |
Returns a new object of a given type.
If the given type has not been registered with the factory, an exception is thrown.
Definition at line 300 of file factory.h.
References rutz::creator_base< T >::create(), rutz::factory< T >::find_creator(), SRC_POS, and rutz::assoc_array< value_t >::throw_for_key().