File indexing completed on 2025-08-03 07:47:59
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/EventData/Types.hpp"
0012 #include "Acts/Utilities/ContainerSubset.hpp"
0013 #include "Acts/Utilities/TypeTraits.hpp"
0014
0015 #include <cassert>
0016 #include <span>
0017 #include <vector>
0018
0019 namespace Acts::Experimental {
0020
0021 class SpacePointContainer2;
0022
0023
0024
0025 template <typename T, bool read_only>
0026 class SpacePointColumnProxy {
0027 public:
0028 constexpr static bool ReadOnly = read_only;
0029 using Index = SpacePointIndex2;
0030 using IndexRange = SpacePointIndexRange2;
0031 using IndexSubset = SpacePointIndexSubset2;
0032 using Value = T;
0033 using Container = const_if_t<ReadOnly, SpacePointContainer2>;
0034 using Column = const_if_t<ReadOnly, std::vector<Value>>;
0035
0036
0037
0038
0039 SpacePointColumnProxy(Container &container, Column &column)
0040 : m_container{&container}, m_column(&column) {}
0041
0042
0043
0044 SpacePointColumnProxy(const SpacePointColumnProxy &other) noexcept = default;
0045
0046
0047
0048 explicit SpacePointColumnProxy(
0049 const SpacePointColumnProxy<T, false> &other) noexcept
0050 requires ReadOnly
0051 : m_container(&other.container()), m_column(&other.column()) {}
0052
0053
0054
0055 SpacePointColumnProxy<T, true> asConst() const noexcept
0056 requires(!ReadOnly)
0057 {
0058 return {*m_container, *m_column};
0059 }
0060
0061
0062
0063 SpacePointContainer2 &container() noexcept
0064 requires(!ReadOnly)
0065 {
0066 return *m_container;
0067 }
0068
0069
0070 const SpacePointContainer2 &container() const noexcept {
0071 return *m_container;
0072 }
0073
0074
0075
0076 const std::vector<Value> &column() const noexcept { return *m_column; }
0077
0078
0079
0080 std::span<Value> data() noexcept
0081 requires(!ReadOnly)
0082 {
0083 return std::span<Value>(column().data(), column().size());
0084 }
0085
0086
0087 std::span<const Value> data() const noexcept {
0088 return std::span<const Value>(column().data(), column().size());
0089 }
0090
0091
0092
0093
0094
0095
0096 Value &at(Index index)
0097 requires(!ReadOnly)
0098 {
0099 if (index >= column().size()) {
0100 throw std::out_of_range("Index out of range in SpacePointContainer2: " +
0101 std::to_string(index) +
0102 " >= " + std::to_string(size()));
0103 }
0104 return data()[index];
0105 }
0106
0107
0108
0109
0110
0111 const Value &at(Index index) const {
0112 if (index >= column().size()) {
0113 throw std::out_of_range("Index out of range in SpacePointContainer2: " +
0114 std::to_string(index) +
0115 " >= " + std::to_string(size()));
0116 }
0117 return data()[index];
0118 }
0119
0120
0121
0122
0123 Value &operator[](Index index) noexcept
0124 requires(!ReadOnly)
0125 {
0126 assert(index < column().size() && "Index out of bounds");
0127 return data()[index];
0128 }
0129
0130
0131
0132 const Value &operator[](Index index) const noexcept {
0133 assert(index < column().size() && "Index out of bounds");
0134 return data()[index];
0135 }
0136
0137 using Subset = ContainerSubset<Column, Value, Index, ReadOnly>;
0138
0139 Subset subset(const IndexSubset &subset) const noexcept {
0140 return Subset(*m_column, subset);
0141 }
0142
0143 private:
0144 Container *m_container{};
0145 Column *m_column{};
0146
0147 std::uint32_t size() const noexcept { return column().size(); }
0148
0149 std::vector<Value> &column() noexcept
0150 requires(!ReadOnly)
0151 {
0152 return *m_column;
0153 }
0154
0155 friend class SpacePointContainer2;
0156 };
0157
0158 template <typename T>
0159 using ConstSpacePointColumnProxy = SpacePointColumnProxy<T, true>;
0160 template <typename T>
0161 using MutableSpacePointColumnProxy = SpacePointColumnProxy<T, false>;
0162
0163 }