MxEngine
Classes | Public Types | Public Member Functions | List of all members
MxEngine::PoolAllocator< T > Class Template Reference

Classes

struct  Block
 

Public Types

using DataPointer = uint8_t *
 

Public Member Functions

 PoolAllocator ()
 
 PoolAllocator (DataPointer data, size_t bytes)
 
void Init (DataPointer data, size_t bytes)
 
void Transfer (DataPointer newData, size_t newBytes)
 
 ~PoolAllocator ()
 
DataPointer GetBase ()
 
template<typename... Args>
T * Alloc (Args &&... args)
 
void Free (T *object)
 
template<typename... Args>
auto StackAlloc (Args &&... args)
 
void Dump (std::ostream &out) const
 

Constructor & Destructor Documentation

§ PoolAllocator() [1/2]

template<typename T >
MxEngine::PoolAllocator< T >::PoolAllocator ( )
inline

creates empty Pool allocator (nullptr chunk pointer, count = 0)

§ PoolAllocator() [2/2]

template<typename T >
MxEngine::PoolAllocator< T >::PoolAllocator ( DataPointer  data,
size_t  bytes 
)
inline

constructs Pool allocator, assigning it memory chunk

Parameters
databegin of memory chunk
bytessize in bytes of memory chunk

§ ~PoolAllocator()

template<typename T >
MxEngine::PoolAllocator< T >::~PoolAllocator ( )
inline

destroys Pool allocator and all objects stored in it

Member Function Documentation

§ Alloc()

template<typename T >
template<typename... Args>
T* MxEngine::PoolAllocator< T >::Alloc ( Args &&...  args)
inline

constructs object of type T in memory and returns pointer to it

Parameters
argsarguments for object construction
Returns
pointer to object (object destructor is automatically called in ~PoolAllocator())

§ Dump()

template<typename T >
void MxEngine::PoolAllocator< T >::Dump ( std::ostream &  out) const
inline

prints whole memory chunk byte by byte in hex format into stream provided

Parameters
outstream to output to

§ Free()

template<typename T >
void MxEngine::PoolAllocator< T >::Free ( T *  object)
inline

destroyes object of type T, calling its destructor

Parameters
valueobject to destroy

§ GetBase()

template<typename T >
DataPointer MxEngine::PoolAllocator< T >::GetBase ( )
inline

memory chunk getter

Returns
pointer to begin of memory chunk

§ Init()

template<typename T >
void MxEngine::PoolAllocator< T >::Init ( DataPointer  data,
size_t  bytes 
)
inline

assigns new memory chunk to Pool allocator

Parameters
databegin of memory chunk
bytessize in bytes of memory chunk

§ StackAlloc()

template<typename T >
template<typename... Args>
auto MxEngine::PoolAllocator< T >::StackAlloc ( Args &&...  args)
inline

constructs object of type T

Parameters
argsarguments for object construction
Returns
smart pointer to object with custom deleter

§ Transfer()

template<typename T >
void MxEngine::PoolAllocator< T >::Transfer ( DataPointer  newData,
size_t  newBytes 
)
inline

transfers blocks from one memory chunk to another

Parameters
newDatabegin of new memory chunk
newBytessize of new memory chunk (must be not less than old size)
Warning
during transfer all pointers to allocated objects are invalidated

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