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
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 207 of file IdDictFieldImplementation.h.

209{ return (m_bits); }

◆ bits_offset()

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

Definition at line 213 of file IdDictFieldImplementation.h.

215{ return (m_bits_offset); }

◆ decode_index()

bool IdDictFieldImplementation::decode_index ( ) const
inline

Definition at line 236 of file IdDictFieldImplementation.h.

238{ return (m_decode_index); }

◆ field()

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

Definition at line 196 of file IdDictFieldImplementation.h.

198{ return (m_field); }

◆ initialize()

void IdDictFieldImplementation::initialize ( )
inlineprivate

Definition at line 241 of file IdDictFieldImplementation.h.

243{
244 // Initialize masks and shift
245 m_mask = (static_cast<size_type>(1) << m_bits) - 1;
247
248 // Shifting by NBITS is undefined behavior.
251 else
253}

◆ mask()

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

Definition at line 219 of file IdDictFieldImplementation.h.

221{ return (m_mask); }

◆ optimize()

void IdDictFieldImplementation::optimize ( void )
inline

Definition at line 299 of file IdDictFieldImplementation.h.

300{
301 m_ored_field.optimize(); // optimize for decoding
302}

◆ ored_field()

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

Definition at line 201 of file IdDictFieldImplementation.h.

203{ return (m_ored_field); }

◆ pack()

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

Definition at line 178 of file IdDictFieldImplementation.h.

180{
181 // Pack value into this field
182 size_type index = (size_type)value;
183 if (m_decode_index) index = m_ored_field.get_value_index (value);
184 id |= (index << m_shift);
185}
str index
Definition DeMoScan.py:362

◆ 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 188 of file IdDictFieldImplementation.h.

190{
191 // Reset field to 0
192 id &= m_zeroing_mask;
193}

◆ set_bits()

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

Definition at line 283 of file IdDictFieldImplementation.h.

285{
286 // Set bits, offset and init
287 m_bits = bits;
289 initialize();
290}

◆ set_bits_offset()

void IdDictFieldImplementation::set_bits_offset ( size_type bits_offset)
inline

Definition at line 274 of file IdDictFieldImplementation.h.

276{
277 // Set offset and init
279 initialize();
280}

◆ set_decode_index()

void IdDictFieldImplementation::set_decode_index ( bool decode_index)
inline

Definition at line 293 of file IdDictFieldImplementation.h.

◆ set_field()

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

Definition at line 256 of file IdDictFieldImplementation.h.

258{
259 m_field = field;
260}
const Range::field & field() const

◆ set_ored_field()

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

Definition at line 264 of file IdDictFieldImplementation.h.

266{
267 // Set ored field and bits, and init
269 m_bits = m_ored_field.get_bits();
270 initialize();
271}
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 231 of file IdDictFieldImplementation.h.

233{ 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 152 of file IdDictFieldImplementation.h.

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

◆ 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 169 of file IdDictFieldImplementation.h.

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

◆ zeroing_mask()

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

Definition at line 225 of file IdDictFieldImplementation.h.

227{ return (m_zeroing_mask); }

Member Data Documentation

◆ m_bits

size_type IdDictFieldImplementation::m_bits
private

Definition at line 112 of file IdDictFieldImplementation.h.

◆ m_bits_offset

size_type IdDictFieldImplementation::m_bits_offset
private

Definition at line 113 of file IdDictFieldImplementation.h.

◆ m_decode_index

bool IdDictFieldImplementation::m_decode_index
private

Definition at line 117 of file IdDictFieldImplementation.h.

◆ m_field

Range::field IdDictFieldImplementation::m_field
private

Definition at line 110 of file IdDictFieldImplementation.h.

◆ m_mask

size_type IdDictFieldImplementation::m_mask
private

Definition at line 114 of file IdDictFieldImplementation.h.

◆ m_ored_field

Range::field IdDictFieldImplementation::m_ored_field
private

Definition at line 111 of file IdDictFieldImplementation.h.

◆ m_range

const IdDictRange* IdDictFieldImplementation::m_range
private

Definition at line 109 of file IdDictFieldImplementation.h.

◆ m_shift

size_type IdDictFieldImplementation::m_shift
private

Definition at line 116 of file IdDictFieldImplementation.h.

◆ m_zeroing_mask

value_type IdDictFieldImplementation::m_zeroing_mask
private

Definition at line 115 of file IdDictFieldImplementation.h.


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