xentara-plugin v1.2.1
The Xentara Plugin Framework
Loading...
Searching...
No Matches
xentara::memory::Array Class Referencefinal

A helper class used to describe structure of memory containing a heterogenious array. More...

#include <memory/Array.hpp>

Classes

class  Handle
 
class  ObjectHandle
 A handle to an array element containing an object or an array of objects. More...
 

Public Types

template<ObjectType Object>
using ObjectHandleFor = ObjectHandle< typename Object::Element >
 A type alias that gets the handle type that corresponds to an object type.
 

Public Member Functions

auto appendElement (std::size_t size, std::size_t alignment=alignof(std::max_align_t)) -> Handle
 Registers a tuple.
 
template<typename Type >
auto appendObject () -> ObjectHandle< Type >
 Appends an object.
 
template<ObjectType Object>
auto appendObject () -> ObjectHandleFor< Object >
 Appends an object.
 
template<typename Type >
auto appendObjects (std::size_t count) -> ObjectHandle< Type >
 Appends an array of objects.
 
template<ObjectType Object>
auto appendObjects (std::size_t count) -> ObjectHandleFor< Object >
 Appends an array of objects.
 
auto size () const -> std::size_t
 Gets the size of the array.
 

Detailed Description

A helper class used to describe structure of memory containing a heterogenious array.

Member Typedef Documentation

◆ ObjectHandleFor

template<ObjectType Object>
using xentara::memory::Array::ObjectHandleFor = ObjectHandle<typename Object::Element>

A type alias that gets the handle type that corresponds to an object type.

Member Function Documentation

◆ appendElement()

auto xentara::memory::Array::appendElement ( std::size_t  size,
std::size_t  alignment = alignof(std::max_align_t) 
) -> Handle

Registers a tuple.

This function must be called before allocating the array. It does not actually append the data block to an existing array, but simply reserves space for it. When you then allocate the memory block for the array, a memory location is provided for the data.

Parameters
sizeThe size of the element
alignmentThe alignment of the element
Returns
A handle to the element

◆ appendObject() [1/2]

template<typename Type >
auto xentara::memory::Array::appendObject ( ) -> ObjectHandle< Type >

Appends an object.

This function must be called before allocating the array. It does not actually append the object to an existing array, but simply reserves space for it. When you then allocate the memory block for the array, a memory location is provided for the object.

Template Parameters
TypeThe C++ type of the object
Returns
A handle to the object

◆ appendObject() [2/2]

template<ObjectType Object>
auto xentara::memory::Array::appendObject ( ) -> ObjectHandleFor< Object >

Appends an object.

This function must be called before allocating the array. It does not actually append the object to an existing array, but simply reserves space for it. When you then allocate the memory block for the array, a memory location is provided for the object.

Template Parameters
ElementsThe elements of the object
Returns
A handle to the object

◆ appendObjects() [1/2]

template<typename Type >
auto xentara::memory::Array::appendObjects ( std::size_t  count) -> ObjectHandle< Type >

Appends an array of objects.

This function must be called before allocating the array. It does not actually append the objects to an existing array, but simply reserves space for it. When you then allocate the memory block for the array, a memory location is provided for the objects.

Consecutively appended arrays of the same type are allocated contiguously, so that you can access all the appended objects through any of the handles using appropriate offsets. If you call appendObjects(3) followed by appendObjects(2) with the same type, the handle returned by the first call will now point to an array of 5 ints, and the second handle will be equal to the first handle + 3. You can also call appendObjects(0) to get a handle to a zero-length array, and then call appendObjects() again to add elements to that array. This is useful if you need a handle to the array before you known how many elements you need.

Template Parameters
TypeThe C++ type of the objects
Parameters
countThe number of objects to add
Returns
A handle to the first object

◆ appendObjects() [2/2]

template<ObjectType Object>
auto xentara::memory::Array::appendObjects ( std::size_t  count) -> ObjectHandleFor< Object >

Appends an array of objects.

This function must be called before allocating the array. It does not actually append the objects to an existing array, but simply reserves space for it. When you then allocate the memory block for the array, a memory location is provided for the objects.

Consecutively appended arrays of the same type are allocated contiguously, so that you can access all the appended objects through any of the handles using appropriate offsets. If you call appendObjects(3) followed by appendObjects(2) with the same type, the handle returned by the first call will now point to an array of 5 ints, and the second handle will be equal to the first handle + 3. You can also call appendObjects(0) to get a handle to a zero-length array, and then call appendObjects() again to add elements to that array. This is useful if you need a handle to the array before you known how many elements you need.

Template Parameters
ElementsThe elements of the object
Parameters
countThe number of objects to add
Returns
A handle to the first object

◆ size()

auto xentara::memory::Array::size ( ) const -> std::size_t

Gets the size of the array.