ATLAS Offline Software
Loading...
Searching...
No Matches
Identifier.icc
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5/// Constructor from Identifier32
6inline Identifier::Identifier(const Identifier32& other)
7 : m_id(max_value){
8 if (other.is_valid()) {
9 m_id = (static_cast<value_type>(other.get_compact()) << 32);
10 }
11}
12
13/// Constructor from Identifier32 value_type (unsigned int)
14/// (only use in id64 case since otherwise redundant)
15inline Identifier::Identifier(Identifier32::value_type value)
16 : m_id(max_value){
17 if (value == ~static_cast<Identifier32::value_type>(0)) {
18 m_id = max_value;
19 } else {
20 m_id = (static_cast<value_type>(value) << 32);
21 }
22}
23
24inline Identifier::Identifier(int value)
25 : m_id(static_cast<value_type>(value) << 32)
26{/* */}
27
28//-----------------------------------------------
29inline Identifier::Identifier(value_type value)
30 : m_id(value){
31 const value_type upper = 0XFFFFFFFF00000000LL;
32 const value_type lower = 0X00000000FFFFFFFFLL;
33 const value_type testUpper = value & upper;
34 const value_type testLower = value & lower;
35 if (testUpper == 0 && testLower > 0) {
36 m_id = (value << 32);
37 }
38}
39
40
41inline Identifier&
42Identifier::operator=(const Identifier32& old){
43 m_id = (static_cast<value_type>(old.get_compact()) << 32);
44 return (*this);
45}
46
47inline Identifier&
48Identifier::operator=(value_type value){
49 // I.e. if lower bits are set and no upper bit set
50 const value_type upper = 0XFFFFFFFF00000000LL;
51 const value_type lower = 0X00000000FFFFFFFFLL;
52 const value_type testUpper = value & upper;
53 const value_type testLower = value & lower;
54 if (testUpper == 0 && testLower > 0) {
55 m_id = (value << 32);
56 return (*this);
57 }
58 m_id = value;
59 return (*this);
60}
61
62inline Identifier&
63Identifier::operator=(Identifier32::value_type value){
64 if (value == ~static_cast<Identifier32::value_type>(0)) {
65 m_id = max_value;
66 } else {
67 m_id = static_cast<value_type>(value) << 32;
68 }
69 return (*this);
70}
71
72inline Identifier&
73Identifier::operator=(int value){
74 m_id = static_cast<value_type>(value) << 32;
75 return (*this);
76}
77
78inline Identifier&
79Identifier::operator|=(value_type value){
80 m_id |= value;
81 return (*this);
82}
83
84inline Identifier&
85Identifier::operator&=(value_type value){
86 m_id &= value;
87 return (*this);
88}
89
90inline Identifier&
91Identifier::set_literal(value_type value){
92 m_id = value;
93 return (*this);
94}
95
96inline void
97Identifier::clear(){
98 m_id = max_value;
99}
100
101inline Identifier::value_type
102Identifier::extract(Identifier::size_type shift,
103 Identifier::size_type mask) const{
104 return (m_id >> shift) & static_cast<Identifier::value_type>(mask);
105}
106
107inline Identifier::value_type
108Identifier::mask_shift(Identifier::value_type mask,
109 Identifier::size_type shift) const{
110 return (m_id & mask) >> shift;
111}
112
113inline Identifier::value_type
114Identifier::extract(Identifier::size_type shift) const{
115 return (m_id >> shift);
116}
117
118inline Identifier32
119Identifier::get_identifier32() const{
120 // test for bit set in lower 32
121 if (extract(0, 0xFFFFFFFF)) return (Identifier32());
122 return (Identifier32(extract(32)));
123}
124
125inline Identifier::value_type
126Identifier::get_compact() const{
127 return (m_id);
128}
129
130
131inline bool
132Identifier::operator==(Identifier::value_type other) const{
133 return (m_id == other);
134}
135
136inline bool
137Identifier::operator==(Identifier32::value_type other) const{
138 return ((*this) == Identifier(other));
139}
140
141inline bool
142Identifier::operator==(int other) const{
143 return ((*this) == Identifier(other));
144}
145
146
147inline bool
148Identifier::is_valid() const{
149 return (!(max_value == m_id));
150}
151