Gaia-ECS v1.0.0
A simple and powerful entity component system
Loading...
Searching...
No Matches
gaia::cnt::page_storage< T > Class Template Reference

Heap-allocated paged storage for elements of type T. More...

#include <paged_storage.h>

Public Types

using value_type = T
 Element type.
 
using reference = T &
 Reference to an element.
 
using const_reference = const T &
 Reference to a read-only element.
 
using pointer = T *
 Pointer to an element.
 
using const_pointer = const T *
 Pointer to a read-only element.
 
using view_policy = mem::auto_view_policy< T >
 Data-layout access policy for the element type.
 
using difference_type = detail::difference_type
 Type used for iterator distances.
 
using size_type = detail::size_type
 Type used for sizes and indices.
 
using Allocator = mem::PagedAllocator< T, AllocatorBlockSize >
 Allocator used for page data.
 
using page_data_type = detail::mem_page_data< T >
 Raw page-data type.
 
using page_type = detail::mem_page< T, Allocator >
 Page type used by the storage.
 
using iterator = page_iterator< T, Allocator, true >
 Forward mutable iterator.
 
using iterator_reverse = page_iterator< T, Allocator, false >
 Reverse mutable iterator.
 
using iterator_soa = page_iterator_soa< T, Allocator, true >
 Forward mutable iterator for structure-of-arrays elements.
 
using iterator_soa_reverse = page_iterator_soa< T, Allocator, false >
 Reverse mutable iterator for structure-of-arrays elements.
 
using const_iterator = const_page_iterator< T, Allocator, true >
 Forward read-only iterator.
 
using const_iterator_reverse = const_page_iterator< T, Allocator, false >
 Reverse read-only iterator.
 
using const_iterator_soa = const_page_iterator_soa< T, Allocator, true >
 Forward read-only iterator for structure-of-arrays elements.
 
using const_iterator_soa_reverse = const_page_iterator_soa< T, Allocator, false >
 Reverse read-only iterator for structure-of-arrays elements.
 
using iterator_category = core::bidirectional_iterator_tag
 Iterator category tag.
 

Public Member Functions

 page_storage (const page_storage &other)
 Copy-constructs a storage.
 
page_storageoperator= (const page_storage &other)
 Copy-assigns a storage.
 
 page_storage (page_storage &&other) noexcept
 Move-constructs a storage.
 
page_storageoperator= (page_storage &&other) noexcept
 Move-assigns a storage.
 
