2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5 /// Constructor from Identifier32
6 //-----------------------------------------------
7 inline Identifier::Identifier(const Identifier32& other)
10 if (other.is_valid()) {
11 m_id = (static_cast<value_type>(other.get_compact()) << 32);
15 /// Constructor from Identifier32 value_type (unsigned int)
16 /// (only use in id64 case since otherwise redundant)
17 //-----------------------------------------------
18 inline Identifier::Identifier(Identifier32::value_type value)
21 if (value == ~static_cast<Identifier32::value_type>(0)) {
24 m_id = (static_cast<value_type>(value) << 32);
27 inline Identifier::Identifier(int value)
28 : m_id(static_cast<value_type>(value) << 32)
32 //-----------------------------------------------
33 inline Identifier::Identifier(value_type value)
37 // Print out warning for potential call with value for a 32-bit id
38 // I.e. if lower bits are set and no upper bit set
39 const value_type upper = 0XFFFFFFFF00000000LL;
40 const value_type lower = 0X00000000FFFFFFFFLL;
41 const value_type testUpper = value & upper;
42 const value_type testLower = value & lower;
43 if (testUpper == 0 && testLower > 0) {
44 boost::io::ios_flags_saver ifs(std::cout);
45 std::cout << "Identifier::Identifier - WARNING Constructing 64-bit id "
46 "with empty upper and non-empty lower: "
47 << std::hex << testUpper << " " << testLower << std::endl;
53 //-----------------------------------------------
56 Identifier::operator=(const Identifier32& old)
58 m_id = (static_cast<value_type>(old.get_compact()) << 32);
63 Identifier::operator=(value_type value)
66 // Print out warning for potential call with value for a 32-bit id
67 // I.e. if lower bits are set and no upper bit set
68 const value_type upper = 0XFFFFFFFF00000000LL;
69 const value_type lower = 0X00000000FFFFFFFFLL;
70 const value_type testUpper = value & upper;
71 const value_type testLower = value & lower;
72 if (testUpper == 0 && testLower > 0) {
73 boost::io::ios_flags_saver ifs(std::cout);
74 std::cout << "Identifier::opertor = - WARNING Constructing 64-bit id "
75 "with empty upper and non-empty lower: "
76 << std::hex << testUpper << " " << testLower << std::endl;
86 Identifier::operator=(Identifier32::value_type value)
88 if (value == ~static_cast<Identifier32::value_type>(0)) {
91 m_id = static_cast<value_type>(value) << 32;
96 Identifier::operator=(int value)
98 m_id = static_cast<value_type>(value) << 32;
103 Identifier::operator|=(value_type value)
110 Identifier::operator&=(value_type value)
117 Identifier::set_literal(value_type value)
129 inline Identifier::value_type
130 Identifier::extract(Identifier::size_type shift,
131 Identifier::size_type mask) const
133 return (m_id >> shift) & static_cast<Identifier::value_type>(mask);
136 inline Identifier::value_type
137 Identifier::mask_shift(Identifier::value_type mask,
138 Identifier::size_type shift) const
140 return (m_id & mask) >> shift;
143 inline Identifier::value_type
144 Identifier::extract(Identifier::size_type shift) const
146 return (m_id >> shift);
150 Identifier::get_identifier32(void) const
152 // test for bit set in lower 32
153 if (extract(0, 0xFFFFFFFF))
154 return (Identifier32());
155 return (Identifier32(extract(32)));
158 inline Identifier::value_type
159 Identifier::get_compact(void) const
164 // Comparison operators
165 //----------------------------------------------------------------
167 Identifier::operator==(const Identifier& other) const
169 return (m_id == other.m_id);
172 //----------------------------------------------------------------
174 Identifier::operator!=(const Identifier& other) const
176 return (m_id != other.m_id);
179 //-----------------------------------------------
181 Identifier::operator<(const Identifier& other) const
183 return (m_id < other.m_id);
186 //-----------------------------------------------
188 Identifier::operator>(const Identifier& other) const
190 return (m_id > other.m_id);
193 //-----------------------------------------------
195 Identifier::operator<=(const Identifier& other) const
197 return (m_id <= other.m_id);
200 //-----------------------------------------------
202 Identifier::operator>=(const Identifier& other) const
204 return (m_id >= other.m_id);
207 //----------------------------------------------------------------
209 Identifier::operator==(Identifier::value_type other) const
211 return (m_id == other);
215 Identifier::operator!=(Identifier::value_type other) const
217 return (m_id != other);
221 Identifier::operator==(Identifier32::value_type other) const
223 return ((*this) == Identifier(other));
227 Identifier::operator==(int other) const
229 return ((*this) == Identifier(other));
233 Identifier::operator!=(Identifier32::value_type other) const
235 return ((*this) != Identifier(other));
239 Identifier::operator!=(int other) const
241 return ((*this) != Identifier(other));
244 /// This is for logging
247 operator<<(MsgStream& f, const Identifier& id)
254 operator<<(std::ostream& os, const Identifier& id)
256 os << id.getString();
261 Identifier::is_valid() const
263 return (!(max_value == m_id));