Skip to content

Commit ed3b68c

Browse files
committed
detail
1 parent a885c7f commit ed3b68c

File tree

2 files changed

+73
-42
lines changed

2 files changed

+73
-42
lines changed

Core/include/Acts/EventData/SpacePointContainer2.hpp

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include "Acts/EventData/SourceLink.hpp"
1212
#include "Acts/EventData/Types.hpp"
13+
#include "Acts/EventData/detail/SpacePointContainer2Column.hpp"
1314
#include "Acts/Utilities/EnumBitwiseOperators.hpp"
1415
#include "Acts/Utilities/TypeTraits.hpp"
1516
#include "Acts/Utilities/Zip.hpp"
@@ -874,50 +875,11 @@ class SpacePointContainer2 {
874875
columns.data().subspan(range.first, range.second)...);
875876
}
876877

877-
class ColumnHolderBase {
878-
public:
879-
virtual ~ColumnHolderBase() = default;
880-
881-
virtual std::unique_ptr<ColumnHolderBase> copy() const = 0;
882-
883-
virtual std::size_t size() const = 0;
884-
virtual void reserve(std::size_t size) = 0;
885-
virtual void resize(std::size_t size) = 0;
886-
virtual void clear() = 0;
887-
virtual void emplace_back() = 0;
888-
};
889-
878+
private:
879+
using ColumnHolderBase = detail::sp::ColumnHolderBase;
890880
template <typename T>
891-
class ColumnHolder final : public ColumnHolderBase {
892-
public:
893-
using Value = T;
894-
using Container = std::vector<Value>;
895-
using Proxy = SpacePointColumnProxy<Value>;
881+
using ColumnHolder = detail::sp::ColumnHolder<T>;
896882

897-
ColumnHolder() = default;
898-
explicit ColumnHolder(Value defaultValue)
899-
: m_default(std::move(defaultValue)) {}
900-
901-
Proxy proxy(const SpacePointContainer2 &container) const {
902-
return Proxy(container, m_data);
903-
}
904-
905-
std::unique_ptr<ColumnHolderBase> copy() const override {
906-
return std::make_unique<ColumnHolder<T>>(*this);
907-
}
908-
909-
std::size_t size() const override { return m_data.size(); }
910-
void reserve(std::size_t size) override { m_data.reserve(size); }
911-
void clear() override { m_data.clear(); }
912-
void resize(std::size_t size) override { m_data.resize(size, m_default); }
913-
void emplace_back() override { m_data.emplace_back(m_default); }
914-
915-
private:
916-
Value m_default{};
917-
Container m_data;
918-
};
919-
920-
private:
921883
std::uint32_t m_size{0};
922884

923885
std::unordered_map<
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// This file is part of the ACTS project.
2+
//
3+
// Copyright (C) 2016 CERN for the benefit of the ACTS project
4+
//
5+
// This Source Code Form is subject to the terms of the Mozilla Public
6+
// License, v. 2.0. If a copy of the MPL was not distributed with this
7+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
8+
9+
#pragma once
10+
11+
#include <memory>
12+
#include <vector>
13+
14+
namespace Acts::Experimental {
15+
16+
class SpacePointContainer2;
17+
template <typename T>
18+
class SpacePointColumnProxy;
19+
20+
namespace detail::sp {
21+
22+
// These classes should have gone into `SpacePointContainer2` but a compiler bug
23+
// prevents that
24+
25+
class ColumnHolderBase {
26+
public:
27+
virtual ~ColumnHolderBase() = default;
28+
29+
virtual std::unique_ptr<ColumnHolderBase> copy() const = 0;
30+
31+
virtual std::size_t size() const = 0;
32+
virtual void reserve(std::size_t size) = 0;
33+
virtual void resize(std::size_t size) = 0;
34+
virtual void clear() = 0;
35+
virtual void emplace_back() = 0;
36+
};
37+
38+
template <typename T>
39+
class ColumnHolder final : public ColumnHolderBase {
40+
public:
41+
using Value = T;
42+
using Container = std::vector<Value>;
43+
using Proxy = SpacePointColumnProxy<Value>;
44+
45+
ColumnHolder() = default;
46+
explicit ColumnHolder(Value defaultValue)
47+
: m_default(std::move(defaultValue)) {}
48+
49+
Proxy proxy(const SpacePointContainer2 &container) const {
50+
return Proxy(container, m_data);
51+
}
52+
53+
std::unique_ptr<ColumnHolderBase> copy() const override {
54+
return std::make_unique<detail::sp::ColumnHolder<T>>(*this);
55+
}
56+
57+
std::size_t size() const override { return m_data.size(); }
58+
void reserve(std::size_t size) override { m_data.reserve(size); }
59+
void clear() override { m_data.clear(); }
60+
void resize(std::size_t size) override { m_data.resize(size, m_default); }
61+
void emplace_back() override { m_data.emplace_back(m_default); }
62+
63+
private:
64+
Value m_default{};
65+
Container m_data;
66+
};
67+
68+
} // namespace detail::sp
69+
} // namespace Acts::Experimental

0 commit comments

Comments
 (0)