Skip to Content
⚠ Under Construction
ReferenceC++ APIRegistry

endstone::Registry

Abstract registry interface for keyed objects.

template <typename T>

Functions:

NameDescription
forEachApply a function to each stored element.
getGet the object by its key.
getConst overload of get() .
getOrThrowGet the object by its key or throw if missing.
getOrThrowConst overload of getOrThrow() .

forEach

void forEach(std::function<bool(const T &)> func) const

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.

get

T *get(NamespacedKey key) noexcept

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.

const T *get(NamespacedKey key) noexcept const

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.

getOrThrow

T &getOrThrow(const NamespacedKey key)

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.
const T &getOrThrow(const NamespacedKey key) const

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.
Last updated on