Skip to content

Class endstone::Registry

template <Keyed T>

ClassList > endstone > Registry

Abstract registry interface for keyed objects. More...

  • #include <endstone/registry.h>

Public Types

Type Name
typedef typename storage_type::const_iterator const_iterator
Const iterator over stored elements.
typedef const T & const_reference
typedef typename storage_type::iterator iterator
Iterator over stored elements.
typedef std::string_view key_type
typedef T & reference
typedef T value_type

Public Functions

Type Name
virtual iterator begin () = 0
Returns iterator to beginning of registry items.
virtual const_iterator begin () const = 0
Const begin iterator.
virtual iterator end () = 0
Returns iterator to end of registry items.
virtual const_iterator end () const = 0
Const end iterator.
virtual T * get (key_type key) noexcept = 0
Get the object by its key.
virtual const T * get (key_type key) noexcept const = 0
Const overload of get() .
virtual T & getOrThrow (key_type key)
Get the object by its key or throw if missing.
virtual const T & getOrThrow (key_type key) const
Const overload of getOrThrow() .
virtual ~Registry () = default

Protected Types

Type Name
typedef std::unordered_map< key_type, T > storage_type
Underlying storage type.

Detailed Description

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

Template parameters:

  • T Must satisfy Keyed, i.e. implement getKey().

Public Types Documentation

typedef const_iterator

Const iterator over stored elements.

using endstone::Registry< T >::const_iterator =  typename storage_type::const_iterator;


typedef const_reference

using endstone::Registry< T >::const_reference =  const T &;

typedef iterator

Iterator over stored elements.

using endstone::Registry< T >::iterator =  typename storage_type::iterator;


typedef key_type

using endstone::Registry< T >::key_type =  std::string_view;

typedef reference

using endstone::Registry< T >::reference =  T &;

typedef value_type

using endstone::Registry< T >::value_type =  T;

Public Functions Documentation

function begin [½]

Returns iterator to beginning of registry items.

virtual iterator endstone::Registry::begin () = 0

Enables range-based for loops.

Returns:

iterator Begin iterator.


function begin [2/2]

Const begin iterator.

virtual const_iterator endstone::Registry::begin () const = 0

Returns:

const_iterator Const begin iterator.


function end [½]

Returns iterator to end of registry items.

virtual iterator endstone::Registry::end () = 0

Returns:

iterator End iterator.


function end [2/2]

Const end iterator.

virtual const_iterator endstone::Registry::end () const = 0

Returns:

const_iterator Const end iterator.


function get [½]

Get the object by its key.

virtual T * endstone::Registry::get (
    key_type key
) noexcept = 0

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() .

virtual const  T * endstone::Registry::get (
    key_type key
) noexcept const = 0

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.

inline virtual T & endstone::Registry::getOrThrow (
    key_type key
) 

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() .

inline virtual const  T & endstone::Registry::getOrThrow (
    key_type key
) const

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

virtual endstone::Registry::~Registry () = default

Protected Types Documentation

typedef storage_type

Underlying storage type.

using endstone::Registry< T >::storage_type =  std::unordered_map<key_type, T>;



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