Shortcuts

Template Class OwnedStorage

Inheritance Relationships

Base Type

Class Documentation

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

Defines an contiguous, statically allocated, storage which owns the data for the given types.

A class to create owned storage for the types defined by the template arguments.

It creates the storage as if the Ts types are stored contiguously (i.e AoS). This will create the data for the storage statically, as is done for a normal class.

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

This class owns the storage data.

Returning this from an array, or setting it from other StorageAccessor types does not allow that data to be modified, and therefore its use case is for data modification (i.e local variables), or when the storage interface is desired but an implementation which mimics traditional structs is required.

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 that 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.

This class does not have an allocator inteface, and is not intended to be allocated, but rather reutned by data containers which use ContiguousStorageView/StridedStorageView when a local copy is required, for example, when deferencing shared memory data which uses StridedStorage.

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

constexpr OwnedStorage() noexcept = default

Default constructor for the storage.

template<typename Impl>
constexpr OwnedStorage(const StorageAccessor<Impl> &from) noexcept

Constructor to set the owned storage from another type which implements the storage access interface.

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

Template Parameters

template<typename Impl>
constexpr auto operator=(const StorageAccessor<Impl> &from) noexcept -> OwnedStorage&

Overload of operator= to set the data for the owned storage from another type which implements the StorageAccessor interface.

Return

A reference to the OwnedStorage with the copied data.

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

Template Parameters

template<typename Other>
constexpr auto copy(const Other &other) noexcept -> void

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

Parameters
  • other: The other strided 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

Determines 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.

For example:

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

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

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

Gets a reference to the Ith data type.

Note

This is only enabled if the Ith type of the Ith type is not a StorageElement.

Return

A reference to the Ith type.

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>
constexpr auto get() const noexcept -> const element_value_t<T>&

Gets a const reference to the Ith data type.

Note

This is only enabled if the Ith type of the Ith type is not a StorageElement.

Return

A reference to the Ith type.

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>
constexpr 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.

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>
constexpr 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.

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>
constexpr 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.

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>
constexpr 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 size_t nth_element_components_v = 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