Belle II Software development
ModuleID_t Class Reference

The ModuleID_t class is a intermediate object generated to contain configurations in a sorted fashion. More...

#include <ARICHDatabaseTools.h>

Public Member Functions

 ModuleID_t (const int8_t sector='0', const int channel=0) noexcept
 ModuleID_t is the default ctor that construct an id out of a sector id and channel number.
 
 ModuleID_t (const uint16_t id) noexcept
 ModuleID_t used to construct from a given integer that has a valid module ID.
 
auto isValidID () const noexcept -> bool
 isValidID check is constructed id is valid
 
auto getSector () const noexcept -> int8_t
 getSector returns the definded sectors.
 
auto getChannel () const noexcept -> int8_t
 getChannel return the defined channel
 
auto getNumbering () const noexcept -> int
 getNumbering returns the channel number Ax = 1+x; Bx = 36 + x; Cx = 72 + x; Dx = 108 + x; Note: an invalid id return an invalid number!!!
 
auto operator== (const ModuleID_t &rOther) const noexcept -> bool
 comparison operator==
 
auto operator!= (const ModuleID_t &rOther) const noexcept -> bool
 comparison operator!=
 
auto operator< (const ModuleID_t &rOther) const noexcept -> bool
 comparison operator<
 
auto operator<= (const ModuleID_t &rOther) const noexcept -> bool
 comparison operator<=
 
auto operator> (const ModuleID_t &rOther) const noexcept -> bool
 comparison operator>
 
auto operator>= (const ModuleID_t &rOther) const noexcept -> bool
 comparison operator>=
 
auto operator++ () noexcept -> ModuleID_t &
 precrement operator ++X
 
auto operator++ (int) noexcept -> ModuleID_t
 postcrement operator X++
 

Static Public Member Functions

static constexpr auto isValidChannel (const int channel) noexcept -> bool
 isValidChannel defines the range of valid channels.
 
static auto isValidSector (const uint8_t sector) noexcept -> bool
 isValidSector checks whether a given sector is valid.
 

Static Public Attributes

static constexpr auto m_gValidSectors
 m_gValidSectors is a array containing allowed sector ids
 
static constexpr auto m_gMaxChannel = int8_t {36}
 m_gMaxChannel number of maximum channel starting from 0
 

Private Attributes

uint16_t m_ID
 m_ID contains the unique sector and channel ids.
 

Static Private Attributes

static constexpr auto m_gMemberSize = sizeof(int8_t) * 8
 m_gMemberSize size of each sub ids
 
static constexpr auto m_gMemberMask = 0xff
 m_gMemberMask is a mask to get the desired sub id info.
 

Friends

auto operator<< (std::ostream &rStream, const ModuleID_t id) -> std::ostream &
 operator << to print the id using any std::ostream implementation...
 

Detailed Description

The ModuleID_t class is a intermediate object generated to contain configurations in a sorted fashion.

Definition at line 30 of file ARICHDatabaseTools.h.

Constructor & Destructor Documentation

◆ ModuleID_t() [1/2]

ModuleID_t ( const int8_t  sector = '0',
const int  channel = 0 
)
inlinenoexcept

ModuleID_t is the default ctor that construct an id out of a sector id and channel number.

Parameters
sector
channel
See also
ModuleID_t::m_gValidSectors

Definition at line 73 of file ARICHDatabaseTools.h.

74 : m_ID((sector << m_gMemberSize) | channel) {}
static constexpr auto m_gMemberSize
m_gMemberSize size of each sub ids
uint16_t m_ID
m_ID contains the unique sector and channel ids.

◆ ModuleID_t() [2/2]

ModuleID_t ( const uint16_t  id)
inlineexplicitnoexcept

ModuleID_t used to construct from a given integer that has a valid module ID.

Note: An invalid ID causes an undefined behaviour!

Parameters
idis a valid module ID

