Class endstone::Registry¶
ClassList > endstone > Registry
Abstract registry interface for objects with identifiers. More...
#include <endstone/registry.h>
Inherits the following classes: endstone::IRegistry
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 (Identifier< T > id) noexcept = 0 Get the object by its identifier. |
| virtual const T * | get (Identifier< T > id) noexcept const = 0 Get the object by its identifier. |
| virtual T & | getOrThrow (Identifier< T > id) Get the object by its identifier or throw if missing. |
| virtual const T & | getOrThrow (Identifier< T > id) const Get the object by its identifier or throw if missing. |
Public Functions inherited from endstone::IRegistry¶
| Type | Name |
|---|---|
| virtual | ~IRegistry () = default |
Detailed Description¶
Provides lookup by identifier (nullable or exception-throwing) and iteration.
Template parameters:
TMust implement getId().
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:
funcA 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 identifier.
Returns a raw pointer to the object, or nullptr if not found.
Parameters:
idIdentifier to look up.
Returns:
T* Pointer to the object, or nullptr if it does not exist.
function get [2/2]¶
Get the object by its identifier.
Returns a raw pointer to the object, or nullptr if not found.
Parameters:
idNon-null identifier to look up.
Returns:
const T* Pointer to the object, or nullptr if it does not exist.
function getOrThrow [½]¶
Get the object by its identifier or throw if missing.
Parameters:
ididentifier of the object to retrieve.
Returns:
T& Reference to the object with the given identifier.
Exception:
std::invalid_argumentif no object with the given identifier exists.
function getOrThrow [2/2]¶
Get the object by its identifier or throw if missing.
Parameters:
ididentifier of the object to retrieve.
Returns:
const T& Const reference to the object with the given identifier.
Exception:
std::invalid_argumentif no object with the given identifier exists.
The documentation for this class was generated from the following file include/endstone/registry.h