ATLAS Offline Software
Loading...
Searching...
No Matches
ContainerRangeGuard.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3 */
4#ifndef PHASEII_CONTAINERRANGEGUARD_H
5#define PHASEII_CONTAINERRANGEGUARD_H
6
7namespace PhaseII {
8
9// test whether the given container collection allows to ask for a new container
10template <typename T_ContainerCollection>
11concept hasDynamicContainerList = requires(T_ContainerCollection &a) { a.getNewContainerPtr(); };
12
13// test whether the given container ptr has an associated container id.
14template <typename T_ContainerPtr>
15concept hasContainerId = requires(T_ContainerPtr &a) { a.containerId(); };
16
31template <typename T_RangeType, typename T_ContainerPtr>
33public:
34 ContainerRangeGuard(T_ContainerPtr ptr) : m_ptr(ptr), m_startIndex(m_ptr->size()) {}
36 T_RangeType range() const {
37 if constexpr(hasContainerId<T_ContainerPtr>) {
38 return T_RangeType::makeDataRange(m_startIndex, m_ptr->size(),m_ptr.containerId());
39 }
40 else {
41 return T_RangeType::makeDataRange(m_startIndex, m_ptr->size(),0u);
42 }
43 }
44 std::size_t startIndex() const {
45 return m_startIndex;
46 }
47
48 T_ContainerPtr &ptr() {
49 return m_ptr;
50 }
51
52 const T_ContainerPtr &ptr() const {
53 return m_ptr;
54 }
55
57 bool empty() const {
58 return m_ptr->size() == m_startIndex;
59 }
60private:
61 T_ContainerPtr m_ptr;
62 std::size_t m_startIndex;
63};
64}
65
66#endif
static Double_t a
T_ContainerPtr & ptr()
return the pointer to the container which contains the element range of this range guard
const T_ContainerPtr & ptr() const
return the pointer to the container which contains the element range of this range guard (read only)
ContainerRangeGuard(T_ContainerPtr ptr)
T_RangeType range() const
create a range for the elements added to the container since the guard was created.
bool empty() const
return true if no elements have been added to the container since the construction of this guard.