Template Class Registry#

Class Documentation#

template<typename Key, typename Value>
class Registry#

Global key -> value store, used for self-registration at static-initialization time. There is exactly one instance per (Key, Value) pair, reachable through instance(). An entry can never be overwritten: registering an existing key is a no-op.

Public Types

using map_type = std::map<Key, Value>#
using iterator = typename map_type::iterator#
using const_iterator = typename map_type::const_iterator#

Public Functions

Registry() = default#
Registry(const Registry&) = delete#
Registry &operator=(const Registry&) = delete#
inline bool register_entry(Key key, Value value)#
Returns:

true if the entry was inserted, false if the key already existed.

inline bool register_entries(std::vector<std::pair<Key, Value>> list)#
Returns:

true if all the entries were inserted.

inline const Value &get(const Key &key) const#
Throws:

std::out_of_range – if the key is not registered.

inline Value get_safe(const Key &key, Value default_value) const#
inline bool contains(const Key &key) const#
inline std::size_t size() const#
inline const map_type &get_all() const#
inline iterator find(const Key &key)#
inline const_iterator find(const Key &key) const#
inline iterator begin()#
inline const_iterator begin() const#
inline iterator end()#
inline const_iterator end() const#

Public Static Functions

static inline Registry<Key, Value> &instance()#