2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5 /// Constructor from Identifier32
6 inline Identifier::Identifier(const Identifier32& other)
8 if (other.is_valid()) {
9 m_id = (static_cast<value_type>(other.get_compact()) << 32);
13 /// Constructor from Identifier32 value_type (unsigned int)
14 /// (only use in id64 case since otherwise redundant)
15 inline Identifier::Identifier(Identifier32::value_type value)
17 if (value == ~static_cast<Identifier32::value_type>(0)) {
20 m_id = (static_cast<value_type>(value) << 32);
24 inline Identifier::Identifier(int value)
25 : m_id(static_cast<value_type>(value) << 32)
28 //-----------------------------------------------
29 inline Identifier::Identifier(value_type value)
32 // Print out warning for potential call with value for a 32-bit id
33 // I.e. if lower bits are set and no upper bit set
34 const value_type upper = 0XFFFFFFFF00000000LL;
35 const value_type lower = 0X00000000FFFFFFFFLL;
36 const value_type testUpper = value & upper;
37 const value_type testLower = value & lower;
38 if (testUpper == 0 && testLower > 0) {
39 std::cout << "Identifier::Identifier - WARNING Constructing 64-bit id "
40 "with empty upper and non-empty lower: "
41 << std::hex << testUpper << " " << testLower << std::dec << std::endl;
48 Identifier::operator=(const Identifier32& old){
49 m_id = (static_cast<value_type>(old.get_compact()) << 32);
54 Identifier::operator=(value_type value){
55 // Print out warning for potential call with value for a 32-bit id
56 // I.e. if lower bits are set and no upper bit set
57 const value_type upper = 0XFFFFFFFF00000000LL;
58 const value_type lower = 0X00000000FFFFFFFFLL;
59 const value_type testUpper = value & upper;
60 const value_type testLower = value & lower;
61 if (testUpper == 0 && testLower > 0) {
62 std::cout << "Identifier::operator = - WARNING Constructing 64-bit id "
63 "with empty upper and non-empty lower: "
64 << std::hex << testUpper << " " << testLower << std::dec << std::endl;
73 Identifier::operator=(Identifier32::value_type value){
74 if (value == ~static_cast<Identifier32::value_type>(0)) {
77 m_id = static_cast<value_type>(value) << 32;
83 Identifier::operator=(int value){
84 m_id = static_cast<value_type>(value) << 32;
89 Identifier::operator|=(value_type value){
95 Identifier::operator&=(value_type value){
101 Identifier::set_literal(value_type value){
111 inline Identifier::value_type
112 Identifier::extract(Identifier::size_type shift,
113 Identifier::size_type mask) const{
114 return (m_id >> shift) & static_cast<Identifier::value_type>(mask);
117 inline Identifier::value_type
118 Identifier::mask_shift(Identifier::value_type mask,
119 Identifier::size_type shift) const{
120 return (m_id & mask) >> shift;
123 inline Identifier::value_type
124 Identifier::extract(Identifier::size_type shift) const{
125 return (m_id >> shift);
129 Identifier::get_identifier32() const{
130 // test for bit set in lower 32
131 if (extract(0, 0xFFFFFFFF)) return (Identifier32());
132 return (Identifier32(extract(32)));
135 inline Identifier::value_type
136 Identifier::get_compact() const{
142 Identifier::operator==(Identifier::value_type other) const{
143 return (m_id == other);
147 Identifier::operator==(Identifier32::value_type other) const{
148 return ((*this) == Identifier(other));
152 Identifier::operator==(int other) const{
153 return ((*this) == Identifier(other));
156 /// This is for logging
159 operator<<(MsgStream& f, const Identifier& id){
165 operator<<(std::ostream& os, const Identifier& id){
166 os << id.getString();
171 Identifier::is_valid() const{
172 return (!(max_value == m_id));