Nebula
Loading...
Searching...
No Matches
Util::ArrayAllocator< TYPES > Class Template Reference

#include <arrayallocator.h>

Detailed Description

template<class ... TYPES>
class Util::ArrayAllocator< TYPES >

The ArrayAllocator provides a variadic list of types which is to be contained in the allocator and fetching each value by providing the index into the list of types, which means the members are nameless.

Note that this is not a container for multiple arrays, but a object allocator that uses multiple arrays to store their variables parallelly, and should be treated as such.

There are two versions of this type, an unsafe and a safe one. Both are implemented in the same way.

The thread safe allocator requires the Get-methods to be within an Enter/Leave lockstep phase.

See also
arrayallocatorsafe.h

Public Member Functions

 ArrayAllocator ()
 constructor
 
 ArrayAllocator (ArrayAllocator< TYPES... > &&rhs)
 move constructor
 
 ArrayAllocator (const ArrayAllocator< TYPES... > &rhs)
 copy constructor
 
 ~ArrayAllocator ()
 destructor
 
void operator= (const ArrayAllocator< TYPES... > &rhs)
 assign operator
 
void operator= (ArrayAllocator< TYPES... > &&rhs)
 move operator
 
uint32_t Alloc ()
 allocate a new resource
 
void EraseIndex (const uint32_t id)
 Erase element for each.
 
void EraseIndexSwap (const uint32_t id)
 Erase element for each.
 
void EraseRange (const uint32_t start, const uint32_t end)
 erase range
 
template<int MEMBER>
tuple_array_t< MEMBER, TYPES... > & Get (const uint32_t index)
 get single item from resource
 
template<int MEMBER>
const tuple_array_t< MEMBER, TYPES... > & ConstGet (const uint32_t index) const
 same as 32 bit get, but const
 
template<int MEMBER>
void Set (const uint32_t index, const tuple_array_t< MEMBER, TYPES... > &type)
 set single item
 
template<int MEMBER>
const Util::Array< tuple_array_t< MEMBER, TYPES... > > & GetArray () const
 get array const reference
 
template<int MEMBER>
Util::Array< tuple_array_t< MEMBER, TYPES... > > & GetArray ()
 get array
 
void Set (const uint32_t index, TYPES...)
 set for each in tuple
 
const uint32_t Size () const
 get number of used indices
 
void Reserve (uint32_t size)
 grow capacity of arrays to size
 
void SetSize (uint32_t size)
 set size of arrays to param size
 
void Clear ()
 clear entire allocator and start from scratch.
 
void UpdateSize ()
 Any reserve and direct array access might mess with the size.
 

Protected Attributes

uint32_t size
 
std::tuple< Util::Array< TYPES >... > objects
 

Constructor & Destructor Documentation

◆ ArrayAllocator() [1/3]

template<class ... TYPES>
Util::ArrayAllocator< TYPES >::ArrayAllocator ( )
inline

constructor

◆ ArrayAllocator() [2/3]

template<class ... TYPES>
Util::ArrayAllocator< TYPES >::ArrayAllocator ( ArrayAllocator< TYPES... > && rhs)
inline

move constructor

◆ ArrayAllocator() [3/3]

template<class ... TYPES>
Util::ArrayAllocator< TYPES >::ArrayAllocator ( const ArrayAllocator< TYPES... > & rhs)
inline

copy constructor

◆ ~ArrayAllocator()

template<class ... TYPES>
Util::ArrayAllocator< TYPES >::~ArrayAllocator ( )
inline

destructor

Member Function Documentation

◆ Alloc()

template<class ... TYPES>
uint32_t Util::ArrayAllocator< TYPES >::Alloc ( )
inline

allocate a new resource

◆ Clear()

template<class ... TYPES>
void Util::ArrayAllocator< TYPES >::Clear ( )
inline

clear entire allocator and start from scratch.

◆ ConstGet()

template<class ... TYPES>
template<int MEMBER>
const tuple_array_t< MEMBER, TYPES... > & Util::ArrayAllocator< TYPES >::ConstGet ( const uint32_t index) const
inline

same as 32 bit get, but const

◆ EraseIndex()

template<class ... TYPES>
void Util::ArrayAllocator< TYPES >::EraseIndex ( const uint32_t id)
inline

Erase element for each.

◆ EraseIndexSwap()

template<class ... TYPES>
void Util::ArrayAllocator< TYPES >::EraseIndexSwap ( const uint32_t id)
inline

Erase element for each.

◆ EraseRange()

template<class ... TYPES>
void Util::ArrayAllocator< TYPES >::EraseRange ( const uint32_t start,
const uint32_t end )
inline

erase range

◆ Get()

template<class ... TYPES>
template<int MEMBER>
tuple_array_t< MEMBER, TYPES... > & Util::ArrayAllocator< TYPES >::Get ( const uint32_t index)
inline

get single item from resource

◆ GetArray() [1/2]

template<class ... TYPES>
template<int MEMBER>
Util::Array< tuple_array_t< MEMBER, TYPES... > > & Util::ArrayAllocator< TYPES >::GetArray ( )
inline

get array

◆ GetArray() [2/2]

template<class ... TYPES>
template<int MEMBER>
const Util::Array< tuple_array_t< MEMBER, TYPES... > > & Util::ArrayAllocator< TYPES >::GetArray ( ) const
inline

get array const reference

◆ operator=() [1/2]

template<class ... TYPES>
void Util::ArrayAllocator< TYPES >::operator= ( ArrayAllocator< TYPES... > && rhs)
inline

move operator

◆ operator=() [2/2]

template<class ... TYPES>
void Util::ArrayAllocator< TYPES >::operator= ( const ArrayAllocator< TYPES... > & rhs)
inline

assign operator

◆ Reserve()

template<class ... TYPES>
void Util::ArrayAllocator< TYPES >::Reserve ( uint32_t size)
inline

grow capacity of arrays to size

◆ Set() [1/2]

template<class ... TYPES>
template<int MEMBER>
void Util::ArrayAllocator< TYPES >::Set ( const uint32_t index,
const tuple_array_t< MEMBER, TYPES... > & type )
inline

set single item

◆ Set() [2/2]

template<class ... TYPES>
void Util::ArrayAllocator< TYPES >::Set ( const uint32_t index,
TYPES... values )

set for each in tuple

◆ SetSize()

template<class ... TYPES>
void Util::ArrayAllocator< TYPES >::SetSize ( uint32_t size)
inline

set size of arrays to param size

◆ Size()

template<class ... TYPES>
const uint32_t Util::ArrayAllocator< TYPES >::Size ( ) const
inline

get number of used indices

◆ UpdateSize()

template<class ... TYPES>
void Util::ArrayAllocator< TYPES >::UpdateSize ( )

Any reserve and direct array access might mess with the size.

This will update the size to reflect the first member array size in objects.

Member Data Documentation

◆ objects

template<class ... TYPES>
std::tuple<Util::Array<TYPES>...> Util::ArrayAllocator< TYPES >::objects
protected

◆ size

template<class ... TYPES>
uint32_t Util::ArrayAllocator< TYPES >::size
protected

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