ATLAS Offline Software
Loading...
Searching...
No Matches
IdDictFieldImplementation Class Reference

IdDictFieldImplementation is used to capture the specification of a single field of an Identifier. More...

#include <IdDictFieldImplementation.h>

Collaboration diagram for IdDictFieldImplementation:

Public Types

enum  bit_defs { NBITS = sizeof(value_type) * 8 , MAX_BIT = (static_cast<value_type>(1) << (NBITS - 1)) , ALL_BITS = ~(static_cast<value_type>(0)) }
typedef Identifier::value_type value_type
typedef Identifier::size_type size_type

Public Member Functions

 IdDictFieldImplementation ()
int unpack (Identifier id) const
 Identifier manipulation methods.
size_type unpackToIndex (Identifier id) const
 Unpack a single field index of the id.
void pack (int value, Identifier &id) const
Identifier new_pack (int value) const
void reset (Identifier &id) const
const IdDictRangerange () const
 Accessors.
const Range::fieldfield () const
const Range::fieldored_field () const
size_type bits () const
size_type bits_offset () const
size_type mask () const
value_type zeroing_mask () const
size_type shift () const
bool decode_index () const
void set_range (const IdDictRange *range)
 Modifiers.
void set_field (const Range::field &field)
void set_ored_field (const Range::field &ored_field)
void set_bits_offset (size_type bits_offset)
void set_bits (size_type bits, size_type bits_offset)
void set_decode_index (bool decode_index)
void optimize (void)
void show (void) const
std::string show_to_string (void) const

Private Member Functions

void initialize ()

Private Attributes

const IdDictRangem_range
Range::field m_field
Range::field m_ored_field
size_type m_bits
size_type m_bits_offset
size_type m_mask
value_type m_zeroing_mask
size_type m_shift
bool m_decode_index

Detailed Description

IdDictFieldImplementation is used to capture the specification of a single field of an Identifier.

This class is primarily used to extract or set the field of an identifier:

int unpack (Identifier id) const; // access to field value size_type unpackToIndex (Identifier id) const; // access to field index, i.e. from 0 void pack (int value, Identifier& id) const; void reset (Identifier& id) const; // reset field bits

This class is normally filled during the parsing of the identifier dictionary. The parsing uses the set_ored_field method where the the internal variables are set to optimize the calculations. One may also build a new object by simply using:

void set_bits (size_type bits, size_type bits_offset);

This as well sets all internal variables.

The meaning of the varibles is:

size_type bits() - number of bits for this field size_type bits_offset() - bits offset relative to 1st field size_type mask() - mask: (xxx >> shift) & mask value_type zeroing_mask() - used to reset field to 0 size_type shift() - shift: (xxx >> shift) & mask bool decode_index() - true == need to lookup value

// Primarily for internal use: const IdDictRange* range() - points to the generating IdDictRange Range::field field() - derived from IdDictRange Range::field ored_field() - "expanded" field to account for other overlapping fields

Definition at line 58 of file IdDictFieldImplementation.h.

Member Typedef Documentation

◆ size_type

typedef Identifier::size_type IdDictFieldImplementation::size_type

Definition at line 63 of file IdDictFieldImplementation.h.

◆ value_type

typedef Identifier::value_type IdDictFieldImplementation::value_type

Definition at line 62 of file IdDictFieldImplementation.h.

Member Enumeration Documentation

◆ bit_defs

Enumerator
NBITS 
MAX_BIT 
ALL_BITS 

Definition at line 65 of file IdDictFieldImplementation.h.

Constructor & Destructor Documentation

◆ IdDictFieldImplementation()

IdDictFieldImplementation::IdDictFieldImplementation ( )
inline

Member Function Documentation

◆ bits()

IdDictFieldImplementation::size_type IdDictFieldImplementation::bits ( ) const
inline

Definition at line 218 of file IdDictFieldImplementation.h.

220{ return (m_bits); }

◆ bits_offset()

IdDictFieldImplementation::size_type IdDictFieldImplementation::bits_offset ( ) const
inline

Definition at line 224 of file IdDictFieldImplementation.h.

226{ return (m_bits_offset); }

◆ decode_index()

