Shortcuts

Template Class ContiguousStorageView

Nested Relationships

Inheritance Relationships

Base Type

Class Documentation

template<typename ...Ts>
class ripple::ContiguousStorageView : public ripple::StorageAccessor<ContiguousStorageView<Ts...>>

Implementation of contiguous view storage.

A type for view storage for the types defined by the template arguments.

The view is created as if the Ts types are stored contiguously (i.e AoS), where the view points to an element in large array where the components of the array look like classes with Ts as their members. Again, this is Aos layout (i.e, how data would usually be allocated).

Template Parameters
  • Ts: The types to create a storage view for.

For example, given Ts = int, float, double, this would create storage as follows:

.---------------------------------------------------.
|      element 0       | ... |     element N -1     |
.---------------------------------------------------.
| int | float | double | ... | int | float | double |
'---------------------------------------------------'

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 contiguous (i.e as Aos), and also contiguous with the types on either side of the Vector in the Ts pack.

To allocate multiple ContiguousStorageiView elements, the Allocator type should be used to determine the memory requirement, and then a ContiguousStorageView 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. If they are not ordered, this will still allocate and align the types correctly, however, the alignment might result in padding which could add a lot of unnecessary data. This behaviour mimics what the compiler would do, so following best practices and ensuring that larger types are placed first will ensure the minimum size of each element.

Sorting can’t be added because it will cause the get interface to break, since it relies on knowing the order of the types, which are specified by the user. Sorting would mean that the user would not know the order, and would have to provide the type as the index to get, which is not so nice.

Template Parameters
  • Ts: The types to create storage for.

Public Functions

ContiguousStorageView() noexcept = default

Default constructor for the contguous storage.

template<typename Impl>
ContiguousStorageView(const StorageAccessor<Impl> &other) noexcept

Set the contiguous storage from a type which implements the StorageAccess interface.

Note

This will fail at compile time if Impl doesn’t implement the StorageAccessor interface,

See

StorageAccessor.

Parameters
  • other: The accessor to copy the data from.

Template Parameters

ContiguousStorageView(const ContiguousStorageView &other) noexcept = default

Copy constructor to set the storage from the other storage.

Parameters
  • other: The other storage to set this one from.

ContiguousStorageView(ContiguousStorageView &&other) noexcept = default

Move constructor to move the other storage into this one.

Parameters
  • other: The other storage to move into this one.

template<typename Impl>
auto operator=(const StorageAccessor<Impl> &other) noexcept -> ContiguousStorageView&

Overload of operator= to set the data for the ContiguousStorageView from a type which implements the StorageAccessor interface.

Note

This will fail at compile time if Impl doesn’t implement the StorageAccessor interface,

See

StorageAccessor.

Return

A reference to the newly created storage.

Parameters
  • other: The accessor to copy the data from.

Template Parameters

auto operator=(const ContiguousStorageView &other) noexcept -> ContiguousStorageView&

Overload of assignment operator to set the data for the stprage from the other storage.

Return

A reference to the newly created storage.

Parameters
  • other: The other storage to copy into this one.

auto operator=(ContiguousStorageView &&other) noexcept -> ContiguousStorageView&

Overload of assignment operator to set the data for the stprage from the other storage.

Return

A reference to the newly created storage.

Parameters
  • other: The other storage to copy into this one.

auto data() noexcept -> void*

Gets a pointer to the data for the storage.

Return

A pointer to the data for the storage.

auto data() const noexcept -> const void*

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>
auto copy(const Other &other) noexcept -> void

Copies the data from the other type which must implement the StorageAccessor interface.

Note

The will assert at compile time if other does not implement the StorageAccessor interface.

Parameters
  • other: The other contiguous view to copy from.

Template Parameters
  • Other: The type of the other storage to copy from.

template<size_t I>
constexpr auto components_of() const noexcept -> size_t

Gets the number of components in the Ith type being stored.

For non-indexable types this will always return 1, otherwise it will return the number of possible components which can be indexed.

For example:

// Returns 1 -- only 1 type:
ContiguousStorageView<int>().conponents_of<0>();

struct A : StridableLayout<A> {
 using descriptor_t = StorageElement<int, 4>;
};
// Returns 4:
ContiguousStorageView<A>().components_of<0>();

Return

The number of components in the type I.

Template Parameters
  • I: The index of the type to get the number of components for.

template<size_t I, typename T = nth_element_t<I, Ts...>, non_vec_element_enable_t<T> = 0>
auto get() noexcept -> element_value_t<T>&

Gets a reference to the Ith data type.

Note

This will only be enabled when the type of the Ith type is not a StorageElement<>.

Note

All offsetting calculations are performed at compile time.

Return

A reference to the Ith type, if the type is not a StorageElement.

Template Parameters
  • I: The index of the type to get the data from.

  • T: The type of the Ith element.

template<size_t I, typename T = nth_element_t<I, Ts...>, non_vec_element_enable_t<T> = 0>
auto get() const noexcept -> const element_value_t<T>&

Gets a const reference to the Ith data type.

Note

This will only be enabled when the type of the Ith type is not a StorageElement<>.

Note

All offsetting calculations are performed at compile time.

Return

A const reference to the Ith type, if the type is not a StorageElement.

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_t J, typename T = nth_element_t<I, Ts...>, vec_element_enable_t<T> = 0>
auto get() noexcept -> element_value_t<T>&

Gets a reference to the Jth element of the Ith data type.

Note

This will only be enabled when the type of the Ith type is a StorageElement<> so that the call to operator[] on the Ith type is valid.

Note

All offsetting calculations are performed at compile time.

Return

A 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, size_t J, typename T = nth_element_t<I, Ts...>, vec_element_enable_t<T> = 0>
auto get() const noexcept -> const element_value_t<T>&

Gets a const reference to the Jth element of the Ith data type.

Note

This will only be enabled when the type of the Ith type is a StorageElement<> so that the call to operator[] on the Ith type is valid.

Note

All offsetting calculations are performed at compile time.

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, typename T = nth_element_t<I, Ts...>, vec_element_enable_t<T> = 0>
auto get(size_t j) noexcept -> element_value_t<T>&

Gets a reference to the jth element of the Ith data type.

Note

This will only be enabled when the type of the Ith type is a StorageElement<> so that the call to operator[] on the Ith type is valid.

Note

The offset of j is performed at runtime.

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, typename T = nth_element_t<I, Ts...>, vec_element_enable_t<T> = 0>
auto get(size_t j) const noexcept -> const element_value_t<T>&

Gets a const reference to the jth element of the Ith data type.

Note

This will only be enabled when the type of the Ith type is a StorageElement<> so that the call to operator[] on the Ith type is valid.

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 auto nth_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 component to get the number of elements for.

Docs

Access comprehensive developer documentation for Ripple

View Docs

Tutorials

Get tutorials to help with understand all features

View Tutorials

Examples

Find examples to help get started

View Examples