Definition at line 81 of file ARICHDatabaseTools.h.

81: m_ID(id) {}

Member Function Documentation

◆ getChannel()

auto getChannel ( ) const -> int8_t
inlinenoexcept

getChannel return the defined channel

Returns
channel id/number
See also
ModuleID_t::isValidChannel()

Definition at line 108 of file ARICHDatabaseTools.h.

109 {
110 return (m_ID & m_gMemberMask);
111 }
static constexpr auto m_gMemberMask
m_gMemberMask is a mask to get the desired sub id info.

◆ getNumbering()

auto getNumbering ( ) const -> int
inlinenoexcept

getNumbering returns the channel number Ax = 1+x; Bx = 36 + x; Cx = 72 + x; Dx = 108 + x; Note: an invalid id return an invalid number!!!

Returns
channel number increamened by an offset determined by section ID.
See also
isValidID()

Definition at line 119 of file ARICHDatabaseTools.h.

120 {
121 return (this->getSector() - m_gValidSectors.front()) * m_gMaxChannel +
122 this->getChannel();
123 }
auto getSector() const noexcept -> int8_t
getSector returns the definded sectors.
static constexpr auto m_gMaxChannel
m_gMaxChannel number of maximum channel starting from 0
auto getChannel() const noexcept -> int8_t
getChannel return the defined channel
static constexpr auto m_gValidSectors
m_gValidSectors is a array containing allowed sector ids

◆ getSector()

auto getSector ( ) const -> int8_t
inlinenoexcept

getSector returns the definded sectors.

Returns
sector id
See also
ModuleID_t::m_gValidSectors

Definition at line 98 of file ARICHDatabaseTools.h.

99 {
100 return ((m_ID >> m_gMemberSize) & m_gMemberMask);
101 }

◆ isValidChannel()

static constexpr auto isValidChannel ( const int  channel) -> bool
inlinestaticconstexprnoexcept

isValidChannel defines the range of valid channels.

Parameters
channelchannel
Returns
true if channel id/number is in the valid range otherwise false.

Definition at line 49 of file ARICHDatabaseTools.h.

50 {
51 return (channel >= 0) && (channel <= m_gMaxChannel);
52 }

◆ isValidID()

auto isValidID ( ) const -> bool
inlinenoexcept

isValidID check is constructed id is valid

Returns
true if this ModuleID_t is valid, otherwise false.

Definition at line 87 of file ARICHDatabaseTools.h.

88 {
89 return ModuleID_t::isValidSector(this->getSector()) &&
91 }
static constexpr auto isValidChannel(const int channel) noexcept -> bool
isValidChannel defines the range of valid channels.
static auto isValidSector(const uint8_t sector) noexcept -> bool
isValidSector checks whether a given sector is valid.

◆ isValidSector()

static auto isValidSector ( const uint8_t  sector) -> bool
inlinestaticnoexcept

isValidSector checks whether a given sector is valid.

Parameters
sectorsector to be checked
Returns
true if sector id/number is in the valid range otherwise false.

Definition at line 59 of file ARICHDatabaseTools.h.

60 {
61 return std::find(m_gValidSectors.begin(), m_gValidSectors.end(), sector) !=
62 m_gValidSectors.end();
63 }

◆ operator!=()

auto operator!= ( const ModuleID_t rOther) const -> bool
inlinenoexcept

comparison operator!=

Note
if using c++17 replace thi one with <=> operator

Definition at line 150 of file ARICHDatabaseTools.h.

151 {
152 return m_ID != rOther.m_ID;
153 }

◆ operator++() [1/2]

auto operator++ ( ) -> ModuleID_t&
inlinenoexcept

precrement operator ++X

Note
does not check the module range!!! overflow is allowed!!!

Definition at line 195 of file ARICHDatabaseTools.h.

196 {
197 m_ID = this->getChannel() >= m_gMaxChannel
198 ? (((this->getSector() + 1) << m_gMemberSize) | 1)
199 : m_ID + 1;
200 return *this;
201 }

