vecmem 1.14.0
Loading...
Searching...
No Matches
jagged_vector_buffer.hpp
1/*
2 * VecMem project, part of the ACTS project (R&D line)
3 *
4 * (c) 2021-2025 CERN for the benefit of the ACTS project
5 *
6 * Mozilla Public License Version 2.0
7 */
8#pragma once
9
10// Local include(s).
11#include "vecmem/containers/data/buffer_type.hpp"
12#include "vecmem/containers/data/jagged_vector_view.hpp"
13#include "vecmem/memory/memory_resource.hpp"
14#include "vecmem/memory/unique_ptr.hpp"
15
16// System include(s).
17#include <cstddef>
18#include <memory>
19#include <type_traits>
20#include <vector>
21
22namespace vecmem {
23namespace data {
24
29template <typename TYPE>
31
32public:
40 using pointer = typename base_type::pointer;
41
44
46 static_assert(std::is_trivially_destructible<TYPE>::value,
47 "vecmem::data::jagged_vector_buffer can not handle types "
48 "with custom destructors");
51 static_assert(std::is_trivially_destructible<value_type>::value,
52 "vecmem::data::jagged_vector_buffer can not handle types "
53 "with custom destructors");
54
56
59
70 template <typename OTHERTYPE,
71 std::enable_if_t<std::is_convertible<TYPE, OTHERTYPE>::value,
72 bool> = true>
74 memory_resource& resource,
75 memory_resource* host_access_resource = nullptr,
77
88 template <typename SIZE_TYPE = std::size_t,
89 std::enable_if_t<std::is_integral<SIZE_TYPE>::value &&
90 std::is_unsigned<SIZE_TYPE>::value,
91 bool> = true>
92 jagged_vector_buffer(const std::vector<SIZE_TYPE>& capacities,
93 memory_resource& resource,
94 memory_resource* host_access_resource = nullptr,
96
99
102
103private:
105 vecmem::unique_alloc_ptr<value_type[]> m_outer_memory;
107 vecmem::unique_alloc_ptr<value_type[]> m_outer_host_memory;
109 vecmem::unique_alloc_ptr<char[]> m_inner_memory;
110
111}; // class jagged_vector_buffer
112
113} // namespace data
114
118 data::jagged_vector_buffer<TYPE>& data);
119
123 const data::jagged_vector_buffer<TYPE>& data);
124
125} // namespace vecmem
126
127// Include the implementation.
128#include "vecmem/containers/impl/jagged_vector_buffer.ipp"
Object owning all the data of a jagged vector.
Definition jagged_vector_buffer.hpp:30
typename base_type::size_type size_type
Use the base class's size_type.
Definition jagged_vector_buffer.hpp:36
jagged_vector_buffer(jagged_vector_buffer &&) noexcept=default
Move constructor.
typename base_type::value_type value_type
Use the base class's value_type.
Definition jagged_vector_buffer.hpp:38
typename base_type::pointer pointer
Pointer type to the jagged array.
Definition jagged_vector_buffer.hpp:40
jagged_vector_buffer()
Make sure that the template type does not have a custom destructor.
Definition jagged_vector_buffer.ipp:60
A view for jagged vectors.
Definition jagged_vector_view.hpp:44
std::size_t size_type
We cannot use boolean types.
Definition jagged_vector_view.hpp:52
std::add_pointer_t< value_type > pointer
Pointer type to the jagged array.
Definition jagged_vector_view.hpp:56
vector_view< TYPE > value_type
Value type of the jagged array.
Definition jagged_vector_view.hpp:54
buffer_type
"Overall type" for a buffer object
Definition buffer_type.hpp:13
@ fixed_size
The buffer has a fixed number of elements.
Main namespace for the vecmem classes/functions.
Definition atomic_ref.hpp:16
std::vector< T, vecmem::polymorphic_allocator< T > > vector
Alias type for vectors with our polymorphic allocator.
Definition vector.hpp:35
std::unique_ptr< T, details::unique_alloc_deleter< T > > unique_alloc_ptr
A unique pointer type for trivial types.
Definition unique_ptr.hpp:69
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