Class endstone::Registry¶
template <Keyed T>
ClassList > endstone > Registry
Abstract registry interface for keyed objects. More...
#include <endstone/registry.h>
Public Types¶
Type | Name |
---|---|
typedef typename storage_type::const_iterator | const_iterator Const iterator over stored elements. |
typedef const T & | const_reference |
typedef typename storage_type::iterator | iterator Iterator over stored elements. |
typedef std::string_view | key_type |
typedef T & | reference |
typedef T | value_type |
Public Functions¶
Type | Name |
---|---|
virtual iterator | begin () = 0 Returns iterator to beginning of registry items. |
virtual const_iterator | begin () const = 0 Const begin iterator. |
virtual iterator | end () = 0 Returns iterator to end of registry items. |
virtual const_iterator | end () const = 0 Const end iterator. |
virtual T * | get (key_type key) noexcept = 0 Get the object by its key. |
virtual const T * | get (key_type key) noexcept const = 0 Const overload of get() . |
virtual T & | getOrThrow (key_type key) Get the object by its key or throw if missing. |
virtual const T & | getOrThrow (key_type key) const Const overload of getOrThrow() . |
virtual | ~Registry () = default |
Protected Types¶
Type | Name |
---|---|
typedef std::unordered_map< key_type, T > | storage_type Underlying storage type. |
Detailed Description¶
Provides lookup by key (nullable or exception-throwing) and iteration.
Template parameters:
T
Must satisfy Keyed, i.e. implement getKey().
Public Types Documentation¶
typedef const_iterator¶
Const iterator over stored elements.
typedef const_reference¶
typedef iterator¶
Iterator over stored elements.
typedef key_type¶
typedef reference¶
typedef value_type¶
Public Functions Documentation¶
function begin [½]¶
Returns iterator to beginning of registry items.
Enables range-based for loops.
Returns:
iterator Begin iterator.
function begin [2/2]¶
Const begin iterator.
Returns:
const_iterator Const begin iterator.
function end [½]¶
Returns iterator to end of registry items.
Returns:
iterator End iterator.
function end [2/2]¶
Const end iterator.
Returns:
const_iterator Const end iterator.
function get [½]¶
Get the object by its key.
Returns a raw pointer to the object, or nullptr if not found.
Parameters:
key
Non-null key to look up.
Returns:
T* Pointer to the object, or nullptr if it does not exist.
function get [2/2]¶
Const overload of get() .
Parameters:
key
Non-null key to look up.
Returns:
const T* Pointer to the object, or nullptr if it does not exist.
function getOrThrow [½]¶
Get the object by its key or throw if missing.
Parameters:
key
Key of the object to retrieve.
Returns:
T& Reference to the object with the given key.
Exception:
std::invalid_argument
if no object with the given key exists.
function getOrThrow [2/2]¶
Const overload of getOrThrow() .
Parameters:
key
Key of the object to retrieve.
Returns:
const T& Const reference to the object with the given key.
Exception:
std::invalid_argument
if no object with the given key exists.
function ~Registry¶
Protected Types Documentation¶
typedef storage_type¶
Underlying storage type.
The documentation for this class was generated from the following file include/endstone/registry.h