|
STIR 6.5.0
|
This class can be used to store 'factories' and their corresponding keys. It is essentially a map, but with some extra embelishments. More...
#include "stir/FactoryRegistry.h"

Public Member Functions | |
| FactoryRegistry () | |
| Default constructor without defaults (see find_factory()). | |
| FactoryRegistry (const Key &default_key, const Factory &default_factory) | |
| constructor with default values which will be returned when no match is found (see find_factory()) | |
| void | add_to_registry (const Key &key, Factory const &factory) |
| Add a pair to the registry. | |
| void | remove_from_registry (const Key &key) |
| Remove a pair from the registry. | |
| void | list_keys (std::ostream &s) const |
| List all keys to an ostream, separated by newlines. | |
| Factory const & | find_factory (const Key &key) const |
| Find a factory corresponding to a key. | |
This class can be used to store 'factories' and their corresponding keys. It is essentially a map, but with some extra embelishments.
A factory is supposed to be an object which can create another object, although this is not really enfored by the implementation of FactoryRegistry.
Key,Factory,Compare must be suitable as defined for std::map. In addition, FactoryRegistry::list_keys() requires that operator<<(ostream&, const Key&) is defined.
|
inline |
Default constructor without defaults (see find_factory()).
References FactoryRegistry().
Referenced by FactoryRegistry().
|
inline |
constructor with default values which will be returned when no match is found (see find_factory())
References add_to_registry().
|
inline |
Add a pair to the registry.
Adding the same key twice will overwrite the first value.
References stir::warning().
Referenced by FactoryRegistry().
|
inline |
Remove a pair from the registry.
References stir::warning().
|
inline |
List all keys to an ostream, separated by newlines.
Referenced by find_factory().
|
inline |
Find a factory corresponding to a key.
If the key is not found, the behaviour depends on which constructor was used. If the (default) no-argument constructor is used, an error message is printed, and the program aborts. If the 2nd constructor with default values, the default_factory is returned.
References stir::error(), and list_keys().
Referenced by stir::RegisteredObject< Root >::read_registered_object().