![]() |
MAGE
v0.171.0
Matthias Advanced Game Engine
|
#include <memory_stack.hpp>
Classes | |
class | Allocator |
Public Member Functions | |
SingleEndedMemoryStack (std::size_t size, std::size_t alignment) | |
SingleEndedMemoryStack (const SingleEndedMemoryStack &stack)=delete | |
SingleEndedMemoryStack (SingleEndedMemoryStack &&stack) noexcept | |
~SingleEndedMemoryStack () | |
SingleEndedMemoryStack & | operator= (const SingleEndedMemoryStack &stack)=delete |
SingleEndedMemoryStack & | operator= (SingleEndedMemoryStack &&stack)=delete |
std::size_t | GetAlignment () const noexcept |
std::size_t | GetSize () const noexcept |
std::size_t | GetUsedSize () const noexcept |
std::size_t | GetAvailableSize () const noexcept |
std::uintptr_t | GetCurrentPtr () const noexcept |
void | Reset () noexcept |
void | RollBack (uintptr_t ptr) noexcept |
void * | Alloc (std::size_t size) noexcept |
template<typename T > | |
T * | AllocData (std::size_t count=1u, bool initialization=false) |
template<typename T > | |
Allocator< T > | GetAllocator () noexcept |
Private Attributes | |
const std::size_t | m_size |
const std::size_t | m_alignment |
std::uintptr_t | m_begin |
std::uintptr_t | m_current |
A class of single-ended memory stacks.
|
explicit |
Constructs a single-ended memory stack with given size.
[in] | size | The size in bytes. |
[in] | alignment | The alignment in bytes. |
std::bad_alloc | Failed to allocate the memory. |
|
delete |
Constructs a single-ended memory stack from the given single-ended memory stack.
[in] | stack | A reference to the single-ended memory stack to copy. |
|
defaultnoexcept |
Constructs a single-ended memory stack by moving the given single-ended memory stack.
[in] | stack | A reference to the single-ended memory stack to move. |
mage::SingleEndedMemoryStack::~SingleEndedMemoryStack | ( | ) |
Destructs this single-ended memory stack.
|
noexcept |
Allocates a block of memory of the given size on this single-ended memory stack.
[in] | size | The requested size in bytes to allocate in memory. |
nullptr
if the allocation failed. T* mage::SingleEndedMemoryStack::AllocData | ( | std::size_t | count = 1u , |
bool | initialization = false |
||
) |
Allocates a block of memory on this single-ended memory stack.
T | The data type. |
[in] | count | The number of objects of type T to allocate in memory. |
[in] | initialization | Flag indicating whether the objects need to be initialized (i.e. the constructor needs to be called). |
nullptr
if the allocation failed.
|
noexcept |
Returns the alignment of this single-ended memory stack.
|
noexcept |
Returns an allocator for this single-ended memory stack.
T | The data type of the allocator. |
|
noexcept |
Returns the available size of this single-ended memory stack.
|
noexcept |
Returns a pointer to the current position of this single-ended memory stack.
|
noexcept |
Returns the size (used + available) of this single-ended memory stack.
|
noexcept |
Returns the used size of this single-ended memory stack.
|
delete |
Copies the given single-ended memory stack to this single-ended memory stack.
[in] | stack | A reference to the single-ended memory stack to copy. |
|
delete |
Moves the given single-ended memory stack to this single-ended memory stack.
[in] | stack | A reference to the single-ended memory stack to move. |
|
noexcept |
Resets this memory stack.
The pointer to the current position of this single-ended memory stack will be reset to the begin position of this single-ended memory stack.
|
noexcept |
Rolls this single-ended memory stack back to the given position.
[in] | ptr | The pointer to the requested position of this single-ended memory stack. |
|
private |
The alignment in bytes of this single-ended memory stack.
|
private |
A pointer to the begin of this single-ended memory stack.
|
private |
A pointer to the current position of this single-ended memory stack.
|
private |
The size in bytes of this single-ended memory stack.