ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
DetectorDescription
IdDict
IdDict
IdDictFieldImplementation.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
/***************************************************************************
6
IdDict package
7
***************************************************************************/
8
9
//<doc><file> $Id: IdDictFieldImplementation.h,v 1.2 2007-11-08 21:21:47 ssnyder Exp $
10
//<version> $Name: not supported by cvs2svn $
11
12
#ifndef IDDICT_IDDICTFIELDIMPLEMENTATION_H
13
# define IDDICT_IDDICTFIELDIMPLEMENTATION_H
14
15
//<<<<<< INCLUDES >>>>>>
16
17
#include "Identifier/Identifier.h"
18
#include "
Identifier/Range.h
"
19
#include <iosfwd>
20
class
IdDictRange
;
21
class
MsgStream;
22
56
57
58
class
IdDictFieldImplementation
59
{
60
public
:
61
62
typedef
Identifier::value_type
value_type
;
63
typedef
Identifier::size_type
size_type
;
64
65
typedef
enum
66
{
67
NBITS
=
sizeof
(
value_type
) * 8,
// bits per byte
68
MAX_BIT
= (
static_cast<
value_type
>
(1) << (
NBITS
- 1)),
69
ALL_BITS
= ~(
static_cast<
value_type
>
(0))
70
}
bit_defs
;
71
72
IdDictFieldImplementation
();
73
75
int
unpack
(
Identifier
id
)
const
;
// access to field value
76
size_type
unpackToIndex
(
Identifier
id
)
const
;
// access to field index, i.e. from 0
77
void
pack
(
int
value,
Identifier
&
id
)
const
;
78
Identifier
new_pack
(
int
value)
const
;
//pack to a new Identifier
79
void
reset
(
Identifier
&
id
)
const
;
// reset field bits
80
82
const
IdDictRange
*
range
()
const
;
83
const
Range::field
&
field
()
const
;
84
const
Range::field
&
ored_field
()
const
;
85
size_type
bits
()
const
;
86
size_type
bits_offset
()
const
;
87
size_type
mask
()
const
;
88
value_type
zeroing_mask
()
const
;
89
size_type
shift
()
const
;
90
bool
decode_index
()
const
;
91
93
void
set_range
(
const
IdDictRange
*
range
);
94
void
set_field
(
const
Range::field
&
field
);
95
void
set_ored_field
(
const
Range::field
&
ored_field
);
96
void
set_bits_offset
(
size_type
bits_offset
);
97
void
set_bits
(
size_type
bits
,
size_type
bits_offset
);
98
void
set_decode_index
(
bool
decode_index
);
99
void
optimize
(
void
);
100
101
// Printout
102
void
show
(
void
)
const
;
103
std::string
show_to_string
(
void
)
const
;
104
105
private
:
106
107
// Initialize derived fields
108
void
initialize
();
109
110
const
IdDictRange
*
m_range
;
111
Range::field
m_field
;
112
Range::field
m_ored_field
;
113
size_type
m_bits
;
114
size_type
m_bits_offset
;
115
size_type
m_mask
;
116
value_type
m_zeroing_mask
;
117
size_type
m_shift
;
118
bool
m_decode_index
;
119
120
};
121
123
std::ostream &
operator<<
(std::ostream & os,
const
IdDictFieldImplementation
&);
125
MsgStream &
operator<<
(MsgStream & ms,
const
IdDictFieldImplementation
&);
126
127
//<<<<<< INLINE MEMBER FUNCTIONS >>>>>>
128
129
//-----------------------------------------------------------------
130
inline
IdDictFieldImplementation::IdDictFieldImplementation
()
131
//-----------------------------------------------------------------
132
:
133
m_range
(0),
134
m_field
(0),
135
m_ored_field
(0),
136
m_bits
(0),
137
m_bits_offset
(0),
138
m_mask
(0),
139
m_zeroing_mask
(0),
140
m_shift
(0),
141
m_decode_index
(0)
142
{}
143
144
152
//-----------------------------------------------------------------
153
inline
int
IdDictFieldImplementation::unpack
(
Identifier
id
)
const
154
//-----------------------------------------------------------------
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
}
162
163
169
//-----------------------------------------------------------------
170
inline
Identifier::size_type
IdDictFieldImplementation::unpackToIndex
(
Identifier
id
)
const
171
//-----------------------------------------------------------------
172
{
173
// Unpack field
174
size_type
index
=
id
.extract(
m_shift
,
m_mask
);
175
return
(
index
);
176
}
177
178
//-----------------------------------------------------------------
179
inline
void
IdDictFieldImplementation::pack
(
int
value,
Identifier
&
id
)
const
180
//-----------------------------------------------------------------
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
}
187
188
//-----------------------------------------------------------------
189
inline
Identifier
IdDictFieldImplementation::new_pack
(
int
value)
const
190
//-----------------------------------------------------------------
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
}
197
198
//-----------------------------------------------------------------
199
inline
void
IdDictFieldImplementation::reset
(
Identifier
&
id
)
const
200
//-----------------------------------------------------------------
201
{
202
// Reset field to 0
203
id
&=
m_zeroing_mask
;
204
}
205
206
//-----------------------------------------------------------------
207
inline
const
Range::field
&
IdDictFieldImplementation::field
()
const
208
//-----------------------------------------------------------------
209
{
return
(
m_field
); }
210
211
//-----------------------------------------------------------------
212
inline
const
Range::field
&
IdDictFieldImplementation::ored_field
()
const
213
//-----------------------------------------------------------------
214
{
return
(
m_ored_field
); }
215
216
//-----------------------------------------------------------------
217
inline
IdDictFieldImplementation::size_type
218
IdDictFieldImplementation::bits
()
const
219
//-----------------------------------------------------------------
220
{
return
(
m_bits
); }
221
222
//-----------------------------------------------------------------
223
inline
IdDictFieldImplementation::size_type
224
IdDictFieldImplementation::bits_offset
()
const
225
//-----------------------------------------------------------------
226
{
return
(
m_bits_offset
); }
227
228
//-----------------------------------------------------------------
229
inline
IdDictFieldImplementation::size_type
230
IdDictFieldImplementation::mask
()
const
231
//-----------------------------------------------------------------
232
{
return
(
m_mask
); }
233
234
//-----------------------------------------------------------------
235
inline
IdDictFieldImplementation::value_type
236
IdDictFieldImplementation::zeroing_mask
()
const
237
//-----------------------------------------------------------------
238
{
return
(
m_zeroing_mask
); }
239
240
//-----------------------------------------------------------------
241
inline
IdDictFieldImplementation::size_type
242
IdDictFieldImplementation::shift
()
const
243
//-----------------------------------------------------------------
244
{
return
(
m_shift
); }
245
246
//-----------------------------------------------------------------
247
inline
bool
IdDictFieldImplementation::decode_index
()
const
248
//-----------------------------------------------------------------
249
{
return
(
m_decode_index
); }
250
251
//-----------------------------------------------------------------
252
inline
void
IdDictFieldImplementation::initialize
()
253
//-----------------------------------------------------------------
254
{
255
// Initialize masks and shift
256
m_mask
= (
static_cast<
size_type
>
(1) <<
m_bits
) - 1;
257
m_shift
=
IdDictFieldImplementation::NBITS
-
m_bits
-
m_bits_offset
;
258
259
// Shifting by NBITS is undefined behavior.
260
if
(
m_shift
<
IdDictFieldImplementation::NBITS
)
261
m_zeroing_mask
= (
m_mask
<<
m_shift
) ^
IdDictFieldImplementation::ALL_BITS
;
262
else
263
m_zeroing_mask
=
IdDictFieldImplementation::ALL_BITS
;
264
}
265
266
//-----------------------------------------------------------------
267
inline
void
IdDictFieldImplementation::set_field
(
const
Range::field
&
field
)
268
//-----------------------------------------------------------------
269
{
270
m_field
=
field
;
271
}
272
273
274
//-----------------------------------------------------------------
275
inline
void
IdDictFieldImplementation::set_ored_field
(
const
Range::field
&
ored_field
)
276
//-----------------------------------------------------------------
277
{
278
// Set ored field and bits, and init
279
m_ored_field
=
ored_field
;
280
m_bits
=
m_ored_field
.get_bits();
281
initialize
();
282
}
283
284
//-----------------------------------------------------------------
285
inline
void
IdDictFieldImplementation::set_bits_offset
(
size_type
bits_offset
)
286
//-----------------------------------------------------------------
287
{
288
// Set offset and init
289
m_bits_offset
=
bits_offset
;
290
initialize
();
291
}
292
293
//-----------------------------------------------------------------
294
inline
void
IdDictFieldImplementation::set_bits
(
size_type
bits
,
size_type
bits_offset
)
295
//-----------------------------------------------------------------
296
{
297
// Set bits, offset and init
298
m_bits
=
bits
;
299
m_bits_offset
=
bits_offset
;
300
initialize
();
301
}
302
303
//-----------------------------------------------------------------
304
inline
void
IdDictFieldImplementation::set_decode_index
(
bool
decode_index
)
305
//-----------------------------------------------------------------
306
{
307
m_decode_index
=
decode_index
;
308
}
309
310
inline
void
IdDictFieldImplementation::optimize
(
void
)
311
{
312
m_ored_field
.optimize();
// optimize for decoding
313
}
314
315
#endif
// IDDICT_IDDICTFIELDIMPLEMENTATION_H
Range.h
operator<<
std::ostream & operator<<(std::ostream &os, const IdDictFieldImplementation &)
stream insertion operator uses show_to_string
Definition
IdDictFieldImplementation.cxx:66
IdDictFieldImplementation
IdDictFieldImplementation is used to capture the specification of a single field of an Identifier.
Definition
IdDictFieldImplementation.h:59
IdDictFieldImplementation::new_pack
Identifier new_pack(int value) const
Definition
IdDictFieldImplementation.h:189
IdDictFieldImplementation::m_bits
size_type m_bits
Definition
IdDictFieldImplementation.h:113
IdDictFieldImplementation::range
const IdDictRange * range() const
Accessors.
Definition
IdDictFieldImplementation.cxx:20
IdDictFieldImplementation::reset
void reset(Identifier &id) const
Definition
IdDictFieldImplementation.h:199
IdDictFieldImplementation::set_bits_offset
void set_bits_offset(size_type bits_offset)
Definition
IdDictFieldImplementation.h:285
IdDictFieldImplementation::m_field
Range::field m_field
Definition
IdDictFieldImplementation.h:111
IdDictFieldImplementation::IdDictFieldImplementation
IdDictFieldImplementation()
Definition
IdDictFieldImplementation.h:130
IdDictFieldImplementation::m_decode_index
bool m_decode_index
Definition
IdDictFieldImplementation.h:118
IdDictFieldImplementation::set_range
void set_range(const IdDictRange *range)
Modifiers.
Definition
IdDictFieldImplementation.cxx:23
IdDictFieldImplementation::m_bits_offset
size_type m_bits_offset
Definition
IdDictFieldImplementation.h:114
IdDictFieldImplementation::set_ored_field
void set_ored_field(const Range::field &ored_field)
Definition
IdDictFieldImplementation.h:275
IdDictFieldImplementation::set_field
void set_field(const Range::field &field)
Definition
IdDictFieldImplementation.h:267
IdDictFieldImplementation::mask
size_type mask() const
Definition
IdDictFieldImplementation.h:230
IdDictFieldImplementation::zeroing_mask
value_type zeroing_mask() const
Definition
IdDictFieldImplementation.h:236
IdDictFieldImplementation::bits_offset
size_type bits_offset() const
Definition
IdDictFieldImplementation.h:224
IdDictFieldImplementation::m_zeroing_mask
value_type m_zeroing_mask
Definition
IdDictFieldImplementation.h:116
IdDictFieldImplementation::m_ored_field
Range::field m_ored_field
Definition
IdDictFieldImplementation.h:112
IdDictFieldImplementation::ored_field
const Range::field & ored_field() const
Definition
IdDictFieldImplementation.h:212
IdDictFieldImplementation::initialize
void initialize()
Definition
IdDictFieldImplementation.h:252
IdDictFieldImplementation::decode_index
bool decode_index() const
Definition
IdDictFieldImplementation.h:247
IdDictFieldImplementation::pack
void pack(int value, Identifier &id) const
Definition
IdDictFieldImplementation.h:179
IdDictFieldImplementation::unpackToIndex
size_type unpackToIndex(Identifier id) const
Unpack a single field index of the id.
Definition
IdDictFieldImplementation.h:170
IdDictFieldImplementation::bit_defs
bit_defs
Definition
IdDictFieldImplementation.h:66
IdDictFieldImplementation::MAX_BIT
@ MAX_BIT
Definition
IdDictFieldImplementation.h:68
IdDictFieldImplementation::ALL_BITS
@ ALL_BITS
Definition
IdDictFieldImplementation.h:69
IdDictFieldImplementation::NBITS
@ NBITS
Definition
IdDictFieldImplementation.h:67
IdDictFieldImplementation::show_to_string
std::string show_to_string(void) const
Definition
IdDictFieldImplementation.cxx:32
IdDictFieldImplementation::bits
size_type bits() const
Definition
IdDictFieldImplementation.h:218
IdDictFieldImplementation::set_decode_index
void set_decode_index(bool decode_index)
Definition
IdDictFieldImplementation.h:304
IdDictFieldImplementation::m_range
const IdDictRange * m_range
Definition
IdDictFieldImplementation.h:110
IdDictFieldImplementation::size_type
Identifier::size_type size_type
Definition
IdDictFieldImplementation.h:63
IdDictFieldImplementation::set_bits
void set_bits(size_type bits, size_type bits_offset)
Definition
IdDictFieldImplementation.h:294
IdDictFieldImplementation::value_type
Identifier::value_type value_type
Definition
IdDictFieldImplementation.h:62
IdDictFieldImplementation::m_shift
size_type m_shift
Definition
IdDictFieldImplementation.h:117
IdDictFieldImplementation::unpack
int unpack(Identifier id) const
Identifier manipulation methods.
Definition
IdDictFieldImplementation.h:153
IdDictFieldImplementation::show
void show(void) const
Definition
IdDictFieldImplementation.cxx:28
IdDictFieldImplementation::optimize
void optimize(void)
Definition
IdDictFieldImplementation.h:310
IdDictFieldImplementation::shift
size_type shift() const
Definition
IdDictFieldImplementation.h:242
IdDictFieldImplementation::m_mask
size_type m_mask
Definition
IdDictFieldImplementation.h:115
IdDictFieldImplementation::field
const Range::field & field() const
Definition
IdDictFieldImplementation.h:207
IdDictRange
Definition
IdDictRange.h:19
Range::field
IdentifierField field
Definition
DetectorDescription/Identifier/Identifier/Range.h:36
const
Identifier
Definition
IdentifierFieldParser.cxx:14
index
Definition
index.py:1
Generated on
for ATLAS Offline Software by
1.17.0