LCIO  02.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
UTIL::BitField64 Class Reference

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

#include <BitField64.h>

+ Inheritance diagram for UTIL::BitField64:

Public Types

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

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

std::vector< BitFieldValue * > _fields {}
 
lcio::long64 _value
 
IndexMap _map {}
 
lcio::long64 _joined
 

Friends

std::ostreamoperator<< (std::ostream &os, const BitField64 &b)
 Operator for dumping BitField64 to streams. More...
 

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 ] ;

Definition at line 132 of file BitField64.h.

Member Typedef Documentation

Definition at line 138 of file BitField64.h.

Constructor & Destructor Documentation

UTIL::BitField64::~BitField64 ( )
inline

Definition at line 141 of file BitField64.h.

References _fields.

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"

Definition at line 161 of file BitField64.h.

References init().

UTIL::BitField64::BitField64 ( )
inlineprotected

No default c'tor.

Definition at line 244 of file BitField64.h.

Member Function Documentation

void UTIL::BitField64::addField ( const std::string name,
unsigned  offset,
int  width 
)
protected

Add an additional field to the list.

Definition at line 172 of file BitField64.cc.

References _fields, _joined, _map, _value, std::hex(), UTIL::BitFieldValue::mask(), and std::stringstream::str().

Referenced by init().

std::string UTIL::BitField64::fieldDescription ( ) const

Return a valid description string of all fields.

Definition at line 136 of file BitField64.cc.

References _fields, and std::stringstream::str().

lcio::long64 UTIL::BitField64::getValue ( ) const
inline

Returns the current 64bit value.

Definition at line 168 of file BitField64.h.

References _value.

unsigned UTIL::BitField64::highestBit ( ) const

Highest bit used in fields [0-63].

Definition at line 109 of file BitField64.cc.

References _fields.

Referenced by UTIL::CellIDEncoder< T >::setCellIDFlag().

unsigned UTIL::BitField64::highWord ( ) const
inline

The high word, bits 32-63.

Definition at line 221 of file BitField64.h.

References _value.

Referenced by UTIL::CellIDEncoder< T >::setCellID().

size_t UTIL::BitField64::index ( const std::string name) const

Index for field named 'name'.

Definition at line 97 of file BitField64.cc.

References _map, std::map< K, T >::end(), and std::map< K, T >::find().

Referenced by operator[]().

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 )

Definition at line 195 of file BitField64.cc.

References addField(), std::string::begin(), std::string::end(), std::for_each(), std::vector< T >::size(), and std::stringstream::str().

Referenced by BitField64().

unsigned UTIL::BitField64::lowWord ( ) const
inline

The low word, bits 0-31.

Definition at line 217 of file BitField64.h.

References _value.

Referenced by UTIL::CellIDEncoder< T >::setCellID().

BitFieldValue& UTIL::BitField64::operator[] ( size_t  theIndex)
inline

Acces to field through index.

Definition at line 180 of file BitField64.h.

References _fields.

const BitFieldValue& UTIL::BitField64::operator[] ( size_t  theIndex) const
inline

Const acces to field through index.

Definition at line 186 of file BitField64.h.

References _fields.

BitFieldValue& UTIL::BitField64::operator[] ( const std::string name)
inline

Access to field through name .

Definition at line 203 of file BitField64.h.

References _fields, and index().

const BitFieldValue& UTIL::BitField64::operator[] ( const std::string name) const
inline

Const Access to field through name .

Definition at line 209 of file BitField64.h.

References _fields, and index().

void UTIL::BitField64::reset ( )
inline

Reset - same as setValue(0) - useful if the same encoder is used for many objects.

Definition at line 176 of file BitField64.h.

References _value.

void UTIL::BitField64::setValue ( lcio::long64  value)
inline

Set a new 64bit value.

Definition at line 172 of file BitField64.h.

References _value.

Referenced by UTIL::CellIDDecoder< T >::operator()(), and UTIL::LCTrackerCellID::valueString().

size_t UTIL::BitField64::size ( ) const
inline

Number of values.

Definition at line 195 of file BitField64.h.

References _fields.

std::string UTIL::BitField64::valueString ( ) const

Return a string with a comma separated list of the current sub field values.

Definition at line 122 of file BitField64.cc.

References _fields, and std::stringstream::str().

Referenced by UTIL::LCTrackerCellID::valueString().

Friends And Related Function Documentation

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

Operator for dumping BitField64 to streams.

Member Data Documentation

std::vector<BitFieldValue*> UTIL::BitField64::_fields {}
protected
lcio::long64 UTIL::BitField64::_joined
protected

Definition at line 252 of file BitField64.h.

Referenced by addField().

IndexMap UTIL::BitField64::_map {}
protected

Definition at line 251 of file BitField64.h.

Referenced by addField(), index(), and UTIL::operator<<().

lcio::long64 UTIL::BitField64::_value
protected

Definition at line 250 of file BitField64.h.

Referenced by addField(), getValue(), highWord(), lowWord(), UTIL::operator<<(), reset(), and setValue().


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