C++ Essence Library 0.1.0
A Utility Library for Modern C++ Programming
Loading...
Searching...
No Matches
essence::nonuniform_grid_buffer< T, Rows, ComponentCells > Class Template Reference

A fixed memory buffer, in which data are arranged within nonuniform grid cells. More...

#include <nonuniform_grid_buffer.hpp>

Public Types

template<std::size_t I, template< typename > typename Decorator = std::type_identity>
using component_span = std::span<typename Decorator<T>::type, std::get<I>(component_cells)>
 
template<std::size_t I, template< typename > typename Decorator = std::type_identity>
using component_byte_span
 

Public Member Functions

template<std::size_t Row, std::size_t I>
requires (Row < Rows && I < component_cells.size())
auto get_component () noexcept
 Gets the component as a mutable cell span.
 
template<std::size_t Row, std::size_t I>
requires (Row < Rows && I < component_cells.size())
auto get_component () const noexcept
 Gets the component as a const cell span.
 
template<std::size_t Row, std::size_t I>
requires (Row < Rows && I < component_cells.size())
void set_component (component_byte_span< I, std::add_const > data) noexcept
 Sets the data of a component.
 
template<std::size_t Row, std::size_t I>
requires (Row < Rows && I < component_cells.size())
void set_component (component_span< I, std::add_const > data) noexcept
 Sets the data of a component.
 
std::span< std::byte, byte_stride *Rows > underlying_buffer () noexcept
 Gets the underlying buffer as a mutable byte span.
 
std::span< const std::byte, byte_stride *Rows > underlying_buffer () const noexcept
 Gets the underlying buffer as a const byte span.
 

Static Public Attributes

static constexpr std::array component_cells {ComponentCells...}
 
static constexpr std::size_t row_count = Rows
 
static constexpr std::size_t row_cell_count = (ComponentCells + ...)
 
static constexpr std::size_t byte_stride = row_cell_count * sizeof(T)
 

Detailed Description

template<typename T, std::size_t Rows, std::size_t... ComponentCells>
class essence::nonuniform_grid_buffer< T, Rows, ComponentCells >

A fixed memory buffer, in which data are arranged within nonuniform grid cells.

Template Parameters
TThe type of one single cell.
RowsThe number of rows.
ComponentCellsThe numbers of the cells of all components across one single row.

Member Typedef Documentation

◆ component_byte_span

template<typename T , std::size_t Rows, std::size_t... ComponentCells>
template<std::size_t I, template< typename > typename Decorator = std::type_identity>
using essence::nonuniform_grid_buffer< T, Rows, ComponentCells >::component_byte_span
Initial value:
std::span<typename Decorator<std::byte>::type, std::get<I>(component_cells) * sizeof(T)>

Member Function Documentation

◆ get_component() [1/2]

template<typename T , std::size_t Rows, std::size_t... ComponentCells>
template<std::size_t Row, std::size_t I>
requires (Row < Rows && I < component_cells.size())
auto essence::nonuniform_grid_buffer< T, Rows, ComponentCells >::get_component ( ) const
inlinenoexcept

Gets the component as a const cell span.

Template Parameters
RowThe index of the row.
IThe index of the component.
Returns
The const cell span.

◆ get_component() [2/2]

template<typename T , std::size_t Rows, std::size_t... ComponentCells>
template<std::size_t Row, std::size_t I>
requires (Row < Rows && I < component_cells.size())
auto essence::nonuniform_grid_buffer< T, Rows, ComponentCells >::get_component ( )
inlinenoexcept

Gets the component as a mutable cell span.

Template Parameters
RowThe index of the row.
IThe index of the component.
Returns
The mutable cell span.

◆ set_component() [1/2]

template<typename T , std::size_t Rows, std::size_t... ComponentCells>
template<std::size_t Row, std::size_t I>
requires (Row < Rows && I < component_cells.size())
void essence::nonuniform_grid_buffer< T, Rows, ComponentCells >::set_component ( component_byte_span< I, std::add_const > data)
inlinenoexcept

Sets the data of a component.

Template Parameters
RowThe index of the row.
IThe index of the component.
Parameters
dataThe byte data to assign.

◆ set_component() [2/2]

template<typename T , std::size_t Rows, std::size_t... ComponentCells>
template<std::size_t Row, std::size_t I>
requires (Row < Rows && I < component_cells.size())
void essence::nonuniform_grid_buffer< T, Rows, ComponentCells >::set_component ( component_span< I, std::add_const > data)
inlinenoexcept

Sets the data of a component.

Template Parameters
RowThe index of the row.
IThe index of the component.
Parameters
dataThe data in T units to assign.

◆ underlying_buffer() [1/2]

template<typename T , std::size_t Rows, std::size_t... ComponentCells>
std::span< const std::byte, byte_stride *Rows > essence::nonuniform_grid_buffer< T, Rows, ComponentCells >::underlying_buffer ( ) const
inlinenoexcept

Gets the underlying buffer as a const byte span.

Returns
The const byte span.

◆ underlying_buffer() [2/2]

template<typename T , std::size_t Rows, std::size_t... ComponentCells>
std::span< std::byte, byte_stride *Rows > essence::nonuniform_grid_buffer< T, Rows, ComponentCells >::underlying_buffer ( )
inlinenoexcept

Gets the underlying buffer as a mutable byte span.

Returns
The mutable byte span.

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