vecmem 1.21.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
74
76 VECMEM_HOST
77 explicit host(memory_resource& resource);
78
80
83
85 VECMEM_HOST
86 size_type size() const;
88 VECMEM_HOST
89 size_type capacity() const;
91 VECMEM_HOST
92 void resize(size_type size);
94 VECMEM_HOST
95 void reserve(size_type size);
97 VECMEM_HOST void push_back(const object_type& element);
98
100 template <std::size_t INDEX>
101 VECMEM_HOST typename details::host_type_at<INDEX, VARTYPES...>::return_type
102 get();
104 template <std::size_t INDEX>
105 VECMEM_HOST
106 typename details::host_type_at<INDEX, VARTYPES...>::const_return_type
107 get() const;
108
116 VECMEM_HOST
117 proxy_type at(size_type index);
125 VECMEM_HOST
126 const_proxy_type at(size_type index) const;
127
133 VECMEM_HOST
134 proxy_type operator[](size_type index);
140 VECMEM_HOST
141 const_proxy_type operator[](size_type index) const;
142
144
147
149 VECMEM_HOST
150 tuple_type& variables();
152 VECMEM_HOST
153 const tuple_type& variables() const;
154
156 VECMEM_HOST
157 memory_resource& resource() const;
158
160
161private:
163 tuple_type m_data;
165 std::reference_wrapper<memory_resource> m_resource;
166
167}; // class host
168
169} // namespace edm
170
178template <typename... VARTYPES, template <typename> class INTERFACE>
179VECMEM_HOST edm::data<edm::schema<VARTYPES...>> get_data(
181 memory_resource* resource = nullptr);
182
190template <typename... VARTYPES, template <typename> class INTERFACE>
191VECMEM_HOST edm::data<edm::details::add_const_t<edm::schema<VARTYPES...>>>
193 memory_resource* resource = nullptr);
194
195} // namespace vecmem
196
197// Include the implementation.
198#include "vecmem/edm/impl/host.ipp"
An allocator class that wraps a memory resource.
Definition allocator.hpp:37
Technical base type for data<schema<VARTYPES...>>
Definition data.hpp:25
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
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
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:58
Meta type describing the "schema" of an SoA container.
Definition schema.hpp:46