bool IdDictFieldImplementation::decode_index ( ) const
inline

Definition at line 247 of file IdDictFieldImplementation.h.

249{ return (m_decode_index); }

◆ field()

const Range::field & IdDictFieldImplementation::field ( ) const
inline

Definition at line 207 of file IdDictFieldImplementation.h.

209{ return (m_field); }

◆ initialize()

void IdDictFieldImplementation::initialize ( )
inlineprivate

Definition at line 252 of file IdDictFieldImplementation.h.

254{
255 // Initialize masks and shift
256 m_mask = (static_cast<size_type>(1) << m_bits) - 1;
258
259 // Shifting by NBITS is undefined behavior.
262 else
264}

◆ mask()

IdDictFieldImplementation::size_type IdDictFieldImplementation::mask ( ) const
inline

Definition at line 230 of file IdDictFieldImplementation.h.

232{ return (m_mask); }

◆ new_pack()

Identifier IdDictFieldImplementation::new_pack ( int value) const
inline

Definition at line 189 of file IdDictFieldImplementation.h.

191{
192 // Pack value into this field
193 size_type index = (size_type)value;
194 if (m_decode_index) index = m_ored_field.get_value_index (value);
195 return Identifier(index << m_shift);
196}
str index
Definition DeMoScan.py:362

◆ optimize()

void IdDictFieldImplementation::optimize ( void )
inline

Definition at line 310 of file IdDictFieldImplementation.h.

311{
312 m_ored_field.optimize(); // optimize for decoding
313}

◆ ored_field()

const Range::field & IdDictFieldImplementation::ored_field ( ) const
inline

Definition at line 212 of file IdDictFieldImplementation.h.

214{ return (m_ored_field); }

◆ pack()

void IdDictFieldImplementation::pack ( int value,
Identifier & id ) const
inline

Definition at line 179 of file IdDictFieldImplementation.h.

181{
182 // Pack value into this field
183 size_type index = (size_type)value;
184 if (m_decode_index) index = m_ored_field.get_value_index (value);
185 id |= (index << m_shift);
186}

◆ range()

const IdDictRange * IdDictFieldImplementation::range ( ) const

Accessors.

@fileIdDictFieldImplementation.cxx

Date
2003-09-04 08:55:25
Author
schaffer

Definition at line 20 of file IdDictFieldImplementation.cxx.

20{return(m_range);}

◆ reset()

void IdDictFieldImplementation::reset ( Identifier & id) const
inline

Definition at line 199 of file IdDictFieldImplementation.h.

201{
202 // Reset field to 0
203 id &= m_zeroing_mask;
204}

◆ set_bits()

void IdDictFieldImplementation::set_bits ( size_type bits,
size_type bits_offset )
inline

Definition at line 294 of file IdDictFieldImplementation.h.

296{
297 // Set bits, offset and init
298 m_bits = bits;
300 initialize();
301}

◆ set_bits_offset()

void IdDictFieldImplementation::set_bits_offset ( size_type bits_offset)
inline

Definition at line 285 of file IdDictFieldImplementation.h.

287{
288 // Set offset and init
290 initialize();
291}

◆ set_decode_index()

void IdDictFieldImplementation::set_decode_index ( bool decode_index)
inline

Definition at line 304 of file IdDictFieldImplementation.h.

◆ set_field()

void IdDictFieldImplementation::set_field ( const Range::field & field)
inline

Definition at line 267 of file IdDictFieldImplementation.h.

269{
270 m_field = field;
271}
const Range::field & field() const

◆ set_ored_field()

void IdDictFieldImplementation::set_ored_field ( const Range::field & ored_field)
inline

Definition at line 275 of file IdDictFieldImplementation.h.

277{
278 // Set ored field and bits, and init
280 m_bits = m_ored_field.get_bits();
281 initialize();
282}
const Range::field & ored_field() const

◆ set_range()

void IdDictFieldImplementation::set_range ( const IdDictRange * range)

Modifiers.

Definition at line 23 of file IdDictFieldImplementation.cxx.

23 {
24 m_range = range;
25}
const IdDictRange * range() const
Accessors.

◆ shift()

