CbmRoot
Loading...
Searching...
No Matches
cbm::util::EnumKeySet< KeyList > Class Template Reference

A subset of some enumeration entries and rule for mapping them to a contiguous integral index. More...

#include <CbmEnumKeySet.h>

Inheritance diagram for cbm::util::EnumKeySet< KeyList >:
[legend]

Public Types

using Key_t = std::common_type_t<decltype(KeyList)...>
 Type of the keys.
 
using Underlying_t = std::underlying_type_t<Key_t>
 Underlying integral type of the enumerator.
 
using KeyContainer_t = std::array<Key_t, NofKeys()>
 

Static Public Member Functions

static constexpr bool CheckKey (Key_t key)
 Checks, if a key is provided within the Keys pack.
 
template<Key_t Key>
static constexpr size_t Index ()
 Returns an index of the enumeration key, which is passed as a template parameter.
 
static constexpr size_t Index (Key_t key)
 Returns an index of the enumeration key, which is passed as a parameter.
 
static constexpr Underlying_t MaxKey ()
 Returns maximal value of the keys.
 
static constexpr Underlying_t MinKey ()
 Returns minimal value of the keys.
 
static constexpr size_t NofKeys ()
 Returns number of keys.
 
static constexpr size_t MapperSize ()
 Returns size of the mapper.
 

Static Public Attributes

static constexpr KeyContainer_t kKeys = InitializedKeysArray()
 A list of keys (for loops)
 

Private Types

using Container_t = std::array<size_t, MapperSize()>
 

Static Private Member Functions

static constexpr auto InitializedKeysArray ()
 Returns initialized keys.
 
static constexpr auto InitializedMapper ()
 Returns the initialized mapper.
 

Static Private Attributes

static constexpr Container_t kMapper = InitializedMapper()
 A mapping array of Enum_t -> index.
 

Detailed Description

template<auto... KeyList>
class cbm::util::EnumKeySet< KeyList >

A subset of some enumeration entries and rule for mapping them to a contiguous integral index.

Template Parameters
KeyList...A subset of enumeration entries

Definition at line 26 of file CbmEnumKeySet.h.

Member Typedef Documentation

◆ Container_t

template<auto... KeyList>
using cbm::util::EnumKeySet< KeyList >::Container_t = std::array<size_t, MapperSize()>
private

Definition at line 81 of file CbmEnumKeySet.h.

◆ Key_t

template<auto... KeyList>
using cbm::util::EnumKeySet< KeyList >::Key_t = std::common_type_t<decltype(KeyList)...>

Type of the keys.

Definition at line 30 of file CbmEnumKeySet.h.

◆ KeyContainer_t

template<auto... KeyList>
using cbm::util::EnumKeySet< KeyList >::KeyContainer_t = std::array<Key_t, NofKeys()>

Definition at line 78 of file CbmEnumKeySet.h.

◆ Underlying_t

template<auto... KeyList>
using cbm::util::EnumKeySet< KeyList >::Underlying_t = std::underlying_type_t<Key_t>

Underlying integral type of the enumerator.

Definition at line 33 of file CbmEnumKeySet.h.

Member Function Documentation

◆ CheckKey()

template<auto... KeyList>
static constexpr bool cbm::util::EnumKeySet< KeyList >::CheckKey ( Key_t key)
inlinestaticconstexpr

Checks, if a key is provided within the Keys pack.

Parameters
keyA key to be tested
Returns
true The key is in the Keys pack
false The key is not in the Keys pack

Definition at line 39 of file CbmEnumKeySet.h.

◆ Index() [1/2]

template<auto... KeyList>
template<Key_t Key>
static constexpr size_t cbm::util::EnumKeySet< KeyList >::Index ( )
inlinestaticconstexpr

Returns an index of the enumeration key, which is passed as a template parameter.

Template Parameters
KeyA key

Definition at line 44 of file CbmEnumKeySet.h.

Referenced by cbm::util::EnumKeySet< ESomeEnum::B, ESomeEnum::D, ESomeEnum::E >::Index().

◆ Index() [2/2]

template<auto... KeyList>
static constexpr size_t cbm::util::EnumKeySet< KeyList >::Index ( Key_t key)
inlinestaticconstexpr

Returns an index of the enumeration key, which is passed as a parameter.

Parameters
keyA key

Definition at line 53 of file CbmEnumKeySet.h.

◆ InitializedKeysArray()

template<auto... KeyList>
static constexpr auto cbm::util::EnumKeySet< KeyList >::InitializedKeysArray ( )
inlinestaticconstexprprivate

Returns initialized keys.

Definition at line 84 of file CbmEnumKeySet.h.

◆ InitializedMapper()

template<auto... KeyList>
static constexpr auto cbm::util::EnumKeySet< KeyList >::InitializedMapper ( )
inlinestaticconstexprprivate

Returns the initialized mapper.

Definition at line 93 of file CbmEnumKeySet.h.

◆ MapperSize()

template<auto... KeyList>
static constexpr size_t cbm::util::EnumKeySet< KeyList >::MapperSize ( )
inlinestaticconstexpr

Returns size of the mapper.

Definition at line 76 of file CbmEnumKeySet.h.

◆ MaxKey()

template<auto... KeyList>
static constexpr Underlying_t cbm::util::EnumKeySet< KeyList >::MaxKey ( )
inlinestaticconstexpr

Returns maximal value of the keys.

Definition at line 59 of file CbmEnumKeySet.h.

Referenced by cbm::util::EnumKeySet< ESomeEnum::B, ESomeEnum::D, ESomeEnum::E >::MapperSize().

◆ MinKey()

◆ NofKeys()

template<auto... KeyList>
static constexpr size_t cbm::util::EnumKeySet< KeyList >::NofKeys ( )
inlinestaticconstexpr

Returns number of keys.

Definition at line 73 of file CbmEnumKeySet.h.

Member Data Documentation

◆ kKeys

template<auto... KeyList>
KeyContainer_t cbm::util::EnumKeySet< KeyList >::kKeys = InitializedKeysArray()
staticconstexpr

A list of keys (for loops)

Definition at line 110 of file CbmEnumKeySet.h.

◆ kMapper

template<auto... KeyList>
Container_t cbm::util::EnumKeySet< KeyList >::kMapper = InitializedMapper()
staticconstexprprivate

A mapping array of Enum_t -> index.

Definition at line 106 of file CbmEnumKeySet.h.


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