GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::RegistryElementIDBase< Self > Class Template Reference

Base class for an opaque handle to a specific element in a Registry. More...

#include <GREM/core/data/Registry.hpp>

Public Types

using Identifier = uint32_t
 Underlying value type.
using Index = uint16_t
 Index type.
using Generation = uint16_t
 Generation counter type.
using Flags = uint8_t
 User-defined flags index type.

Public Member Functions

constexpr RegistryElementIDBase () noexcept=default
 Construct an invalid element handle.
constexpr RegistryElementIDBase (Index index, Generation generation, Flags flags)
 Construct an element handle with a specific set of parameters.
constexpr operator bool () const noexcept
 Check if this handle is potentially valid.
constexpr Identifier getIdentifier () const noexcept
 Get a unique identifier for the underlying representation of the element handle.
constexpr Index getIndex () const noexcept
 Get the index of the element's generation slot.
constexpr Generation getGeneration () const noexcept
 Get the generation counter value of the element.
constexpr Flags getFlags () const noexcept
 Get the user-defined flags of the element.
constexpr bool operator== (const RegistryElementIDBase &other) const noexcept=default
 Compare this handle to another for equality.
constexpr std::strong_ordering operator<=> (const RegistryElementIDBase &other) const noexcept=default
 Compare this handle to another.

Static Public Attributes

static constexpr Index INVALID_INDEX = Limits<Index>::MAX
 Reserved index value for an invalid element handle.
static constexpr Index MAX_INDEX = Limits<Index>::MAX - 1
 Maximum valid index value.
static constexpr Generation MAX_GENERATION = (1 << 14) - 1
 Maximum valid generation counter value.
static constexpr Flags ALL_FLAGS = 0b11
 Maximum valid set of user-defined flags.

Friends

constexpr bool operator== (const Self &a, const Self &b) noexcept
 Compare two handles for equality.
constexpr std::strong_ordering operator<=> (const Self &a, const Self &b) noexcept
 Compare two handles.

Detailed Description

template<typename Self>
class grem::RegistryElementIDBase< Self >

Base class for an opaque handle to a specific element in a Registry.

Template Parameters
SelfCRTP argument for the concrete derived type.

Member Typedef Documentation

◆ Identifier

template<typename Self>
using grem::RegistryElementIDBase< Self >::Identifier = uint32_t

Underlying value type.

◆ Index

template<typename Self>
using grem::RegistryElementIDBase< Self >::Index = uint16_t

Index type.

◆ Generation

template<typename Self>
using grem::RegistryElementIDBase< Self >::Generation = uint16_t

Generation counter type.

◆ Flags

template<typename Self>
using grem::RegistryElementIDBase< Self >::Flags = uint8_t

User-defined flags index type.

Constructor & Destructor Documentation

◆ RegistryElementIDBase() [1/2]

template<typename Self>
grem::RegistryElementIDBase< Self >::RegistryElementIDBase ( )
constexprdefaultnoexcept

Construct an invalid element handle.

◆ RegistryElementIDBase() [2/2]

template<typename Self>
grem::RegistryElementIDBase< Self >::RegistryElementIDBase ( Index index,
Generation generation,
Flags flags )
inlineconstexpr

Construct an element handle with a specific set of parameters.

Parameters
indexindex of the element's generation slot within the registry. Must be less than or equal to MAX_INDEX.
generationgeneration counter value of the element. Must be less than or equal to MAX_GENERATION.
flagsuser-defined flags. Must be less than or equal to ALL_FLAGS.

Member Function Documentation

◆ operator bool()

template<typename Self>
grem::RegistryElementIDBase< Self >::operator bool ( ) const
inlineexplicitconstexprnoexcept

Check if this handle is potentially valid.

Returns
true if this handle is potentially valid, false if it is equal to a default-constructed invalid handle.

◆ getIdentifier()

template<typename Self>
Identifier grem::RegistryElementIDBase< Self >::getIdentifier ( ) const
inlinenodiscardconstexprnoexcept

Get a unique identifier for the underlying representation of the element handle.

Returns
the underlying value of the handle.

◆ getIndex()

template<typename Self>
Index grem::RegistryElementIDBase< Self >::getIndex ( ) const
inlinenodiscardconstexprnoexcept

Get the index of the element's generation slot.

Returns
the element index.

◆ getGeneration()

template<typename Self>
Generation grem::RegistryElementIDBase< Self >::getGeneration ( ) const
inlinenodiscardconstexprnoexcept

Get the generation counter value of the element.

Returns
the element generation.

◆ getFlags()

template<typename Self>
Flags grem::RegistryElementIDBase< Self >::getFlags ( ) const
inlinenodiscardconstexprnoexcept

Get the user-defined flags of the element.

Returns
the element flags.

◆ operator==()

template<typename Self>
bool grem::RegistryElementIDBase< Self >::operator== ( const RegistryElementIDBase< Self > & other) const
nodiscardconstexprdefaultnoexcept

Compare this handle to another for equality.

Parameters
otherthe handle to compare this one to.
Returns
true if the handles are equal, false otherwise.

◆ operator<=>()

template<typename Self>
std::strong_ordering grem::RegistryElementIDBase< Self >::operator<=> ( const RegistryElementIDBase< Self > & other) const
nodiscardconstexprdefaultnoexcept

Compare this handle to another.

Parameters
otherthe handle to compare this one to.
Returns
a strong ordering between the two handles.

◆ operator==

template<typename Self>
bool operator== ( const Self & a,
const Self & b )
friend

Compare two handles for equality.

Parameters
afirst handle.
bsecond handle.
Returns
true if the handles are equal, false otherwise.

◆ operator<=>

template<typename Self>
std::strong_ordering operator<=> ( const Self & a,
const Self & b )
friend

Compare two handles.

Parameters
afirst handle.
bsecond handle.
Returns
a strong ordering between the two handles.

Member Data Documentation

◆ INVALID_INDEX

template<typename Self>
Index grem::RegistryElementIDBase< Self >::INVALID_INDEX = Limits<Index>::MAX
staticconstexpr

Reserved index value for an invalid element handle.

◆ MAX_INDEX

template<typename Self>
Index grem::RegistryElementIDBase< Self >::MAX_INDEX = Limits<Index>::MAX - 1
staticconstexpr

Maximum valid index value.

◆ MAX_GENERATION

template<typename Self>
Generation grem::RegistryElementIDBase< Self >::MAX_GENERATION = (1 << 14) - 1
staticconstexpr

Maximum valid generation counter value.

◆ ALL_FLAGS

template<typename Self>
Flags grem::RegistryElementIDBase< Self >::ALL_FLAGS = 0b11
staticconstexpr

Maximum valid set of user-defined flags.


The documentation for this class was generated from the following file: