vecmem 1.14.0
Loading...
Searching...
No Matches
host.hpp
1/* VecMem project, part of the ACTS project (R&D line)
2 *
3 * (c) 2023-2025 CERN for the benefit of the ACTS project
4 *
5 * Mozilla Public License Version 2.0
6 */
7#pragma once
8
9// Local include(s).
10#include "vecmem/edm/data.hpp"
11#include "vecmem/edm/details/host_traits.hpp"
12#include "vecmem/edm/details/schema_traits.hpp"
13#include "vecmem/edm/proxy.hpp"
14#include "vecmem/edm/schema.hpp"
15#include "vecmem/memory/memory_resource.hpp"
16#include "vecmem/utils/types.hpp"
17
18// System include(s).
19#include <cstddef>
20#include <functional>
21#include <tuple>
22
23namespace vecmem {
24namespace edm {
25
27template <typename T, template <typename> class I>
28class host;
29
39template <typename... VARTYPES, template <typename> class INTERFACE>
41
42public:
46 using size_type = std::size_t;
48 using tuple_type =
49 std::tuple<typename details::host_type<VARTYPES>::type...>;
51 template <typename T>
54 using proxy_type =
55 interface_type<proxy<schema_type, details::proxy_domain::host,
56 details::proxy_access::non_constant,
57 details::proxy_type::reference>>;
60 proxy<schema_type, details::proxy_domain::host,
61 details::proxy_access::constant, details::proxy_type::reference>>;
64 interface_type<proxy<schema_type, details::proxy_domain::host,
65 details::proxy_access::non_constant,
66 details::proxy_type::standalone>>;
67
70
72 VECMEM_HOST
73 explicit host(memory_resource& resource);
74
76
79
81 VECMEM_HOST
82 size_type size() const;
84 VECMEM_HOST
85 void resize(size_type size);
87 VECMEM_HOST
88 void reserve(size_type size);
90 VECMEM_HOST void push_back(const object_type& element);
91
93 template <std::size_t INDEX>
94 VECMEM_HOST typename details::host_type_at<INDEX, VARTYPES...>::return_type
95 get();
97 template <std::size_t INDEX>
98 VECMEM_HOST
99 typename details::host_type_at<INDEX, VARTYPES...>::const_return_type
100 get() const;
101
109 VECMEM_HOST
110 proxy_type at(size_type index);
118 VECMEM_HOST
119 const_proxy_type at(size_type index) const;
120
126 VECMEM_HOST
127 proxy_type operator[](size_type index);
133 VECMEM_HOST
134 const_proxy_type operator[](size_type index) const;
135
137
140
142 VECMEM_HOST
143 tuple_type& variables();
145 VECMEM_HOST
146 const tuple_type& variables() const;
147
149 VECMEM_HOST
150 memory_resource& resource() const;
151
153
154private:
156 tuple_type m_data;
158 std::reference_wrapper<memory_resource> m_resource;
159
160}; // class host
161
162} // namespace edm
163
171template <typename... VARTYPES, template <typename> class INTERFACE>
172VECMEM_HOST edm::data<edm::schema<VARTYPES...>> get_data(
174 memory_resource* resource = nullptr);
175
183template <typename... VARTYPES, template <typename> class INTERFACE>
184VECMEM_HOST edm::data<edm::details::add_const_t<edm::schema<VARTYPES...>>>
186 memory_resource* resource = nullptr);
187
188} // namespace vecmem
189
190// Include the implementation.
191#include "vecmem/edm/impl/host.ipp"
Technical base type for data<schema<VARTYPES...>>
Definition data.hpp:25
schema< VARTYPES... > schema_type
The schema describing the host's payload.
Definition host.hpp:44
INTERFACE< T > interface_type
The type of the interface used for the proxy objects.
Definition host.hpp:52
interface_type< proxy< schema_type, details::proxy_domain::host, details::proxy_access::non_constant, details::proxy_type::standalone > > object_type
Type type of standalone proxy objects for the container.
Definition host.hpp:66
std::tuple< typename details::host_type< VARTYPES >::type... > tuple_type
The tuple type holding all of the the individual variable vectors.
Definition host.hpp:49
interface_type< proxy< schema_type, details::proxy_domain::host, details::proxy_access::non_constant, details::proxy_type::reference > > proxy_type
The type of the (non-const) proxy objects for the container elements.
Definition host.hpp:57
interface_type< proxy< schema_type, details::proxy_domain::host, details::proxy_access::constant, details::proxy_type::reference > > const_proxy_type
The type of the (const) proxy objects for the container elements.
Definition host.hpp:61
std::size_t size_type
Size type used for the container.
Definition host.hpp:46
Technical base type for host<schema<VARTYPES...>,INTERFACE>
Definition host.hpp:28
Technical base type for proxy<schema<VARTYPES...>,PDOMAIN,PACCESS,PTYPE>
Definition proxy.hpp:21
Main namespace for the vecmem classes/functions.
Definition atomic_ref.hpp:16
VECMEM_HOST_AND_DEVICE constexpr const auto & get(const tuple< Ts... > &t) noexcept
Get a constant element out of a tuple.
Definition tuple.ipp:58
std::vector< T, vecmem::polymorphic_allocator< T > > vector
Alias type for vectors with our polymorphic allocator.
Definition vector.hpp:35
VECMEM_HOST data::vector_view< T > get_data(array< T, N > &a)
Helper function creating a vecmem::data::vector_view object.
Definition array.ipp:217
Definition host_traits.hpp:56
Meta type describing the "schema" of an SoA container.
Definition schema.hpp:46