IdDictFieldImplementation::size_type IdDictFieldImplementation::shift ( ) const
inline

Definition at line 242 of file IdDictFieldImplementation.h.

244{ return (m_shift); }

◆ show()

void IdDictFieldImplementation::show ( void ) const

Definition at line 28 of file IdDictFieldImplementation.cxx.

28 {
29 std::cout << show_to_string() << std::endl;
30}
std::string show_to_string(void) const

◆ show_to_string()

std::string IdDictFieldImplementation::show_to_string ( void ) const

Definition at line 32 of file IdDictFieldImplementation.cxx.

32 {
33 // Build the indexes list once
34 const auto& idx = m_ored_field.get_indexes();
35 std::string indexes;
36 indexes.reserve(idx.size() * 3);
37 for (std::size_t i = 0; i < idx.size(); ++i) {
38 if (i) indexes.push_back(' ');
39 indexes += std::to_string(idx[i]);
40 }
41 // Mode string
42 std::string_view mode =
43 m_ored_field.isBounded() ? "both_bounded"
44 : m_ored_field.isEnumerated() ? "enumerated"
45 : "unknown";
46 try{
47 return std::format(
48 "decode {:d} vals {:<15} "
49 "mask/zero mask/shift/bits/offset {:<3x} {:<3x} {:<3} {:<3} {:<3} "
50 "indexes {:<20} mode {} ",
52 static_cast<std::string>(m_ored_field),
53 m_mask,
55 m_shift,
56 m_bits,
58 indexes,
59 mode);
60 } catch (std::format_error & ){
61 return {};
62 }
63}

◆ unpack()

int IdDictFieldImplementation::unpack ( Identifier id) const
inline

Identifier manipulation methods.

Unpack a single field of the bits32 id.

One specifies the pointer to the field implementation to be used for decoding. The first_field_index is normally 0. It is non-zero when fields 0 to first_field_index -1 are missing from the compact

Definition at line 153 of file IdDictFieldImplementation.h.

155{
156 // Unpack field
157 size_type index = id.extract(m_shift, m_mask);
158 int field = index;
159 if (m_decode_index) field = m_ored_field.get_value_at (index);
160 return (field);
161}

◆ unpackToIndex()

Identifier::size_type IdDictFieldImplementation::unpackToIndex ( Identifier id) const
inline

Unpack a single field index of the id.

The value unpacked above may differ from the index if the values are enumerated rather than simply 0 to N-1.

Definition at line 170 of file IdDictFieldImplementation.h.

172{
173 // Unpack field
174 size_type index = id.extract(m_shift, m_mask);
175 return (index);
176}

◆ zeroing_mask()

IdDictFieldImplementation::value_type IdDictFieldImplementation::zeroing_mask ( ) const
inline

Definition at line 236 of file IdDictFieldImplementation.h.

238{ return (m_zeroing_mask); }

Member Data Documentation

◆ m_bits

size_type IdDictFieldImplementation::m_bits
private

Definition at line 113 of file IdDictFieldImplementation.h.

◆ m_bits_offset

size_type IdDictFieldImplementation::m_bits_offset
private

Definition at line 114 of file IdDictFieldImplementation.h.

◆ m_decode_index

bool IdDictFieldImplementation::m_decode_index
private

Definition at line 118 of file IdDictFieldImplementation.h.

◆ m_field

Range::field IdDictFieldImplementation::m_field
private

Definition at line 111 of file IdDictFieldImplementation.h.

◆ m_mask

size_type IdDictFieldImplementation::m_mask
private

Definition at line 115 of file IdDictFieldImplementation.h.

◆ m_ored_field

Range::field IdDictFieldImplementation::m_ored_field
private

Definition at line 112 of file IdDictFieldImplementation.h.

◆ m_range

const IdDictRange* IdDictFieldImplementation::m_range
private

Definition at line 110 of file IdDictFieldImplementation.h.

◆ m_shift

size_type IdDictFieldImplementation::m_shift
private

Definition at line 117 of file IdDictFieldImplementation.h.

◆ m_zeroing_mask

value_type IdDictFieldImplementation::m_zeroing_mask
private

Definition at line 116 of file IdDictFieldImplementation.h.


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