xentara-plugin v1.2.1
The Xentara Plugin Framework
|
A memory block containing a single C++ object. More...
#include <memory/ObjectBlock.hpp>
Public Types | |
using | TargetObject = memory::Object< Type > |
The object type describing the structure of this block. | |
using | Element = typename TargetObject::Element |
The C++ object type contained in this memory block. | |
using | Handle = ObjectHandle< Type > |
A handle for accessing the object. | |
Public Member Functions | |
MemoryBlock () noexcept=default | |
Default constructor. | |
MemoryBlock (std::nullptr_t) noexcept | |
Conversion from an null pointer. | |
MemoryBlock (MemoryBlock &&other) noexcept=default | |
Move constructor. | |
~MemoryBlock ()=default | |
Destructor. | |
auto | operator= (MemoryBlock &&other) noexcept -> MemoryBlock &=default |
Move assignment operator. | |
auto | operator= (std::nullptr_t) noexcept -> MemoryBlock & |
Assignment operator for a null pointer. | |
auto | operator== (std::nullptr_t) const -> bool |
Comparison operator with a null pointer. | |
operator bool () const noexcept | |
Boolean operator. | |
auto | create (MemoryResource &memoryResource) -> Initializer< TargetObject > |
Allocates memory for the object and default initializes it. | |
auto | destroy () noexcept -> void |
Destroys any created object and turns the block into a null block. | |
auto | initializer () -> Initializer< TargetObject > |
Recovers the initializer for additional initialization. | |
auto | handle () const noexcept -> Handle |
Returns an object handle for the object's memory. | |
template<typename TypeOrBase , typename MemberType > requires std::derived_from<Type, TypeOrBase> | |
auto | member (MemberType TypeOrBase::*member) const noexcept -> ObjectHandle< MemberType > |
Returns an object handle to one of the object's members. | |
template<std::same_as< Type > BitFieldType = Type> requires utils::tools::UnsignedIntegral<BitFieldType> | |
auto | bits (Type mask) const noexcept -> BitFieldHandle< BitFieldType > |
Returns a handle to a bit field using the object's value. | |
template<std::same_as< Type > BitFieldType = Type> requires utils::tools::UnsignedIntegral<BitFieldType> | |
auto | bit (BitFieldType mask) const noexcept -> BitHandle |
Returns a Boolean handle to single bit in a bit field using the object's value. | |
auto | memoryResource () const noexcept -> MemoryResource & |
Returns the memory resource that the block was allocated in. | |
auto | rawBlock () const noexcept -> const RawMemoryBlock & |
Returns the raw memory block that holds the object. | |
auto | rawBlock () noexcept -> RawMemoryBlock & |
Returns the raw memory block that holds the object. | |
Protected Member Functions | |
auto | blockTraits () const noexcept -> BlockTraits final |
Gets the size and alignment info for the block. | |
auto | constructAt (void *placement) const -> void final |
Called by the framework to construct a block in an existing placement. | |
auto | constructAt (void *placement, const void *init) const -> void final |
Called by the framework to construct a block in an existing placement using copy construction. | |
auto | destroyAt (void *placement) const noexcept -> void final |
Called by the framework to destroy the block in an existing placement. | |
A memory block containing a single C++ object.
This class can be moved but not copied.
Type | The type of the C++ object contained in the block |
using xentara::memory::MemoryBlock< Object< Type > >::Element = typename TargetObject::Element |
The C++ object type contained in this memory block.
using xentara::memory::MemoryBlock< Object< Type > >::Handle = ObjectHandle<Type> |
A handle for accessing the object.
using xentara::memory::MemoryBlock< Object< Type > >::TargetObject = memory::Object<Type> |
The object type describing the structure of this block.
|
defaultnoexcept |
Default constructor.
This constructor constructs a null object without an allocated block
|
noexcept |
Conversion from an null pointer.
This constructor constructs a null object without an allocated block
|
defaultnoexcept |
Move constructor.
This constructor transfers any allocated memory from other to this object. other is turned into as a null object without an allocated block.
|
default |
Destructor.
Destroys any allocated object
|
noexcept |
Returns a Boolean handle to single bit in a bit field using the object's value.
mask | A mask describing the desired bit. Must have exactly one bit set. |
|
noexcept |
Returns a handle to a bit field using the object's value.
mask | A mask describing the relevant bits |
|
finalprotectedvirtualnoexcept |
Gets the size and alignment info for the block.
Implements xentara::memory::MemoryResource::BlockHandler.
|
finalprotectedvirtual |
Called by the framework to construct a block in an existing placement.
placement | The placement of the block |
Implements xentara::memory::MemoryResource::BlockHandler.
|
finalprotectedvirtual |
Called by the framework to construct a block in an existing placement using copy construction.
placement | The placement of the block |
init | The placement of the block to copy. The block is guaranteed to have the same handler. |
Implements xentara::memory::MemoryResource::BlockHandler.
auto xentara::memory::MemoryBlock< Object< Type > >::create | ( | MemoryResource & | memoryResource | ) | -> Initializer<TargetObject> |
Allocates memory for the object and default initializes it.
Any previously created object is destroyed
memoryResource | The memory resource to use |
|
noexcept |
Destroys any created object and turns the block into a null block.
Like operator new
and std::free(), this method can safely be called on null objects.
|
finalprotectedvirtualnoexcept |
Called by the framework to destroy the block in an existing placement.
placement | The placement of the block |
Implements xentara::memory::MemoryResource::BlockHandler.
|
noexcept |
Returns an object handle for the object's memory.
auto xentara::memory::MemoryBlock< Object< Type > >::initializer | ( | ) | -> Initializer<TargetObject> |
Recovers the initializer for additional initialization.
This function can be used to perform additional initialization of the object from code locations where the initializer returned from create() is not available.
|
noexcept |
Returns an object handle to one of the object's members.
member | The member |
|
noexcept |
Returns the memory resource that the block was allocated in.
This function may not be called on null objects with no allocated block
|
explicitnoexcept |
Boolean operator.
This operator checks whether the object has an allocated memory block
|
defaultnoexcept |
Move assignment operator.
This operator swaps the allocated memory with other.
|
noexcept |
Assignment operator for a null pointer.
This operator deallocates any allocated data turns the object into a null object.
auto xentara::memory::MemoryBlock< Object< Type > >::operator== | ( | std::nullptr_t | ) | const -> bool |
Comparison operator with a null pointer.
This operator checks whether the object is a null object without an allocated block
|
noexcept |
Returns the raw memory block that holds the object.
|
noexcept |
Returns the raw memory block that holds the object.