28template <
class Key,
class Factory,
class Compare>
33template <
class Key,
class Factory,
class Compare>
36 default_key(default_key),
37 default_factory(default_factory)
42template <
class Key,
class Factory,
class Compare>
43FactoryRegistry<Key, Factory, Compare>::~FactoryRegistry()
52template <
class Key,
class Factory,
class Compare>
58 typename FactoryMap::iterator iter = m.find(key);
62 s <<
"FactoryRegistry:: overwriting previous value of key in registry.\n key: " << key;
67 m.insert(std::pair<Key, Factory>(key, factory));
70template <
class Key,
class Factory,
class Compare>
75 typename FactoryMap::iterator iter = m.find(key);
81 s <<
"FactoryRegistry:: Attempt to remove key from registry, but it's not in there...\n key: " << key;
89template <
class Key,
class Factory,
class Compare>
93 for (
typename FactoryMap::const_iterator i = m.begin(); i != m.end(); ++i)
94 s << i->first <<
'\n';
97template <
class Key,
class Factory,
class Compare>
101 typename FactoryMap::const_iterator i = m.find(key);
109 std::cerr <<
"FactoryRegistry: key " << key <<
" not found in current registry\n" << m.size() <<
" possible values are:\n";
114 std::cerr <<
"Using value corresponding to key \"" << default_key <<
"\"" << std::endl;
115 return default_factory;
119 error(
"FactoryRegistry: aborting");
121 return default_factory;
FactoryRegistry()
Default constructor without defaults (see find_factory())
Definition FactoryRegistry.inl:29
Factory const & find_factory(const Key &key) const
Find a factory corresponding to a key.
Definition FactoryRegistry.inl:99
void remove_from_registry(const Key &key)
Remove a pair from the registry.
Definition FactoryRegistry.inl:72
void list_keys(std::ostream &s) const
List all keys to an ostream, separated by newlines.
Definition FactoryRegistry.inl:91
void add_to_registry(const Key &key, Factory const &factory)
Add a pair to the registry.
Definition FactoryRegistry.inl:54
Declaration of stir::error()
void error(const char *const s,...)
Print error with format string a la printf and throw exception.
Definition error.cxx:42
void warning(const char *const s,...)
Print warning with format string a la printf.
Definition warning.cxx:41
Declaration of stir::warning()