Template Class StridedStorageView¶
Defined in File storage_traits.hpp
Class Documentation¶
-
template<typename ...
Ts
>
classripple
::
StridedStorageView
¶ A view storage class for the types defined by the template arguments.
Defines a view into strided storage for Ts types.
It creates the view into storage as if the Ts types are stored strided (i.e SoA), where the view points to an element in which is effectively multiple arrays, each of which is one of the Ts types. Again, this is SoA layout.
Since this is a view type storage, it does not own the underlying data, it just references data which has been allocated with the appropriate layout.
It provides access to the types via the StorageAccessor interface.
If any of the Ts are Vector<T, V> types, then this will provide storage such each of the V components of the element are strided (i.e as SoA).
To allocate multiple StridedStorageiView elements, the Allocator type should be used to determine the memory requirement, and then a StridedStorageView can be created through the allocator, as also offset through the allocator.
Currently, this requires that the Ts be ordered in descending alignment size, as there is no functionality to sort the types. This may be added in the future, but the compile time overhead of performing a sort of the types based on their required alignments is significant.
The data for this class is stided in that each element of a multi-element type his offset by the stride of the zero dimension, which is the number of elements in the zero dimension, including padding.
- Template Parameters
Ts
: The types to create a storage view for.
- Template Parameters
Ts
: The types to create a storage view for.
Public Functions
-
StridedStorageView
() = default¶ Default constructor for the strided storage.
-
template<typename
Impl
>StridedStorageView
(const StorageAccessor<Impl> &other) noexcept¶ Constructor to set the strided storage from another StorageAccessor with a different layout.
- Parameters
other
: The accessor to set this storage from.
- Template Parameters
Impl
: The implementation of the StorageAccessor.
-
StridedStorageView
(const StridedStorageView &other) noexcept¶ Copy constructor to set the strided storage from the other storage.
- Parameters
other
: The other storage to set this one from.
-
StridedStorageView
(StridedStorageView &&other) noexcept¶ Move constructor to move the other storage into this one.
- Parameters
other
: The other storage to move into this one.
-
template<typename
Impl
>
autooperator=
(const StorageAccessor<Impl> &other) noexcept -> StridedStorageView&¶ Overload of assignment operator to set the data for the StridedStorageView from another StorageAccessor.
- Return
A reference to the created storage view.
- Parameters
other
: The accessor to copy the data from.
- Template Parameters
Impl
: The implementation of the StorageAccessor.
-
auto
operator=
(const StridedStorageView &other) noexcept -> StridedStorageView&¶ Overload of assignment operator to set the data for the StridedStorageView from another StridedStorageView.
- Return
A reference to the created storage view.
- Parameters
other
: The strided storage to copy from.
-
auto
operator=
(StridedStorageView &&other) noexcept -> StridedStorageView&¶ Overload of move assignment operator to move the other strided view into this one.
- Return
A reference to the created storage view.
- Parameters
other
: The strided storage to move from.
-
auto
data
() noexcept -> Ptr¶ Gets a pointer to the data for the storage.
- Return
A pointer to the data for the storage.
-
auto
data
() const noexcept -> ConstPtr¶ Gets a const pointer to the data.
- Return
A const pointer to the data for the storage.
-
auto
data_ptrs
() noexcept -> std::vector<Ptr>¶ Returns a reference to the data pointers for the storage.
-
template<typename
Other
>
autocopy
(const Other &other) noexcept -> void¶ Copies the data from the other type.
- Note
If the other type is not a StorageAccessor, this will cause a compile time error.
- Parameters
other
: The other storage to copy from.
- Template Parameters
Other
: The type of the other storage to copy from.
-
template<size_t
I
>
constexpr autocomponents_of
() const noexcept -> size_t¶ Returns the number of components in the Ith type being stored.
For non-indexable types this will always return 1, otherwise will return the number of possible components which can be indexed.
- Return
The number of components in the Ith type.
- Template Parameters
I
: The index of the type to get the number of components for.
-
template<size_t
I
, typenameT
= nth_element_t<I, Ts...>, non_vec_element_enable_t<T> = 0>
autoget
() noexcept -> element_value_t<T>&¶ Gets a reference to the Ith data type.
- Return
A reference to the Ith element.
- Template Parameters
I
: The index of the type to get the data from.T
: The type of the Ith element.
-
template<size_t
I
, typenameT
= nth_element_t<I, Ts...>, non_vec_element_enable_t<T> = 0>
autoget
() const noexcept -> const element_value_t<T>&¶ Gets a const reference to the Ith data type.
- Return
A const reference to the Ith element.
- Template Parameters
I
: The index of the type to get the data from.T
: The type of the Ith element.
-
template<size_t
I
, size_tJ
, typenameT
= nth_element_t<I, Ts...>, vec_element_enable_t<T> = 0>
autoget
() noexcept -> element_value_t<T>&¶ Gets a reference to the Jth element of the Ith data type, if the Ith type is indexable.
- Return
A reference to the Jth element in the Ith type.
- Template Parameters
I
: The index of the type to get the data from.J
: The index in the type to get.T
: The type of the Ith element.
-
template<size_t
I
, size_tJ
, typenameT
= nth_element_t<I, Ts...>, vec_element_enable_t<T> = 0>
autoget
() const noexcept -> const element_value_t<T>&¶ Gets a const reference to the Jth element of the Ith data type, if the Ith type is indexable.
- Return
A const reference to the Jth element of the Ith type.
- Template Parameters
I
: The index of the type to get the data from.J
: The index in the type to get.T
: The type of the Ith element.
-
template<size_t
I
, typenameT
= nth_element_t<I, Ts...>, vec_element_enable_t<T> = 0>
autoget
(size_t j) noexcept -> element_value_t<T>&¶ Gets a reference to the jth element of the Ith data type, if the Ith type is indexable.
- Return
A reference to the jth element of the Ith type.
- Parameters
j
: The index of the component in the type to get.
- Template Parameters
I
: The index of the type to get the data from.T
: The type of the Ith element.
-
template<size_t
I
, typenameT
= nth_element_t<I, Ts...>, vec_element_enable_t<T> = 0>
autoget
(size_t j) const noexcept -> const element_value_t<T>&¶ Gets a const reference to the jth element of the Ith data type, if the Ith type is indexable.
- Return
A const reference to the jth element of the Ith type.
- Parameters
j
: The index of the component in the type to get.
- Template Parameters
I
: The index of the type to get the data from.T
: The type of the Ith element.
Public Static Attributes
-
template<size_t
I
>
constexpr size_tnth_element_components
= element_components<nth_element_t<I, Ts...>>¶ Gets the number of components for the nth element.
- Template Parameters
I
: The index of the element to get the number of components for.