DynaMix
1.3.7
A new take on polymorphism in C++
|
#include <allocators.hpp>
Public Member Functions | |
virtual std::pair< char *, size_t > | alloc_mixin (const basic_mixin_type_info &info, const object *obj)=0 |
virtual void | dealloc_mixin (char *ptr, size_t mixin_offset, const basic_mixin_type_info &info, const object *obj)=0 |
virtual void | construct_mixin (const basic_mixin_type_info &info, void *ptr) |
virtual bool | copy_construct_mixin (const basic_mixin_type_info &info, void *ptr, const void *source) |
virtual void | destroy_mixin (const basic_mixin_type_info &info, void *ptr) noexcept |
bool | has_allocated () const |
Static Public Member Functions | |
static size_t | mem_size_for_mixin (size_t mixin_size, size_t mixin_alignment) |
static size_t | mixin_offset (const char *buffer, size_t mixin_alignment) |
Protected Attributes | |
std::atomic< bool > | _has_allocated |
This class should be the parent to your custom mixin allocators, i.e. allocators that are set to mixins as features.
|
inlinestatic |
Calculates appropriate size for a mixin buffer so as to satisfy the requirements of mixin size and alignment AND leave a room for its owning object in front.
You may use it in your overrides of alloc_mixin
to determine the appropriate memory size.
|
inlinestatic |
Calculates the appropriate offset of the mixin in the buffer so as to satisfy the requirements of its alignment AND leave a room for its owning object in front.
You may use it in your overrides of alloc_mixin
to determine the correct mixin_offset.
|
pure virtual |
Pure virtual. Returns a buffer of memory and the offset of the mixin within it (according to the alignment) BUT IN SUCH A WAY AS TO ALLOW A POINTER TO BE PLACED IN FRONT
You may use mem_size_for_mixin
and mixin_offset
if you're not sure what to do.
Implemented in dynamix::internal::default_allocator.
|
pure virtual |
Pure virtual. Should free the memory that has been obtained via a call to alloc_mixin
. The library will call the method with the same mixin type info which was used to allocate it previously and also with the offset which was returned by the allocation.
Implemented in dynamix::internal::default_allocator.
|
virtual |
Virtual function, which constructs a mixin within a memory buffer. The default implementation calls the default constructor.
|
virtual |
Virtual function, which copy-constructs a mixin within a memory buffer, from a given source. Should return false if the copy-construction failed. The default implementation calls the default copy constructor and returns false if none exists.
|
virtualnoexcept |
Virtual function, which destroys a mixin from a given buffer. The default implementation calls the destructor.