CbmRoot
Loading...
Searching...
No Matches
cbm::util::EnumMap< T, KeySet, Base > Class Template Reference

A class to define a statical mapper over some type. More...

#include <CbmEnumMap.h>

Inheritance diagram for cbm::util::EnumMap< T, KeySet, Base >:
[legend]
Collaboration diagram for cbm::util::EnumMap< T, KeySet, Base >:
[legend]

Public Types

using Base_t = Base
 
using KeySet_t = KeySet
 
using Value_t = T
 
using Key_t = typename KeySet::Key_t
 

Public Member Functions

constexpr EnumMap ()
 Default constructor.
 
constexpr EnumMap (std::initializer_list< std::pair< Key_t, Value_t > > init)
 Constructor from initializer list.
 
constexpr T & operator[] (Key_t key)
 Mutable access operator.
 
constexpr const T & operator[] (Key_t key) const
 Constant access operator.
 
constexpr const T & operator[] (size_t index) const
 Constant access operator.
 
constexpr T & at (Key_t key)
 Mutable access with bounds checking.
 
constexpr const T & at (Key_t key) const
 Constant access with bounds checking.
 
constexpr bool CheckKey (Key_t key) const
 Checks, if the key is provided in the key set.
 
template<Key_t key>
constexpr bool CheckKey () const
 Checks, if the key is provided in the key set.
 

Private Member Functions

template<typename Archive>
void serialize (Archive &ar, const unsigned int)
 

Friends

class boost::serialization::access
 

Detailed Description

template<class T, class KeySet, class Base = std::array<T, KeySet::NofKeys()>>
class cbm::util::EnumMap< T, KeySet, Base >

A class to define a statical mapper over some type.

Template Parameters
TType of values, stored in the map
KeySetThe enumeration key set type
BaseThe base container (should define the same methods as std::array) A particular mapper class has to define the following methods and types: Key_t A type of the key constexpr Index(Key_t) A function to map a Key_t on the contigious index fi constexpr NofKeys() Number of keys

Definition at line 31 of file CbmEnumMap.h.

Member Typedef Documentation

◆ Base_t

template<class T, class KeySet, class Base = std::array<T, KeySet::NofKeys()>>
using cbm::util::EnumMap< T, KeySet, Base >::Base_t = Base

Definition at line 33 of file CbmEnumMap.h.

◆ Key_t

template<class T, class KeySet, class Base = std::array<T, KeySet::NofKeys()>>
using cbm::util::EnumMap< T, KeySet, Base >::Key_t = typename KeySet::Key_t

Definition at line 36 of file CbmEnumMap.h.

◆ KeySet_t

template<class T, class KeySet, class Base = std::array<T, KeySet::NofKeys()>>
using cbm::util::EnumMap< T, KeySet, Base >::KeySet_t = KeySet

Definition at line 34 of file CbmEnumMap.h.

◆ Value_t

template<class T, class KeySet, class Base = std::array<T, KeySet::NofKeys()>>
using cbm::util::EnumMap< T, KeySet, Base >::Value_t = T

Definition at line 35 of file CbmEnumMap.h.

Constructor & Destructor Documentation

◆ EnumMap() [1/2]

template<class T, class KeySet, class Base = std::array<T, KeySet::NofKeys()>>
cbm::util::EnumMap< T, KeySet, Base >::EnumMap ( )
inlineconstexpr

Default constructor.

Note
Provides default initialization of elements with T()

Definition at line 41 of file CbmEnumMap.h.

◆ EnumMap() [2/2]

template<class T, class KeySet, class Base = std::array<T, KeySet::NofKeys()>>
cbm::util::EnumMap< T, KeySet, Base >::EnumMap ( std::initializer_list< std::pair< Key_t, Value_t > > init)
inlineconstexpr

Constructor from initializer list.

Parameters
initThe initializer list

Definition at line 45 of file CbmEnumMap.h.

Member Function Documentation

◆ at() [1/2]

template<class T, class KeySet, class Base = std::array<T, KeySet::NofKeys()>>
T & cbm::util::EnumMap< T, KeySet, Base >::at ( Key_t key)
inlineconstexpr

Mutable access with bounds checking.

Parameters
keyA key

Definition at line 72 of file CbmEnumMap.h.

◆ at() [2/2]

template<class T, class KeySet, class Base = std::array<T, KeySet::NofKeys()>>
const T & cbm::util::EnumMap< T, KeySet, Base >::at ( Key_t key) const
inlineconstexpr

Constant access with bounds checking.

Parameters
keyA key

Definition at line 82 of file CbmEnumMap.h.

◆ CheckKey() [1/2]

template<class T, class KeySet, class Base = std::array<T, KeySet::NofKeys()>>
template<Key_t key>
bool cbm::util::EnumMap< T, KeySet, Base >::CheckKey ( ) const
inlineconstexpr

Checks, if the key is provided in the key set.

Template Parameters
keyA key
Note
Guaranties a consteval

Definition at line 98 of file CbmEnumMap.h.

◆ CheckKey() [2/2]

template<class T, class KeySet, class Base = std::array<T, KeySet::NofKeys()>>
bool cbm::util::EnumMap< T, KeySet, Base >::CheckKey ( Key_t key) const
inlineconstexpr

Checks, if the key is provided in the key set.

Parameters
keyA key

Definition at line 92 of file CbmEnumMap.h.

◆ operator[]() [1/3]

template<class T, class KeySet, class Base = std::array<T, KeySet::NofKeys()>>
T & cbm::util::EnumMap< T, KeySet, Base >::operator[] ( Key_t key)
inlineconstexpr

Mutable access operator.

Parameters
keyA key

Definition at line 59 of file CbmEnumMap.h.

Referenced by cbm::util::EnumMap< T, SomeKeySet_t >::at(), and cbm::util::EnumMap< T, SomeKeySet_t >::at().

◆ operator[]() [2/3]

template<class T, class KeySet, class Base = std::array<T, KeySet::NofKeys()>>
const T & cbm::util::EnumMap< T, KeySet, Base >::operator[] ( Key_t key) const
inlineconstexpr

Constant access operator.

Parameters
keyA key

Definition at line 63 of file CbmEnumMap.h.

◆ operator[]() [3/3]

template<class T, class KeySet, class Base = std::array<T, KeySet::NofKeys()>>
const T & cbm::util::EnumMap< T, KeySet, Base >::operator[] ( size_t index) const
inlineconstexpr

Constant access operator.

Parameters
indexAn integral index
Note
To be used for iterations

Definition at line 68 of file CbmEnumMap.h.

◆ serialize()

template<class T, class KeySet, class Base = std::array<T, KeySet::NofKeys()>>
template<typename Archive>
void cbm::util::EnumMap< T, KeySet, Base >::serialize ( Archive & ar,
const unsigned int  )
inlineprivate

Definition at line 120 of file CbmEnumMap.h.

Friends And Related Symbol Documentation

◆ boost::serialization::access

template<class T, class KeySet, class Base = std::array<T, KeySet::NofKeys()>>
friend class boost::serialization::access
friend

Definition at line 118 of file CbmEnumMap.h.


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