Class endstone::Registry¶
ClassList > endstone > Registry
Abstract registry interface for keyed objects. More...
#include <endstone/registry.h>
Public Functions¶
Type | Name |
---|---|
virtual void | forEach (std::function< bool(const T &)> func) const = 0 Apply a function to each stored element. |
virtual T * | get (NamespacedKey key) noexcept = 0 Get the object by its key. |
virtual const T * | get (NamespacedKey key) noexcept const = 0 Const overload of get() . |
virtual T & | getOrThrow (const NamespacedKey key) Get the object by its key or throw if missing. |
virtual const T & | getOrThrow (const NamespacedKey key) const Const overload of getOrThrow() . |
virtual | ~Registry () = default |
Detailed Description¶
Provides lookup by key (nullable or exception-throwing) and iteration.
Template parameters:
T
Must satisfy Keyed, i.e. implement getKey().
Public Functions Documentation¶
function forEach¶
Apply a function to each stored element.
Iterates over all stored elements and applies the provided function to them. The iteration continues until the function returns false or all elements have been processed.
Parameters:
func
A callable object taking a const reference to an element and returning a boolean. Returning false stops the iteration.
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¶
The documentation for this class was generated from the following file include/endstone/registry.h