endstone::Registry
Abstract registry interface for keyed objects.
template <typename T>
Functions:
| Name | Description |
|---|---|
forEach | Apply a function to each stored element. |
get | Get the object by its key. |
get | Const overload of get() . |
getOrThrow | Get the object by its key or throw if missing. |
getOrThrow | Const overload of getOrThrow() . |
forEach
void forEach(std::function<bool(const T &)> func) constApply 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:
funcA callable object taking a const reference to an element and returning a boolean. Returning false stops the iteration.
get
T *get(NamespacedKey key) noexceptGet the object by its key.
Returns a raw pointer to the object, or nullptr if not found.
Parameters:
keyNon-null key to look up.
Returns:
T* Pointer to the object, or nullptr if it does not exist.
const T *get(NamespacedKey key) noexcept constConst overload of get() .
Parameters:
keyNon-null key to look up.
Returns:
const T* Pointer to the object, or nullptr if it does not exist.
getOrThrow
T &getOrThrow(const NamespacedKey key)Get the object by its key or throw if missing.
Parameters:
keyKey of the object to retrieve.
Returns:
T& Reference to the object with the given key.
Exception:
std::invalid_argumentif no object with the given key exists.
const T &getOrThrow(const NamespacedKey key) constConst overload of getOrThrow() .
Parameters:
keyKey of the object to retrieve.
Returns:
const T& Const reference to the object with the given key.
Exception:
std::invalid_argumentif no object with the given key exists.