Skip to content

Class endstone::Registry

template <typename T>

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

See endstone::IRegistry

Type Name
virtual ~IRegistry () = default

Detailed Description

Provides lookup by identifier (nullable or exception-throwing) and iteration.

Template parameters:

  • T Must implement getId().

Public Functions Documentation

function forEach

Apply a function to each stored element.

virtual void endstone::Registry::forEach (
    std::function< bool ( const  T &)> func
) const = 0

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 identifier.

virtual T * endstone::Registry::get (
    Identifier < T > id
) noexcept = 0

Returns a raw pointer to the object, or nullptr if not found.

Parameters:

Returns:

T* Pointer to the object, or nullptr if it does not exist.


function get [2/2]

Get the object by its identifier.

virtual const  T * endstone::Registry::get (
    Identifier < T > id
) noexcept const = 0

Returns a raw pointer to the object, or nullptr if not found.

Parameters:

  • id Non-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.

inline virtual T & endstone::Registry::getOrThrow (
    Identifier < T > id
) 

Parameters:

  • id identifier of the object to retrieve.

Returns:

T& Reference to the object with the given identifier.

Exception:

  • std::invalid_argument if no object with the given identifier exists.

function getOrThrow [2/2]

Get the object by its identifier or throw if missing.

inline virtual const  T & endstone::Registry::getOrThrow (
    Identifier < T > id
) const

Parameters:

  • id identifier of the object to retrieve.

Returns:

const T& Const reference to the object with the given identifier.

Exception:

  • std::invalid_argument if no object with the given identifier exists.


The documentation for this class was generated from the following file include/endstone/registry.h