Warning, file /acts/Core/include/Acts/EventData/detail/SpacePointContainerColumn.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include <memory>
0012 #include <vector>
0013
0014 namespace Acts {
0015
0016 class SpacePointContainer;
0017 template <typename T, bool read_only>
0018 class SpacePointColumnProxy;
0019 template <typename T>
0020 using MutableSpacePointColumnProxy = SpacePointColumnProxy<T, false>;
0021 template <typename T>
0022 using ConstSpacePointColumnProxy = SpacePointColumnProxy<T, true>;
0023
0024 namespace detail::sp {
0025
0026
0027
0028
0029 class ColumnHolderBase {
0030 public:
0031 virtual ~ColumnHolderBase() = default;
0032
0033 virtual std::unique_ptr<ColumnHolderBase> copy() const = 0;
0034
0035 virtual std::size_t size() const = 0;
0036 virtual void reserve(std::size_t size) = 0;
0037 virtual void resize(std::size_t size) = 0;
0038 virtual void clear() = 0;
0039 virtual void emplace_back() = 0;
0040 virtual void copyFrom(const ColumnHolderBase &source, std::size_t sourceIndex,
0041 std::size_t destinationIndex) = 0;
0042 };
0043
0044 template <typename T>
0045 class ColumnHolder : public ColumnHolderBase {
0046 public:
0047 using Value = T;
0048 using Container = std::vector<Value>;
0049 using MutableProxy = MutableSpacePointColumnProxy<Value>;
0050 using ConstProxy = ConstSpacePointColumnProxy<Value>;
0051
0052 ColumnHolder() = default;
0053 explicit ColumnHolder(Value defaultValue)
0054 : m_default(std::move(defaultValue)) {}
0055
0056 MutableProxy proxy(SpacePointContainer &container) {
0057 return MutableProxy(container, m_data);
0058 }
0059 ConstProxy proxy(const SpacePointContainer &container) const {
0060 return ConstProxy(container, m_data);
0061 }
0062
0063 std::unique_ptr<ColumnHolderBase> copy() const final {
0064 return std::make_unique<ColumnHolder<T>>(*this);
0065 }
0066
0067 std::size_t size() const final { return m_data.size(); }
0068 void reserve(std::size_t size) final { m_data.reserve(size); }
0069 void clear() final { m_data.clear(); }
0070 void resize(std::size_t size) final { m_data.resize(size, m_default); }
0071 void emplace_back() final { m_data.emplace_back(m_default); }
0072 void copyFrom(const ColumnHolderBase &source, std::size_t sourceIndex,
0073 std::size_t destinationIndex) final {
0074 const auto &typedSource = static_cast<const ColumnHolder<T> &>(source);
0075 m_data[destinationIndex] = typedSource.m_data[sourceIndex];
0076 }
0077
0078 private:
0079 Value m_default{};
0080 Container m_data;
0081 };
0082
0083 }
0084 }