Helper class for decoding and encoding a bit field of 64bits for convenient declaration. More...
#include <BitFieldCoder.h>
Public Types | |
typedef std::map< std::string, unsigned int > | IndexMap |
Public Member Functions | |
BitFieldCoder ()=default | |
Default constructor. More... | |
BitFieldCoder (const BitFieldCoder &)=default | |
Copy constructor. More... | |
BitFieldCoder (BitFieldCoder &&)=default | |
Move constructor. More... | |
~BitFieldCoder ()=default | |
Default destructor. More... | |
BitFieldCoder & | operator= (const BitFieldCoder &)=default |
Assignment operator. More... | |
BitFieldCoder (const std::string &initString) | |
long64 | get (long64 bitfield, size_t index) const |
long64 | get (long64 bitfield, const std::string &name) const |
void | set (long64 &bitfield, size_t index, ulong64 value) const |
void | set (long64 &bitfield, const std::string &name, ulong64 value) const |
unsigned | highestBit () const |
size_t | size () const |
size_t | index (const std::string &name) const |
const BitFieldValue & | operator[] (const std::string &name) const |
const BitFieldValue & | operator[] (unsigned index) const |
std::string | fieldDescription () const |
std::string | valueString (ulong64 bitfield) const |
const std::vector< BitFieldValue > & | fields () const |
ulong64 | mask () const |
Static Public Member Functions | |
static long64 | toLong (unsigned low_Word, unsigned high_Word) |
static unsigned | lowWord (long64 bitfield) |
static unsigned | highWord (long64 bitfield) |
Protected Member Functions | |
void | addField (const std::string &name, unsigned offset, int width) |
void | init (const std::string &initString) |
Protected Attributes | |
std::vector< BitFieldValue > | _fields {} |
IndexMap | _map {} |
long64 | _joined {} |
Helper class for decoding and encoding a bit field of 64bits for convenient declaration.
and manipulation of sub fields of various widths.
This is a thread safe re-implementation of the functionality in the deprected BitField64.
Example:
BitFieldCoder bc("layer:7,system:-3,barrel:3,theta:32:11,phi:11" ) ;
bc.set( field, "layer" , 123 );
bc.set( field, "system" , -4 );
bc.set( field, "barrel" , 7 );
bc.set( field, "theta" , 180 );
bc.set( field, "phi" , 270 );
...
int theta = bc.get( field, "theta" ) ;
...
unsigned phiIndex = bc.index("phi") ;
int phi = bc.get( field, phiIndex ) ;
Definition at line 130 of file BitFieldCoder.h.
typedef std::map<std::string, unsigned int> gar::geo::BitFieldCoder::IndexMap |
Definition at line 134 of file BitFieldCoder.h.
|
default |
Default constructor.
|
default |
Copy constructor.
|
default |
Move constructor.
|
default |
Default destructor.
|
inline |
The c'tor takes an initialization string of the form:
<fieldDesc>[,<fieldDesc>...]
fieldDesc = name:[start]:[-]length
where:
name: The name of the field
start: The start bit of the field. If omitted assumed to start immediately following previous field, or at the least significant bit if the first field.
length: The number of bits in the field. If preceeded by '-' the field is signed, otherwise unsigned.
Bit numbering is from the least significant bit (bit 0) to the most significant (bit 63).
Example: "layer:7,system:-3,barrel:3,theta:32:11,phi:11"
Definition at line 162 of file BitFieldCoder.h.
|
protected |
std::string gar::geo::BitFieldCoder::fieldDescription | ( | ) | const |
|
inline |
Definition at line 223 of file BitFieldCoder.h.
get value of sub-field specified by index
Definition at line 181 of file BitFieldCoder.h.
|
inline |
Access to field through name .
Definition at line 185 of file BitFieldCoder.h.
unsigned gar::geo::BitFieldCoder::highestBit | ( | ) | const |
|
inlinestatic |
The high word, bits 32-63
Definition at line 177 of file BitFieldCoder.h.
size_t gar::geo::BitFieldCoder::index | ( | const std::string & | name | ) | const |
|
protected |
Decode the initialization string as described in the constructor.
Definition at line 165 of file BitFieldCoder.cxx.
|
inlinestatic |
The low word, bits 0-31
Definition at line 173 of file BitFieldCoder.h.
|
inline |
|
default |
Assignment operator.
|
inline |
Const Access to field through name .
Definition at line 209 of file BitFieldCoder.h.
|
inline |
Const Access to field through index .
Definition at line 213 of file BitFieldCoder.h.
set value of sub-field specified by index
Definition at line 189 of file BitFieldCoder.h.
|
inline |
Access to field through name .
Definition at line 193 of file BitFieldCoder.h.
|
inline |
|
inlinestatic |
return a new 64bit value given as high and low 32bit words.
Definition at line 169 of file BitFieldCoder.h.
std::string gar::geo::BitFieldCoder::valueString | ( | ulong64 | bitfield | ) | const |
Return a string with a comma separated list of the current sub field values
Definition at line 104 of file BitFieldCoder.cxx.
|
protected |
Definition at line 243 of file BitFieldCoder.h.
|
protected |
Definition at line 245 of file BitFieldCoder.h.
|
protected |
Definition at line 244 of file BitFieldCoder.h.