◆ operator++() [2/2]

auto operator++ ( int  ) -> ModuleID_t
inlinenoexcept

postcrement operator X++

Note
does not check the module range!!! overflow is allowed!!!

Definition at line 207 of file ARICHDatabaseTools.h.

208 {
209 auto tmp = ModuleID_t(m_ID);
210 this->operator++();
211 return tmp;
212 }
ModuleID_t(const int8_t sector='0', const int channel=0) noexcept
ModuleID_t is the default ctor that construct an id out of a sector id and channel number.
auto operator++() noexcept -> ModuleID_t &
precrement operator ++X

◆ operator<()

auto operator< ( const ModuleID_t rOther) const -> bool
inlinenoexcept

comparison operator<

Note
if using c++17 replace thi one with <=> operator

Definition at line 159 of file ARICHDatabaseTools.h.

160 {
161 return m_ID < rOther.m_ID;
162 }

◆ operator<=()

auto operator<= ( const ModuleID_t rOther) const -> bool
inlinenoexcept

comparison operator<=

Note
if using c++17 replace thi one with <=> operator

Definition at line 168 of file ARICHDatabaseTools.h.

169 {
170 return m_ID <= rOther.m_ID;
171 }

◆ operator==()

auto operator== ( const ModuleID_t rOther) const -> bool
inlinenoexcept

comparison operator==

Note
if using c++17 replace thi one with <=> operator

Definition at line 141 of file ARICHDatabaseTools.h.

142 {
143 return m_ID == rOther.m_ID;
144 }

◆ operator>()

auto operator> ( const ModuleID_t rOther) const -> bool
inlinenoexcept

comparison operator>

Note
if using c++17 replace thi one with <=> operator

Definition at line 177 of file ARICHDatabaseTools.h.

178 {
179 return m_ID > rOther.m_ID;
180 }

◆ operator>=()

auto operator>= ( const ModuleID_t rOther) const -> bool
inlinenoexcept

comparison operator>=

Note
if using c++17 replace thi one with <=> operator

Definition at line 186 of file ARICHDatabaseTools.h.

187 {
188 return m_ID >= rOther.m_ID;
189 }

Friends And Related Function Documentation

◆ operator<<

auto operator<< ( std::ostream &  rStream,
const ModuleID_t  id 
) -> std::ostream&
friend

operator << to print the id using any std::ostream implementation...

Parameters
rStream
id

Definition at line 130 of file ARICHDatabaseTools.h.

132 {
133 rStream << id.getSector() << static_cast<int>(id.getChannel());
134 return rStream;
135 }

Member Data Documentation

◆ m_gMaxChannel

constexpr auto m_gMaxChannel = int8_t {36}
staticconstexpr

m_gMaxChannel number of maximum channel starting from 0

Definition at line 42 of file ARICHDatabaseTools.h.

◆ m_gMemberMask

constexpr auto m_gMemberMask = 0xff
staticconstexprprivate

m_gMemberMask is a mask to get the desired sub id info.

Definition at line 222 of file ARICHDatabaseTools.h.

◆ m_gMemberSize

constexpr auto m_gMemberSize = sizeof(int8_t) * 8
staticconstexprprivate

m_gMemberSize size of each sub ids

Definition at line 218 of file ARICHDatabaseTools.h.

◆ m_gValidSectors

constexpr std::array< uint8_t, 4 > m_gValidSectors
staticconstexpr
Initial value:
=
std::array<uint8_t, 4>( {{'A', 'B', 'C', 'D'}})

m_gValidSectors is a array containing allowed sector ids

Definition at line 36 of file ARICHDatabaseTools.h.

◆ m_ID

uint16_t m_ID
private

m_ID contains the unique sector and channel ids.

Definition at line 227 of file ARICHDatabaseTools.h.


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