MxEngine
Public Types | Public Member Functions | List of all members
MxEngine::LinearAllocator Class Reference

Public Types

using DataPointer = uint8_t *
 

Public Member Functions

 LinearAllocator ()
 
void Init (DataPointer data, size_t bytes)
 
 LinearAllocator (DataPointer data, size_t bytes)
 
DataPointer GetBase ()
 
DataPointer RawAlloc (size_t bytes, size_t align=1)
 
template<typename T , typename... Args>
T * Alloc (Args &&... args)
 
template<typename T >
void Free (T *value)
 
template<typename T , typename... Args>
auto StackAlloc (Args &&... args)
 
void Dump (std::ostream &out)
 

Constructor & Destructor Documentation

§ LinearAllocator() [1/2]

MxEngine::LinearAllocator::LinearAllocator ( )
inline

creates empty linear allocator (nullptr chunk pointer, size = 0)

§ LinearAllocator() [2/2]

MxEngine::LinearAllocator::LinearAllocator ( DataPointer  data,
size_t  bytes 
)
inline

constructs linear allocator, assigning it memory chunk

Parameters
databegin of memory chunk
bytessize in bytes of memory chunk

Member Function Documentation

§ Alloc()

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

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

Parameters
argsarguments for object construction
Returns
pointer to unmanaged object

§ Dump()

void MxEngine::LinearAllocator::Dump ( std::ostream &  out)
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::LinearAllocator::Free ( T *  value)
inline

destroyes object of type T, calling its destructor memory is not freed, as linear allocator does not support it

Parameters
valueobject to destroy

§ GetBase()

DataPointer MxEngine::LinearAllocator::GetBase ( )
inline

memory chunk getter

Returns
pointer to begin of memory chunk

§ Init()

void MxEngine::LinearAllocator::Init ( DataPointer  data,
size_t  bytes 
)
inline

assigns new memory chunk to linear allocator

Parameters
databegin of memory chunk
bytessize in bytes of memory chunk

§ RawAlloc()

DataPointer MxEngine::LinearAllocator::RawAlloc ( size_t  bytes,
size_t  align = 1 
)
inline

returns pointer to raw allocated memory

Parameters
bytesminimal requested block size
alignminimal alignment of pointer (defaults to 1)
Returns
pointer to memory

§ StackAlloc()

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

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

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

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