UTIL::BitField64 Class Reference

A bit field of 64bits that allows convenient declaration and manipulation of sub fields of various widths. More...

#include <UTIL/BitField64.h>

Inheritance diagram for UTIL::BitField64:
UTIL::CellIDEncoder< T > UTIL::ILDCellIDEncoder< T >

List of all members.

Public Types

typedef std::map< std::string,
unsigned int > 
IndexMap

Public Member Functions

 BitField64 (const std::string &initString)
 The c'tor takes an initialization string of the form:
<fieldDesc>[,<fieldDesc>.
lcio::long64 getValue () const
 Returns the current 64bit value.
void setValue (lcio::long64 value)
 Set a new 64bit value.
void reset ()
 Reset - same as setValue(0) - useful if the same encoder is used for many objects.
BitFieldValueoperator[] (size_t theIndex)
 Acces to field through index.
const BitFieldValueoperator[] (size_t theIndex) const
 Const acces to field through index.
unsigned highestBit () const
 Highest bit used in fields [0-63].
size_t size () const
 Number of values.
size_t index (const std::string &name) const
 Index for field named 'name'.
BitFieldValueoperator[] (const std::string &name)
 Access to field through name .
const BitFieldValueoperator[] (const std::string &name) const
 Const Access to field through name .
unsigned lowWord () const
 The low word, bits 0-31.
unsigned highWord () const
 The high word, bits 32-63.
std::string fieldDescription () const
 Return a valid description string of all fields.
std::string valueString () const
 Return a string with a comma separated list of the current sub field values.

Protected Member Functions

void addField (const std::string &name, unsigned offset, int width)
 Add an additional field to the list.
void init (const std::string &initString)
 Decode the initialization string as described in the constructor.
 BitField64 ()
 No default c'tor.

Protected Attributes

lcio::long64 _value
lcio::long64 _joined

Friends

std::ostream & operator<< (std::ostream &os, const BitField64 &b)

Detailed Description

A bit field of 64bits that allows convenient declaration and manipulation of sub fields of various widths.


Example:
BitField64 b("layer:7,system:-3,barrel:3,theta:32:11,phi:11" ) ;
b[ "layer" ] = 123 ;
b[ "system" ] = -4 ;
b[ "barrel" ] = 7 ;
b[ "theta" ] = 180 ;
b[ "phi" ] = 270 ;
...
int theta = b["theta"] ;
...
unsigned phiIndex = b.index(phi) ;
int phi = b[ phiIndex ] ;


Constructor & Destructor Documentation

UTIL::BitField64::BitField64 ( const std::string &  initString  )  [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"


Member Function Documentation

void UTIL::BitField64::init ( const std::string &  initString  )  [protected]

Decode the initialization string as described in the constructor.

See also:
BitField64( const std::string& initString )

References addField().


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Friends

Generated on 6 Mar 2020 for LCIO by  doxygen 1.6.1