ATLAS Offline Software
Loading...
Searching...
No Matches
PackedLinkImpl.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 * @file AthContainers/PackedLinkImpl.icc
6 * @author scott snyder <snyder@bnl.gov>
7 * @date Oct, 2023
8 * @brief Definition of PackedLink type.
9 */
10
11
12namespace SG {
13
14
15/**
16 * @brief Default constructor.
17 *
18 * Initialize a null link.
19 */
20inline
21PackedLinkBase::PackedLinkBase()
22 : m_packed (0)
23{
24}
25
26
27/**
28 * @brief Constructor.
29 * @param collection The index of the collection in the @c DataLink vector,
30 * @param index The index of the element within the collection.
31 */
32inline
33PackedLinkBase::PackedLinkBase (unsigned int collection, unsigned int index) :
34 m_packed ((collection << INDEX_NBITS) + index)
35{
36 assert (index <= INDEX_MAX);
37 assert (collection <= COLLECTION_MAX);
38}
39
40
41/**
42 * @brief Comparison.
43 * @param other The link with which to compare.
44 */
45inline
46bool PackedLinkBase::operator== (const PackedLinkBase& other) const
47{
48 return m_packed == other.m_packed;
49}
50
51
52/**
53 * @brief Unpack the collection index from the link.
54 */
55inline
56unsigned int PackedLinkBase::collection() const
57{
58 return m_packed >> INDEX_NBITS;
59}
60
61
62/**
63 * @brief Unpack the element index from the link.
64 */
65inline
66unsigned int PackedLinkBase::index() const
67{
68 return (m_packed & INDEX_MAX);
69}
70
71
72/**
73 * @brief Set the collection index;
74 * @param collection The index of the collection in the @c DataLink vector,
75 */
76inline
77void PackedLinkBase::setCollection (unsigned int collection)
78{
79 assert (collection <= COLLECTION_MAX);
80 m_packed = (m_packed & INDEX_MAX) | (collection << INDEX_NBITS);
81}
82
83
84/**
85 * @brief Set the element index;
86 * @param index The index of the element within the collection.
87 */
88inline
89void PackedLinkBase::setIndex (unsigned int index)
90{
91 assert (index <= INDEX_MAX);
92 m_packed = (m_packed & (COLLECTION_MAX << INDEX_NBITS)) | index;
93}
94
95
96} // namespace SG