File indexing completed on 2026-07-26 08:21:58
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010
0011 #include "traccc/definitions/qualifiers.hpp"
0012 #include "traccc/edm/details/device_container.hpp"
0013 #include "traccc/edm/details/host_container.hpp"
0014 #include "traccc/utils/type_traits.hpp"
0015
0016
0017 #include <vecmem/containers/data/jagged_vector_buffer.hpp>
0018 #include <vecmem/containers/data/jagged_vector_data.hpp>
0019 #include <vecmem/containers/data/jagged_vector_view.hpp>
0020 #include <vecmem/containers/data/vector_buffer.hpp>
0021 #include <vecmem/containers/data/vector_view.hpp>
0022 #include <vecmem/containers/device_vector.hpp>
0023 #include <vecmem/containers/vector.hpp>
0024
0025
0026 #include <type_traits>
0027
0028 namespace traccc {
0029
0030
0031
0032
0033
0034 template <typename header_t, typename item_t>
0035 struct container_data {
0036 using header_vector = vecmem::data::vector_view<header_t>;
0037 using item_vector = vecmem::data::jagged_vector_data<item_t>;
0038 header_vector headers;
0039 item_vector items;
0040 };
0041
0042
0043 template <typename header_t, typename item_t>
0044 struct container_buffer {
0045 using header_vector = vecmem::data::vector_buffer<header_t>;
0046 using item_vector = vecmem::data::jagged_vector_buffer<item_t>;
0047 header_vector headers;
0048 item_vector items;
0049 };
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063 template <typename header_t, typename item_t>
0064 struct container_view {
0065
0066 using header_vector = vecmem::data::vector_view<header_t>;
0067
0068 using item_vector = vecmem::data::jagged_vector_view<item_t>;
0069
0070
0071 template <
0072 typename other_header_t, typename other_item_t,
0073 std::enable_if_t<details::is_same_nc<header_t, other_header_t>::value,
0074 bool> = true,
0075 std::enable_if_t<details::is_same_nc<item_t, other_item_t>::value, bool> =
0076 true>
0077 container_view(const container_data<other_header_t, other_item_t>& data)
0078 : headers(data.headers), items(data.items) {}
0079
0080
0081 template <
0082 typename other_header_t, typename other_item_t,
0083 std::enable_if_t<details::is_same_nc<header_t, other_header_t>::value,
0084 bool> = true,
0085 std::enable_if_t<details::is_same_nc<item_t, other_item_t>::value, bool> =
0086 true>
0087 container_view(const container_buffer<other_header_t, other_item_t>& buffer)
0088 : headers(buffer.headers), items(buffer.items) {}
0089
0090
0091 template <
0092 typename other_header_t, typename other_item_t,
0093 std::enable_if_t<details::is_same_nc<header_t, other_header_t>::value,
0094 bool> = true,
0095 std::enable_if_t<details::is_same_nc<item_t, other_item_t>::value, bool> =
0096 true>
0097 container_view(const container_view<other_header_t, other_item_t>& parent)
0098 : headers(parent.headers), items(parent.items) {}
0099
0100
0101 header_vector headers;
0102
0103
0104 item_vector items;
0105 };
0106
0107
0108
0109 template <typename header_t, typename item_t>
0110 inline container_data<header_t, item_t> get_data(
0111 host_container<header_t, item_t>& cc,
0112 vecmem::memory_resource* resource = nullptr) {
0113 return {{vecmem::get_data(cc.get_headers())},
0114 {vecmem::get_data(cc.get_items(), resource)}};
0115 }
0116
0117
0118 template <typename header_t, typename item_t>
0119 inline container_data<const header_t, const item_t> get_data(
0120 const host_container<header_t, item_t>& cc,
0121 vecmem::memory_resource* resource = nullptr) {
0122 return {{vecmem::get_data(cc.get_headers())},
0123 {vecmem::get_data(cc.get_items(), resource)}};
0124 }
0125
0126
0127 template <typename item_t>
0128 struct collection_types {
0129
0130 static_assert(std::is_const<item_t>::value == false,
0131 "The template parameter must not be a constant type");
0132
0133
0134 using host = vecmem::vector<item_t>;
0135
0136 using device = vecmem::device_vector<item_t>;
0137
0138 using const_device = vecmem::device_vector<const item_t>;
0139
0140
0141 using view = vecmem::data::vector_view<item_t>;
0142
0143 using const_view = vecmem::data::vector_view<const item_t>;
0144
0145
0146 using buffer = vecmem::data::vector_buffer<item_t>;
0147
0148 };
0149
0150
0151 template <typename header_t, typename item_t>
0152 struct container_types {
0153
0154 static_assert(std::is_const<header_t>::value == false,
0155 "The header type must not be constant");
0156
0157 static_assert(std::is_const<item_t>::value == false,
0158 "The item type must not be constant");
0159
0160
0161 using host = host_container<header_t, item_t>;
0162
0163 using device = device_container<header_t, item_t>;
0164
0165 using const_device = device_container<const header_t, const item_t>;
0166
0167
0168 using view = container_view<header_t, item_t>;
0169
0170 using const_view = container_view<const header_t, const item_t>;
0171
0172
0173 using data = container_data<header_t, item_t>;
0174
0175 using const_data = container_data<const header_t, const item_t>;
0176
0177
0178 using buffer = container_buffer<header_t, item_t>;
0179
0180 };
0181
0182 }