Gaia-ECS v1.0.0
A simple and powerful entity component system
Loading...
Searching...
No Matches
gaia::mem::data_view_policy_aos< ValueType > Struct Template Reference

View policy for accessing and storing data in the AoS way. Good for random access and when accessing data that needs to be close together. More...

#include <data_layout_policy.h>

+ Inheritance diagram for gaia::mem::data_view_policy_aos< ValueType >:

Public Types

using TargetCastType = std::add_pointer_t< ValueType >
 Pointer type used to address stored values.
 

Static Public Member Functions

static GAIA_NODISCARD constexpr uint32_t get_min_byte_size (uintptr_t addr, size_t cnt) noexcept
 Calculates the bytes required for a value range.
 
template<typename Allocator >
static GAIA_NODISCARD uint8_t * alloc (size_t cnt) noexcept
 Allocates and default-constructs an AoS value range.
 
template<typename Allocator >
static void free (void *pData, size_t cap, size_t cnt) noexcept
 Destroys and releases an instrumented AoS value range.
 
template<typename Allocator >
static void free (void *pData, size_t cnt) noexcept
 Destroys and releases an AoS value range.
 
GAIA_NODISCARD static constexpr ValueType get_value (std::span< const ValueType > s, size_t idx) noexcept
 Copies a value from an AoS span.
 
GAIA_NODISCARD static constexpr const ValueType & get (std::span< const ValueType > s, size_t idx) noexcept
 Returns a read-only value reference from an AoS span.
 
GAIA_NODISCARD static constexpr ValueType & set (std::span< ValueType > s, size_t idx) noexcept
 Returns a mutable value reference from an AoS span.
 

Static Public Attributes

static constexpr DataLayout Layout = data_layout_properties<DataLayout::AoS, ValueType>::Layout
 Physical layout.
 
static constexpr size_t Alignment = data_layout_properties<DataLayout::AoS, ValueType>::Alignment
 Required byte alignment.
 

Detailed Description

template<typename ValueType>
struct gaia::mem::data_view_policy_aos< ValueType >

View policy for accessing and storing data in the AoS way. Good for random access and when accessing data that needs to be close together.

struct Foo { int x; int y; int z; }; using fooViewPolicy = data_view_policy<DataLayout::AoS, Foo>;

Memory organized as: xyz xyz xyz xyz

Member Function Documentation

◆ alloc()

template<typename ValueType >
template<typename Allocator >
static GAIA_NODISCARD uint8_t * gaia::mem::data_view_policy_aos< ValueType >::alloc ( size_t  cnt)
inlinestaticnoexcept

Allocates and default-constructs an AoS value range.

Template Parameters
AllocatorAllocator adaptor type.
Parameters
cntNumber of values.
Returns
Allocated byte buffer.

◆ free() [1/2]

template<typename ValueType >
template<typename Allocator >
static void gaia::mem::data_view_policy_aos< ValueType >::free ( void *  pData,
size_t  cap,
size_t  cnt 
)
inlinestaticnoexcept

Destroys and releases an instrumented AoS value range.

Template Parameters
AllocatorAllocator adaptor type.
Parameters
pDataAllocated buffer, or null.
capBuffer capacity in values.
cntNumber of live values.

◆ free() [2/2]

template<typename ValueType >
template<typename Allocator >
static void gaia::mem::data_view_policy_aos< ValueType >::free ( void *  pData,
size_t  cnt 
)
inlinestaticnoexcept

Destroys and releases an AoS value range.

Template Parameters
AllocatorAllocator adaptor type.
Parameters
pDataAllocated buffer, or null.
cntNumber of live values.

◆ get()

template<typename ValueType >
GAIA_NODISCARD static constexpr const ValueType & gaia::mem::data_view_policy_aos< ValueType >::get ( std::span< const ValueType >  s,
size_t  idx 
)
inlinestaticconstexprnoexcept

Returns a read-only value reference from an AoS span.

Parameters
sSource values.
idxValue index.
Returns
Reference to the selected value.

◆ get_min_byte_size()

template<typename ValueType >
static GAIA_NODISCARD constexpr uint32_t gaia::mem::data_view_policy_aos< ValueType >::get_min_byte_size ( uintptr_t  addr,
size_t  cnt 
)
inlinestaticconstexprnoexcept

Calculates the bytes required for a value range.

Parameters
addrStarting address used for alignment calculations.
cntNumber of values.
Returns
Minimum required byte count.

◆ get_value()

template<typename ValueType >
GAIA_NODISCARD static constexpr ValueType gaia::mem::data_view_policy_aos< ValueType >::get_value ( std::span< const ValueType >  s,
size_t  idx 
)
inlinestaticconstexprnoexcept

Copies a value from an AoS span.

Parameters
sSource values.
idxValue index.
Returns
Copied value.

◆ set()

template<typename ValueType >
GAIA_NODISCARD static constexpr ValueType & gaia::mem::data_view_policy_aos< ValueType >::set ( std::span< ValueType >  s,
size_t  idx 
)
inlinestaticconstexprnoexcept

Returns a mutable value reference from an AoS span.

Parameters
sDestination values.
idxValue index.
Returns
Reference to the selected value.

The documentation for this struct was generated from the following file: