6 using namespace EVENT ;
12 unsigned theOffset,
int signedWidth ) :
17 _width( abs( signedWidth ) ),
20 _isSigned( signedWidth < 0 ) {
26 s <<
" BitFieldValue '" <<
_name <<
"': out of range - offset : "
62 if( ( val & ( 1LL << (
_width - 1 ) ) ) != 0 ) {
78 if( in < _minVal || in >
_maxVal ) {
81 s <<
" BitFieldValue '" <<
_name <<
"': out of range : " << in
82 <<
" for width " <<
_width ;
99 IndexMap::const_iterator it =
_map.
find( name ) ;
106 throw Exception(
" BitFieldValue: unknown name: " + name ) ;
113 for(
unsigned i=0;i<
_fields.size();i++){
126 for(
unsigned i=0;i<
_fields.size();i++){
128 if( i != 0 ) os <<
"," ;
140 for(
unsigned i=0;i<
_fields.size();i++){
142 if( i != 0 ) os <<
"," ;
144 os <<
_fields[i]->name() <<
":"
145 <<
_fields[i]->offset() <<
":" ;
184 s <<
" BitFieldValue::addField(" << name <<
"): bits already used " <<
std::hex <<
_joined
185 <<
" for mask " << bfv->
mask() ;
197 unsigned offset = 0 ;
205 for(
unsigned i=0; i< fieldDescriptors.
size() ; i++ ){
210 std::for_each( fieldDescriptors[i].begin(), fieldDescriptors[i].end(), ts );
214 unsigned thisOffset ;
216 switch( subfields.
size() ){
220 name = subfields[0] ;
221 width = atol( subfields[1].c_str() ) ;
222 thisOffset = offset ;
224 offset += abs( width ) ;
229 name = subfields[0] ;
230 thisOffset = atol( subfields[1].c_str() ) ;
231 width = atol( subfields[2].c_str() ) ;
233 offset = thisOffset + abs( width ) ;
240 s <<
" BitField64: invalid number of subfields "
241 << fieldDescriptors[i] ;
246 addField( name , thisOffset, width ) ;
256 for( BitField64::IndexMap::const_iterator it = b.
_map.begin() ;
257 it != b.
_map.end() ; ++it ){
259 os <<
" " << it->first <<
" [" << b[ it->second ].offset() <<
":" ;
261 if( b[ it->second ].isSigned() ) os <<
"-" ;
263 os << b[ it->second ].width() <<
"] : " ;
266 os << b[ it->second ].value()
Base exception class for LCIO - all other exceptions extend this.
BitFieldValue & operator=(lcio::long64 in)
Assignment operator for user convenience.
unsigned highestBit() const
Highest bit used in fields [0-63].
std::ostream & operator<<(std::ostream &os, const BitField64 &b)
Operator for dumping BitField64 to streams.
std::vector< BitFieldValue * > _fields
std::string fieldDescription() const
Return a valid description string of all fields.
size_t index(const std::string &name) const
Index for field named 'name'.
A bit field of 64bits that allows convenient declaration and manipulation of sub fields of various wi...
Helper class for BitField64 that corresponds to one field value.
lcio::ulong64 mask() const
The field's mask.
std::string valueString() const
Return a string with a comma separated list of the current sub field values.
long long long64
64 bit signed integer,e.g.to be used for timestamps
lcio::long64 value() const
Returns the current field value.
void addField(const std::string &name, unsigned offset, int width)
Add an additional field to the list.
Helper class for string tokenization.
void init(const std::string &initString)
Decode the initialization string as described in the constructor.