ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
DetectorDescription
Identifier
Identifier
DetectorDescription/Identifier/Identifier/Identifier.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
#ifndef IDENTIFIER_IDENTIFIER_H
6
#define IDENTIFIER_IDENTIFIER_H
7
8
9
#include "
Identifier/Identifier32.h
"
10
#include <string>
11
#include <string_view>
12
#include <iosfwd>
13
14
class
MsgStream;
15
/*
16
*
17
* @brief Identifier is a simple type-safe 64 bit unsigned integer. An
18
* Identifier relies on other classes - IdHelpers - to encode and
19
* decode its information.
20
*
21
* The default constructor created an Identifier an invalid state
22
* which can be check with the "is_valid" method to allow some error
23
* checking.
24
*
25
*/
26
class
Identifier
{
27
public
:
28
29
using
id_type
=
Identifier
;
30
using
value_type
=
unsigned
long
long;
31
using
diff_type
=
long
long;
32
using
size_type
=
unsigned
long
long ;
33
34
static
constexpr
unsigned
int
NBITS
=
sizeof
(
value_type
) * 8;
// bits per byte
35
static
constexpr
value_type
MAX_BIT
= (
static_cast<
value_type
>
(1) << (
NBITS
- 1));
36
static
constexpr
value_type
ALL_BITS
= ~(
static_cast<
value_type
>
(0));
37
39
Identifier
() =
default
;
40
44
explicit
Identifier
(
value_type
value);
45
47
Identifier
(
const
Identifier32
& other);
48
51
explicit
Identifier
(
Identifier32::value_type
value);
52
explicit
Identifier
(
int
value);
54
56
Identifier
&
operator =
(
const
Identifier32
& old);
57
Identifier
&
operator =
(
value_type
value);
59
Identifier
&
operator =
(
Identifier32::value_type
value);
60
Identifier
&
operator =
(
int
value);
61
62
private
:
64
Identifier
&
operator |=
(
value_type
value);
65
Identifier
&
operator &=
(
value_type
value);
66
67
public
:
68
70
void
set
(std::string_view
id
);
71
73
void
clear
();
74
76
Identifier
&
set_literal
(
value_type
value);
77
80
Identifier32
get_identifier32
()
const
;
81
83
value_type
get_compact
()
const
;
84
86
struct
get_compact_func
{
87
value_type
operator()
(
const
Identifier
&
id
){
88
return
id
.get_compact();
89
}
90
};
91
92
bool
operator ==
(
const
Identifier
& other)
const
=
default
;
93
inline
auto
operator <=> (
const
Identifier
& other)
const
{
return
m_id <=> other.m_id;}
100
bool
operator ==
(
value_type
other)
const
;
101
bool
operator ==
(
Identifier32::value_type
other)
const
;
102
bool
operator ==
(
int
other)
const
;
103
105
bool
is_valid
()
const
;
106
108
std::string
getString
()
const
;
109
111
void
show
(std::ostream & out)
const
;
112
void
show
(MsgStream & out)
const
;
113
114
private
:
116
value_type
extract
(
size_type
shift,
size_type
mask)
const
;
117
119
value_type
mask_shift
(
value_type
mask,
size_type
shift)
const
;
120
122
value_type
extract
(
size_type
shift)
const
;
123
124
// allow IdDict access to the following private methods
125
friend
class
IdDictDictionary
;
126
friend
class
IdDictFieldImplementation
;
127
friend
class
AtlasDetectorID
;
128
friend
class
PixelID
;
129
130
enum
max_value_type
{
131
max_value
= ~(
static_cast<
value_type
>
(0))
132
};
133
134
value_type
m_id
=
max_value
;
135
};
136
137
MsgStream&
138
operator<<
(MsgStream& f,
const
Identifier
&
id
);
139
140
std::ostream&
141
operator<<
(std::ostream& os,
const
Identifier
&
id
);
142
144
namespace
std
{
145
template
<>
146
struct
hash<
Identifier
>{
147
size_t
operator()
(
const
Identifier
&
id
)
const
{
148
return
static_cast<
size_t
>
(
id
.get_compact());
149
}
150
};
151
}
152
153
#include "
Identifier/Identifier.icc
"
154
155
#endif
operator=
ElementLink & operator=(const ElementLink &)=default
operator==
bool operator==(const DataVector< T > &a, const DataVector< T > &b)
Vector equality comparison.
operator<<
MsgStream & operator<<(MsgStream &f, const Identifier &id)
Definition
Identifier.cxx:55
Identifier32.h
Identifier.icc
operator&=
constexpr std::enable_if_t< is_bitmask_v< E >, E & > operator&=(E &lhs, E rhs)
operator&=
Definition
bitmask.h:185
operator|=
constexpr std::enable_if_t< is_bitmask_v< E >, E & > operator|=(E &lhs, E rhs)
operator|=
Definition
bitmask.h:197
Identifier32
Definition
Identifier32.h:28
Identifier32::value_type
unsigned int value_type
Definition
Identifier32.h:31
Identifier::id_type
Identifier id_type
Definition
DetectorDescription/Identifier/Identifier/Identifier.h:29
Identifier::getString
std::string getString() const
Provide a string form of the identifier - hexadecimal.
Definition
Identifier.cxx:37
Identifier::MAX_BIT
static constexpr value_type MAX_BIT
Definition
DetectorDescription/Identifier/Identifier/Identifier.h:35
Identifier::IdDictDictionary
friend class IdDictDictionary
Definition
DetectorDescription/Identifier/Identifier/Identifier.h:125
Identifier::m_id
value_type m_id
The only data member.
Definition
DetectorDescription/Identifier/Identifier/Identifier.h:134
Identifier::is_valid
bool is_valid() const
Check if id is in a valid state.
Identifier::clear
void clear()
Reset to invalid state.
Identifier::AtlasDetectorID
friend class AtlasDetectorID
Definition
DetectorDescription/Identifier/Identifier/Identifier.h:127
Identifier::max_value
@ max_value
Definition
DetectorDescription/Identifier/Identifier/Identifier.h:131
Identifier::show
void show(std::ostream &out) const
Print out in hex form.
Definition
Identifier.cxx:47
Identifier::get_compact
value_type get_compact() const
Get the compact id.
Identifier::Identifier
Identifier(const Identifier32 &other)
Constructor from Identifier32.
Identifier::PixelID
friend class PixelID
Definition
DetectorDescription/Identifier/Identifier/Identifier.h:128
Identifier::Identifier
Identifier(Identifier32::value_type value)
Constructor from 32-bit value_type and int (to avoid common implicit conversions).
Identifier::set_literal
Identifier & set_literal(value_type value)
Set literal value.
Identifier::ALL_BITS
static constexpr value_type ALL_BITS
Definition
DetectorDescription/Identifier/Identifier/Identifier.h:36
Identifier::set
void set(std::string_view id)
build from a string form - hexadecimal
Definition
Identifier.cxx:25
Identifier::extract
value_type extract(size_type shift, size_type mask) const
extract field from identifier (shift first, then mask)
Identifier::NBITS
static constexpr unsigned int NBITS
Definition
DetectorDescription/Identifier/Identifier/Identifier.h:34
Identifier::diff_type
long long diff_type
Definition
DetectorDescription/Identifier/Identifier/Identifier.h:31
Identifier::mask_shift
value_type mask_shift(value_type mask, size_type shift) const
extract field(s) by masking first, then shifting
Identifier::size_type
unsigned long long size_type
Definition
DetectorDescription/Identifier/Identifier/Identifier.h:32
Identifier::extract
value_type extract(size_type shift) const
extract field, no mask
Identifier::Identifier
Identifier()=default
Default constructor.
Identifier::max_value_type
max_value_type
Definition
DetectorDescription/Identifier/Identifier/Identifier.h:130
Identifier::get_identifier32
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
Identifier::Identifier
Identifier(value_type value)
Identifier::Identifier
Identifier(int value)
Identifier::IdDictFieldImplementation
friend class IdDictFieldImplementation
Definition
DetectorDescription/Identifier/Identifier/Identifier.h:126
Identifier::value_type
unsigned long long value_type
Definition
DetectorDescription/Identifier/Identifier/Identifier.h:30
Identifier
Definition
IdentifierFieldParser.cxx:14
std
STL namespace.
Identifier::get_compact_func
A get_compact functional for use in STL algorithms.
Definition
DetectorDescription/Identifier/Identifier/Identifier.h:86
Identifier::get_compact_func::operator()
value_type operator()(const Identifier &id)
Definition
DetectorDescription/Identifier/Identifier/Identifier.h:87
std::hash< Identifier >::operator()
size_t operator()(const Identifier &id) const
Definition
DetectorDescription/Identifier/Identifier/Identifier.h:147
Generated on
for ATLAS Offline Software by
1.17.0