ATLAS Offline Software
Loading...
Searching...
No Matches
PackedLinkImpl.h
Go to the documentation of this file.
1// This file's extension implies that it's C, but it's really -*- C++ -*-.
2/*
3 * Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration.
4 */
15
16
17#ifndef ATHCONTAINERS_PACKEDLINKIMPL_H
18#define ATHCONTAINERS_PACKEDLINKIMPL_H
19
20
21#ifndef XAOD_STANDALONE
23#endif
24#include "CxxUtils/ones.h"
25#include <concepts>
26#include <cstdint>
27#include <cassert>
28
29
30namespace SG {
31
32
47{
48 static constexpr unsigned NBITS = 32;
49 static constexpr unsigned COLLECTION_NBITS = 8;
50 static constexpr unsigned INDEX_NBITS = NBITS - COLLECTION_NBITS;
52 static constexpr uint32_t INDEX_MAX = CxxUtils::ones<uint32_t> (INDEX_NBITS);
53
60
61
67 PackedLinkBase (unsigned int collection, unsigned int index);
68
69
74 bool operator== (const PackedLinkBase& other) const;
75
76
80 unsigned int collection() const;
81
82
86 unsigned int index() const;
87
88
93 void setCollection (unsigned int collection);
94
95
100 void setIndex (unsigned int index);
101
102
103private:
105 uint32_t m_packed;
106};
107
108
114template <class STORABLE>
115#ifndef XAOD_STANDALONE
116// To be usable as a packed link, the index must be integral.
117requires (std::integral<typename SG::ElementLinkTraits<STORABLE>::IndexingPolicy::index_type>)
118#endif
120 : public PackedLinkBase
121{
122public:
124};
125
126
127} // namespace SG
128
129
131
132
133#endif // not ATHCONTAINERS_PACKEDLINKIMPL_H
Determine dependent types for ElementLink classes.
constexpr T ones(unsigned int n)
Return a bit mask with the lower n bits set.
Definition ones.h:25
Forward declaration.
Definition index.py:1
Construct a bit mask.
PackedLinkBase()
Default constructor.
bool operator==(const PackedLinkBase &other) const
Comparison.
static constexpr uint32_t INDEX_MAX
unsigned int collection() const
Unpack the collection index from the link.
unsigned int index() const
Unpack the element index from the link.
static constexpr unsigned INDEX_NBITS
PackedLinkBase(unsigned int collection, unsigned int index)
Constructor.
void setIndex(unsigned int index)
Set the element index;.
uint32_t m_packed
The packed form of the link.
static constexpr uint32_t COLLECTION_MAX
static constexpr unsigned COLLECTION_NBITS
static constexpr unsigned NBITS
void setCollection(unsigned int collection)
Set the collection index;.