libUTL++
utl::FlagsMI Class Reference

Mix-in to provide 64-bits for space-efficient storage of up to 64 boolean flags. More...

#include <FlagsMI.h>

Inheritance diagram for utl::FlagsMI:

Public Member Functions

 FlagsMI ()
 Constructor. More...
 
virtual ~FlagsMI ()
 Destructor. More...
 
void copyFlags (const FlagsMI &rhs)
 Copy the given flags. More...
 
void copyFlags (const FlagsMI &rhs, uint_t lsb, uint_t msb)
 Copy (some of) the given flags. More...
 
void copyFlags (uint64_t flags, uint_t lsb, uint_t msb)
 Copy (some of) the given flags. More...
 
bool getFlag (uint_t flagNum) const
 Get a user-defined flag. More...
 
void setFlag (uint_t flagNum, bool val)
 Set a user-defined flag. More...
 
uint64_t getFlagsNumber (uint64_t mask, uint64_t shift=0)
 Get a multi-bit value in the flags data (which is stored as one 64-bit integer). More...
 
void setFlagsNumber (uint64_t mask, uint64_t shift, uint64_t num)
 Set a multi-bit value in the flags data (which is stored as one 64-bit integer). More...
 
uint64_t getFlags () const
 Get the flags. More...
 
void setFlags (uint64_t flags)
 Set the flags. More...
 

Detailed Description

Mix-in to provide 64-bits for space-efficient storage of up to 64 boolean flags.

You can also use some of the bits to store multi-bit patterns if you wish.

Author
Adam McKee

Definition at line 25 of file FlagsMI.h.

Constructor & Destructor Documentation

◆ FlagsMI()

utl::FlagsMI::FlagsMI ( )
inline

Constructor.

Definition at line 29 of file FlagsMI.h.

◆ ~FlagsMI()

virtual utl::FlagsMI::~FlagsMI ( )
inlinevirtual

Destructor.

Definition at line 35 of file FlagsMI.h.

Member Function Documentation

◆ copyFlags() [1/3]

void utl::FlagsMI::copyFlags ( const FlagsMI rhs)
inline

Copy the given flags.

Definition at line 41 of file FlagsMI.h.

◆ copyFlags() [2/3]

void utl::FlagsMI::copyFlags ( const FlagsMI rhs,
uint_t  lsb,
uint_t  msb 
)
inline

Copy (some of) the given flags.

Parameters
rhsright-hand-side flags
lsbleast significant bit (0-63)
msbmost significant bit (0-63)

Definition at line 53 of file FlagsMI.h.

◆ copyFlags() [3/3]

void utl::FlagsMI::copyFlags ( uint64_t  flags,
uint_t  lsb,
uint_t  msb 
)
inline

Copy (some of) the given flags.

Parameters
flagsright-hand-side flags
lsbleast significant bit (0-63)
msbmost significant bit (0-63)

Definition at line 65 of file FlagsMI.h.

References ASSERTD, utl::serialize(), and utl::uint64_t_max.

◆ getFlag()

bool utl::FlagsMI::getFlag ( uint_t  flagNum) const
inline

Get a user-defined flag.

Returns
requested flag (bool)
Parameters
flagNumflag # (0 <= flagNum <= 63)

Definition at line 90 of file FlagsMI.h.

References ASSERTD.

Referenced by utl::FlagGuard::FlagGuard().

◆ setFlag()

void utl::FlagsMI::setFlag ( uint_t  flagNum,
bool  val 
)
inline

Set a user-defined flag.

Parameters
flagNumflag # (0 <= flagNum <= 63)
valnew flag value

Definition at line 103 of file FlagsMI.h.

References ASSERTD.

◆ getFlagsNumber()

uint64_t utl::FlagsMI::getFlagsNumber ( uint64_t  mask,
uint64_t  shift = 0 
)
inline

Get a multi-bit value in the flags data (which is stored as one 64-bit integer).

Return the bitwise AND of the flags with the given 64-bit integer.

Parameters
maskbitmask (e.g. 0x3 for a two-bit number using the two least-significant bits)
shiftthe least-significant bit in the number (e.g. 0 if using the two lowest bits)

Definition at line 120 of file FlagsMI.h.

◆ setFlagsNumber()

void utl::FlagsMI::setFlagsNumber ( uint64_t  mask,
uint64_t  shift,
uint64_t  num 
)
inline

Set a multi-bit value in the flags data (which is stored as one 64-bit integer).

Parameters
maskbitmask (e.g. 0x3 for a two-bit number using the two least-significant bits)
shiftthe least-significant bit in the number (e.g. 0 if using the two lowest bits)
numthe number to set in the identified portion of the flags data

Definition at line 132 of file FlagsMI.h.

◆ getFlags()

uint64_t utl::FlagsMI::getFlags ( ) const
inline

Get the flags.

Definition at line 140 of file FlagsMI.h.

◆ setFlags()

void utl::FlagsMI::setFlags ( uint64_t  flags)
inline

Set the flags.

Definition at line 147 of file FlagsMI.h.


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