ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::enumrecords::EnumRecords< TEnum > Struct Template Reference

Description:

template<typename TEnum>
requires alib::enumrecords::HasRecords<TEnum>
struct alib::enumrecords::EnumRecords< TEnum >

This is a pure static interface type usable with enumeration types that dispose of a specialization of the type trait RecordsTraits.

The type has two main purposes:

  1. Providing overloaded methods Bootstrap which allow to defined enum data records during bootstrapping of ALib and the using software.
  2. Providing an iterator over all records defined for elements of TEnum.

A third purpose, namely to retrieve the default (single) enumeration record for a specific enum element is not provided by this type, but instead offered with likewise templated namespace functions

Note
The rationale for this is techical: Using namespace methods, the compiler can deduce template parameter TEnum from the function parameter, which was not possible if the functions were static methods of this templated type.
Attention
While this type becomes available with the inclusion if the header ALib.EnumRecords.H, the overloaded Bootstrap methods (which are to be used solely during bootstrap, with single-threaded access to this backend), become available only with further inclusion of ALib.EnumRecords.Bootstrap.H.

The rationale for the above is twofold: It reduces header-file dependencies from the majority of code that just use enum records and not defne them. Secondly, it stresses the fact that the variouos Bootstrap methods must be used only while bootstrapping is done.

See also
Chapter ALib Enum Records of the Programmer's Manual of this module.
Template Parameters
TEnumThe enumeration type that the static methods of this type are to use.

Definition at line 270 of file records.inl.

Inner Type Index:

struct  ForwardIterator
 

Public Type Index:

using TIntegral = typename std::underlying_type<TEnum>::type
 The enum's underlying integer type.
 
using TRecord = typename RecordsTraits<TEnum>::Type
 The enum's associated record type.
 

Public Static Method Index:

template<typename TRecord, typename TAssociated = typename RecordsTraits<TEnum>::Type>
static constexpr bool AreOfType ()
 
static ForwardIterator begin ()
 
static constexpr ForwardIterator end ()
 

Public Method Index:

 EnumRecords () noexcept=default
 Defaulted constructor.
 

Type Definition Details:

◆ TIntegral

template<typename TEnum>
using alib::enumrecords::EnumRecords< TEnum >::TIntegral = typename std::underlying_type<TEnum>::type

The enum's underlying integer type.

Definition at line 279 of file records.inl.

◆ TRecord

template<typename TEnum>
using alib::enumrecords::EnumRecords< TEnum >::TRecord = typename RecordsTraits<TEnum>::Type

The enum's associated record type.

Definition at line 282 of file records.inl.

Method Details:

◆ AreOfType()

template<typename TEnum>
template<typename TRecord, typename TAssociated = typename RecordsTraits<TEnum>::Type>
constexpr bool alib::enumrecords::EnumRecords< TEnum >::AreOfType ( )
inlinestaticconstexpr

Tests if TEnum has an associated record type that either is or is derived from type TRecord.

Template Parameters
TRecordThe enum record base type required.
TAssociatedDeduced by the compiler. Must not be specified.
Returns
Returns true if the given record type is the same or a base class of the record type associated with the given enum. Otherwise, returns false.

Definition at line 291 of file records.inl.

Here is the call graph for this function:

◆ begin()

template<typename TEnum>
ForwardIterator alib::enumrecords::EnumRecords< TEnum >::begin ( )
inlinestatic

Returns an iterator referring to the first enum record defined for type TEnum.

Note
Receiving the list of enum records is internally implemented using class Singleton and executes in constant time O(1), in effect almost no time.
Like any other entity in this class, this method is static, apart from a defaulted (empty) constructor, which is provided for the sole purpose of allowing range-based for(:) loops.
Returns
An iterator to the first record defined for enumeration type TEnum.

Definition at line 409 of file records.inl.

Here is the call graph for this function:

◆ end()

template<typename TEnum>
constexpr ForwardIterator alib::enumrecords::EnumRecords< TEnum >::end ( )
inlinestaticconstexpr

Returns an iterator referring to the first element behind the list.

See also
The note documented with sibling method begin.
Returns
The end of the list.

Definition at line 419 of file records.inl.


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