GAIA_NODISCARD decltype(autooperator[] (page_storage_id id) noexcept
 Accesses an element by identifier.
 
GAIA_NODISCARD decltype(autooperator[] (page_storage_id id) const noexcept
 Accesses an element by identifier.
 
GAIA_NODISCARD bool has (page_storage_id id) const noexcept
 Checks if an item with a given page id exists.
 
GAIA_NODISCARD bool has (const T &arg) const noexcept
 Checks if an item arg exists within the storage.
 
template<typename TType >
decltype(autoadd (TType &&arg)
 Inserts the item arg into the storage.
 
decltype(autoset (page_storage_id id)
 Accesses the record at the index id for update.
 
void del (page_storage_id id) noexcept
 Removes the item at the index id from the storage.
 
void del (const T &arg) noexcept
 Removes the item arg from the storage.
 
void clear ()
 Clears the storage.
 
GAIA_NODISCARD size_type size () const noexcept
 Returns the number of items inserted into the storage.
 
GAIA_NODISCARD bool empty () const noexcept
 Checks if the storage is empty (no items inserted).
 
GAIA_NODISCARD decltype(autofront () noexcept
 Accesses the first stored element.
 
GAIA_NODISCARD decltype(autofront () const noexcept
 Accesses the first stored element.
 
GAIA_NODISCARD decltype(autoback () noexcept
 Accesses the last stored element.
 
GAIA_NODISCARD decltype(autoback () const noexcept
 Accesses the last stored element.
 
GAIA_NODISCARD auto begin () noexcept
 Returns an iterator to the first stored element.
 
GAIA_NODISCARD auto begin () const noexcept
 Returns an iterator to the first stored element.
 
GAIA_NODISCARD auto cbegin () const noexcept
 Returns a read-only iterator to the first stored element.
 
GAIA_NODISCARD auto end () noexcept
 Returns an iterator past the last stored element.
 
GAIA_NODISCARD auto end () const noexcept
 Returns an iterator past the last stored element.
 
GAIA_NODISCARD auto cend () const noexcept
 Returns a read-only iterator past the last stored element.
 
GAIA_NODISCARD auto rbegin () noexcept
 Returns a reverse iterator to the last stored element.
 
GAIA_NODISCARD auto rbegin () const noexcept
 Returns a reverse iterator to the last stored element.
 
GAIA_NODISCARD auto crbegin () const noexcept
 Returns a read-only reverse iterator to the last stored element.
 
GAIA_NODISCARD auto rend () noexcept
 Returns a reverse iterator before the first stored element.
 
GAIA_NODISCARD auto rend () const noexcept
 Returns a reverse iterator before the first stored element.
 
GAIA_NODISCARD auto crend () const noexcept
 Returns a read-only reverse iterator before the first stored element.
 
GAIA_NODISCARD bool operator== (const page_storage &other) const noexcept
 Checks whether two storages contain equal elements.
 
GAIA_NODISCARD bool operator!= (const page_storage &other) const noexcept
 Checks whether two storages differ.
 

Static Public Attributes

static constexpr uint32_t AllocatorBlockSize = (uint32_t)sizeof(detail::mem_page_data<T>)
 Size in bytes of one allocator block.
 
static constexpr uint32_t PageCapacity = page_type::PageCapacity
 Maximum number of elements addressable in one page.
 

Detailed Description

template<typename T>
class gaia::cnt::page_storage< T >

Heap-allocated paged storage for elements of type T.

Template Parameters
TElement type.

Constructor & Destructor Documentation

◆ page_storage() [1/2]

template<typename T >
gaia::cnt::page_storage< T >::page_storage ( const page_storage< T > &  other)
inline

Copy-constructs a storage.

Parameters
otherStorage to copy.

◆ page_storage() [2/2]

template<typename T >
gaia::cnt::page_storage< T >::page_storage ( page_storage< T > &&  other)
inlinenoexcept

Move-constructs a storage.

Parameters
otherStorage to move from.

Member Function Documentation

◆ add()

template<typename T >
template<typename TType >
decltype(auto) gaia::cnt::page_storage< T >::add ( TType &&  arg)
inline

Inserts the item arg into the storage.

Template Parameters
TTypeType of the forwarded item.
Parameters
argData
Returns
Reference to the inserted record, or nothing for a structure-of-arrays layout.

◆ back() [1/2]

template<typename T >
GAIA_NODISCARD decltype(auto) gaia::cnt::page_storage< T >::back ( ) const
inlinenoexcept

Accesses the last stored element.

Returns
Read-only reference to the last element.

◆ back() [2/2]

template<typename T >
GAIA_NODISCARD decltype(auto) gaia::cnt::page_storage< T >::back ( )
inlinenoexcept

Accesses the last stored element.

Returns
Mutable reference to the last element.

◆ begin() [1/2]

template<typename T >
GAIA_NODISCARD auto gaia::cnt::page_storage< T >::begin ( ) const
inlinenoexcept

Returns an iterator to the first stored element.

Returns
Read-only iterator to the first element.

◆ begin() [2/2]

template<typename T >
GAIA_NODISCARD auto gaia::cnt::page_storage< T >::begin ( )
inlinenoexcept

Returns an iterator to the first stored element.

Returns
Mutable iterator to the first element.

◆ cbegin()

template<typename T >
GAIA_NODISCARD auto gaia::cnt::page_storage< T >::cbegin ( ) const
inlinenoexcept

Returns a read-only iterator to the first stored element.

Returns
Read-only iterator to the first element.

◆ cend()

template<typename T >
GAIA_NODISCARD auto gaia::cnt::page_storage< T >::cend ( ) const
inlinenoexcept

Returns a read-only iterator past the last stored element.

Returns
Read-only end iterator.

◆ crbegin()

template<typename T >
GAIA_NODISCARD auto gaia::cnt::page_storage< T >::crbegin ( ) const
inlinenoexcept

Returns a read-only reverse iterator to the last stored element.

Returns
Read-only reverse iterator to the last element.

◆ crend()

template<typename T >
GAIA_NODISCARD auto gaia::cnt::page_storage< T >::crend ( ) const
inlinenoexcept

Returns a read-only reverse iterator before the first stored element.

Returns
Read-only reverse end iterator.

◆ del() [1/2]

template<typename T >
void gaia::cnt::page_storage< T >::del ( const T arg)
inlinenoexcept

Removes the item arg from the storage.

Parameters
argData

◆ del() [2/2]

template<typename T >
void gaia::cnt::page_storage< T >::del ( page_storage_id  id)
inlinenoexcept

Removes the item at the index id from the storage.

Parameters
idPage id

◆ empty()

template<typename T >
GAIA_NODISCARD bool gaia::cnt::page_storage< T >::empty ( ) const
inlinenoexcept

Checks if the storage is empty (no items inserted).

Returns
True if the storage contains no items.

◆ end() [1/2]

template<typename T >
GAIA_NODISCARD auto gaia::cnt::page_storage< T >::end ( ) const
inlinenoexcept

Returns an iterator past the last stored element.

Returns
Read-only end iterator.

◆ end() [2/2]

template<typename T >
GAIA_NODISCARD auto gaia::cnt::page_storage< T >::end ( )
inlinenoexcept

Returns an iterator past the last stored element.

Returns
Mutable end iterator.

◆ front() [1/2]

template<typename T >
GAIA_NODISCARD decltype(auto) gaia::cnt::page_storage< T >::front ( ) const
inlinenoexcept

Accesses the first stored element.

Returns
Read-only reference to the first element.

◆ front() [2/2]

template<typename T >
GAIA_NODISCARD decltype(auto) gaia::cnt::page_storage< T >::front ( )
inlinenoexcept

Accesses the first stored element.

Returns
Mutable reference to the first element.

◆ has() [1/2]

template<typename T >
GAIA_NODISCARD bool gaia::cnt::page_storage< T >::has ( const T arg) const
inlinenoexcept

Checks if an item arg exists within the storage.

Parameters
argData
Returns
True if arg exists in the storage.

◆ has() [2/2]

template<typename T >
GAIA_NODISCARD bool gaia::cnt::page_storage< T >::has ( page_storage_id  id) const
inlinenoexcept

Checks if an item with a given page id exists.

Parameters
idPage id
Returns
True if an item with id exists.

◆ operator!=()

template<typename T >
GAIA_NODISCARD bool gaia::cnt::page_storage< T >::operator!= ( const page_storage< T > &  other) const
inlinenoexcept

Checks whether two storages differ.

Parameters
otherStorage to compare with.
Returns
True if the storages differ.

◆ operator=() [1/2]

template<typename T >
page_storage & gaia::cnt::page_storage< T >::operator= ( const page_storage< T > &  other)
inline

Copy-assigns a storage.

Parameters
otherStorage to copy.
Returns
Reference to this storage.

◆ operator=() [2/2]

template<typename T >
page_storage & gaia::cnt::page_storage< T >::operator= ( page_storage< T > &&  other)
inlinenoexcept

Move-assigns a storage.

Parameters
otherStorage to move from.
Returns
Reference to this storage.

◆ operator==()

template<typename T >
GAIA_NODISCARD bool gaia::cnt::page_storage< T >::operator== ( const page_storage< T > &  other) const
inlinenoexcept

Checks whether two storages contain equal elements.

Parameters
otherStorage to compare with.
Returns
True if both storages contain equal elements.

◆ operator[]() [1/2]

template<typename T >
GAIA_NODISCARD decltype(auto) gaia::cnt::page_storage< T >::operator[] ( page_storage_id  id) const
inlinenoexcept

Accesses an element by identifier.

Parameters
idIdentifier of an existing element.
Returns
Read-only element reference or structure-of-arrays view.

◆ operator[]() [2/2]

template<typename T >
GAIA_NODISCARD decltype(auto) gaia::cnt::page_storage< T >::operator[] ( page_storage_id  id)
inlinenoexcept

Accesses an element by identifier.

Parameters
idIdentifier of an existing element.
Returns
Mutable element reference or structure-of-arrays view.

◆ rbegin() [1/2]

template<typename T >
GAIA_NODISCARD auto gaia::cnt::page_storage< T >::rbegin ( ) const
inlinenoexcept

Returns a reverse iterator to the last stored element.

Returns
Read-only reverse iterator to the last element.

◆ rbegin() [2/2]

template<typename T >
GAIA_NODISCARD auto gaia::cnt::page_storage< T >::rbegin ( )
inlinenoexcept

Returns a reverse iterator to the last stored element.

Returns
Mutable reverse iterator to the last element.

◆ rend() [1/2]

template<typename T >
GAIA_NODISCARD auto gaia::cnt::page_storage< T >::rend ( ) const
inlinenoexcept

Returns a reverse iterator before the first stored element.

Returns
Read-only reverse end iterator.

◆ rend() [2/2]

template<typename T >
GAIA_NODISCARD auto gaia::cnt::page_storage< T >::rend ( )
inlinenoexcept

Returns a reverse iterator before the first stored element.

Returns
Mutable reverse end iterator.

◆ set()

template<typename T >
decltype(auto) gaia::cnt::page_storage< T >::set ( page_storage_id  id)
inline

Accesses the record at the index id for update.

Parameters
idPage id
Returns
Mutable record reference or structure-of-arrays view.

◆ size()

template<typename T >
GAIA_NODISCARD size_type gaia::cnt::page_storage< T >::size ( ) const
inlinenoexcept

Returns the number of items inserted into the storage.

Returns
Number of stored items.

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