ATLAS Offline Software
IdentContIndex.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ATHLINKS_TOOLS_IDENTCONTINDEX_H
6 # define ATHLINKS_TOOLS_IDENTCONTINDEX_H
7 
23 {
24 public:
26 
28  IdentContIndex(unsigned short collHash, unsigned short objIndex);
29  IdentContIndex(unsigned int hashAndIndex);
31 
33  unsigned short collHash() const;
36  unsigned short objIndex() const;
38  unsigned int hashAndIndex() const;
40  bool isValid() const;
42 
44 
45  void setHashAndIndex(unsigned int hashAndIndex);
48  void setCollHash(unsigned short hash);
50  void setObjIndex(unsigned short index);
52 
53 private:
54  unsigned short m_collHash;
55  unsigned short m_objIndex;
56 };
57 
58 
59 
60 // inline definitions
61 
62 inline
64  :
65  m_collHash(0xFFFF),
66  m_objIndex(0xFFFF)
67 {}
68 
69 inline
70 IdentContIndex::IdentContIndex(unsigned short collHash, unsigned short objIndex)
71  :
72  m_collHash(collHash),
73  m_objIndex(objIndex)
74 {}
75 
76 inline
77 IdentContIndex::IdentContIndex(unsigned int hashAndIndex)
78 {
80 }
81 
82 
83 inline
84 unsigned short
86 {
87  return (m_collHash);
88 }
89 
90 inline
91 unsigned short
93 {
94  return (m_objIndex);
95 }
96 
97 inline
98 unsigned int
100 {
101  // Concatenate hash and index
102  unsigned int result = (m_collHash << 16) + m_objIndex;
103  return (result);
104 }
105 
106 inline
107 bool
109 {
110  // is valid if both hash and index are not default values
111  return (m_collHash != 0xFFFF && m_objIndex != 0xFFFF);
112 }
113 
114 
115 inline
116 void
117 IdentContIndex::setHashAndIndex(unsigned int hashAndIndex)
118 {
119  // Extract hash and index
120  m_collHash = static_cast<unsigned short> (hashAndIndex >> 16);
121  m_objIndex = static_cast<unsigned short> (hashAndIndex & 0xFFFF);
122 }
123 
124 inline
125 void
127 {
128  m_collHash = hash;
129 }
130 
131 inline
132 void
134 {
135  m_objIndex = index;
136 }
137 
138 #endif // not ATHLINKS_TOOLS_IDENTCONTINDEX_H
get_generator_info.result
result
Definition: get_generator_info.py:21
index
Definition: index.py:1
IdentContIndex
Identifiable container index to a contained object.
Definition: IdentContIndex.h:23
IdentContIndex::setObjIndex
void setObjIndex(unsigned short index)
set combined index
Definition: IdentContIndex.h:133
IdentContIndex::setCollHash
void setCollHash(unsigned short hash)
set object index in collection
Definition: IdentContIndex.h:126
IdentContIndex::m_objIndex
unsigned short m_objIndex
Definition: IdentContIndex.h:55
IdentContIndex::hashAndIndex
unsigned int hashAndIndex() const
combined index
Definition: IdentContIndex.h:99
IdentContIndex::objIndex
unsigned short objIndex() const
object index in collection
Definition: IdentContIndex.h:92
IdentContIndex::isValid
bool isValid() const
check that both fields are set
Definition: IdentContIndex.h:108
DeMoScan.index
string index
Definition: DeMoScan.py:364
IdentContIndex::IdentContIndex
IdentContIndex()
Constructors.
Definition: IdentContIndex.h:63
IdentContIndex::setHashAndIndex
void setHashAndIndex(unsigned int hashAndIndex)
Setters of hash, obj index and combined index.
Definition: IdentContIndex.h:117
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
IdentContIndex::m_collHash
unsigned short m_collHash
Definition: IdentContIndex.h:54
IdentContIndex::collHash
unsigned short collHash() const
Accessor to hash, obj index and combined index.
Definition: IdentContIndex.h:85