xentara-plugin v1.2.1
The Xentara Plugin Framework
Loading...
Searching...
No Matches
xentara::memory::MemoryHandle< Object< Type > > Class Template Referencefinal

A handle to a single C++ value object located in a memory resource. More...

#include <memory/ObjectHandle.hpp>

Public Types

using TargetObject = memory::Object< Type >
 The object type describing the structure.
 
using Element = typename TargetObject::Element
 The C++ object type.
 

Public Member Functions

 MemoryHandle () noexcept=default
 Default constructor.
 
 MemoryHandle (const RawMemoryHandle &rawHandle) noexcept
 Creates a handle for an object in a memory block.
 
 MemoryHandle (std::nullptr_t) noexcept
 Conversion from an null pointer.
 
template<typename Base >
requires std::derived_from<Type, Base>
 operator ObjectHandle< Base > () const
 Gets a handle to an unambiguous base class.
 
auto operator= (std::nullptr_t) noexcept -> MemoryHandle &
 Assignment operator for a null pointer.
 
auto operator== (std::nullptr_t) const -> bool
 Comparison operator with a null pointer.
 
 operator bool () const noexcept
 Checks for a null handle.
 
auto operator== (const MemoryHandle &) const -> bool=default
 Comparison operator.
 
auto operator<=> (const MemoryHandle &) const -> auto=default
 Comparison operator.
 
auto memoryResource () const noexcept -> MemoryResource &
 Returns the memory resource that the object resides in.
 
constexpr auto blockHandle () const noexcept -> const MemoryResource::BlockHandle &
 Returns a a handle to the memory block that holds the object.
 
constexpr auto rawHandle () const noexcept -> const RawMemoryHandle &
 Returns a handle to the raw memory holding the object.
 
auto offset () const noexcept -> std::size_t
 Gets the offset of the object within the block data.
 
auto initializer () const -> Initializer< TargetObject >
 Creates an initializer for additional initialization.
 
template<typename TypeOrBase , typename MemberType >
requires std::derived_from<Type, TypeOrBase>
auto member (MemberType TypeOrBase::*member) const noexcept -> ObjectHandle< MemberType >
 Returns a handle to a member.
 
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 operator++ () noexcept -> MemoryHandle &
 Increments the handle by a one element.
 
auto operator++ (int) noexcept -> MemoryHandle
 Increments the handle by a one element.
 
auto operator-- () noexcept -> MemoryHandle &
 Decrements the handle by a one element.
 
auto operator-- (int) noexcept -> MemoryHandle
 Decrements the handle by a one element.
 
auto operator+= (std::ptrdiff_t count) noexcept -> MemoryHandle &
 Offsets the handle by a specific number of elements.
 
auto operator-= (std::ptrdiff_t count) noexcept -> MemoryHandle &
 Offsets the handle by a specific number of elements.
 

Detailed Description

template<typename Type>
class xentara::memory::MemoryHandle< Object< Type > >

A handle to a single C++ value object located in a memory resource.

Template Parameters
TypeThe type of the C++ object this handle refers to

Member Typedef Documentation

◆ Element

template<typename Type >
using xentara::memory::MemoryHandle< Object< Type > >::Element = typename TargetObject::Element

The C++ object type.

◆ TargetObject

template<typename Type >
using xentara::memory::MemoryHandle< Object< Type > >::TargetObject = memory::Object<Type>

The object type describing the structure.

Constructor & Destructor Documentation

◆ MemoryHandle() [1/3]

template<typename Type >
xentara::memory::MemoryHandle< Object< Type > >::MemoryHandle ( )
defaultnoexcept

Default constructor.

This constructor constructs a null handle

◆ MemoryHandle() [2/3]

template<typename Type >
xentara::memory::MemoryHandle< Object< Type > >::MemoryHandle ( const RawMemoryHandle< Object< Type > > &  rawHandle)
noexcept

Creates a handle for an object in a memory block.

◆ MemoryHandle() [3/3]

template<typename Type >
xentara::memory::MemoryHandle< Object< Type > >::MemoryHandle ( std::nullptr_t  )
noexcept

Conversion from an null pointer.

This constructor constructs a null handle

Member Function Documentation

◆ bit()

template<typename Type >
template<std::same_as< Type > BitFieldType = Type>
requires utils::tools::UnsignedIntegral<BitFieldType>
auto xentara::memory::MemoryHandle< Object< Type > >::bit ( BitFieldType  mask) const -> BitHandle
noexcept

Returns a Boolean handle to single bit in a bit field using the object's value.

Requirements:
This function is only available for unsigned integer types.
Parameters
maskA mask describing the desired bit. Must have exactly one bit set.
Returns
A handle to a bit field containing the specified bit
See also
utils::tools::UnsignedIntegral

◆ bits()

template<typename Type >
template<std::same_as< Type > BitFieldType = Type>
requires utils::tools::UnsignedIntegral<BitFieldType>
auto xentara::memory::MemoryHandle< Object< Type > >::bits ( Type  mask) const -> BitFieldHandle< BitFieldType >
noexcept

Returns a handle to a bit field using the object's value.

Requirements:
This function is only available for unsigned integer types.
Parameters
maskA mask describing the relevant bits
Returns
A handle to a bit field containing the specified bits
See also
utils::tools::UnsignedIntegral

◆ blockHandle()

template<typename Type >
constexpr auto xentara::memory::MemoryHandle< Object< Type > >::blockHandle ( ) const -> const MemoryResource::BlockHandle &
constexprnoexcept

Returns a a handle to the memory block that holds the object.

◆ initializer()

template<typename Type >
auto xentara::memory::MemoryHandle< Object< Type > >::initializer ( ) const -> Initializer<TargetObject>

Creates an initializer for additional initialization.

This function can be used to perform additional initialization of the object from code locations where the original initializer returned when the block was allocated is not available.

Attention
Do not call this function if any read or write sentinels may exist for the block this handle belongs to, or if anyone may be holding any read handles or write handles to any data within that block.
Returns
An initializer for additional initialization of the object

◆ member()

template<typename Type >
template<typename TypeOrBase , typename MemberType >
requires std::derived_from<Type, TypeOrBase>
auto xentara::memory::MemoryHandle< Object< Type > >::member ( MemberType TypeOrBase::*  member) const -> ObjectHandle<MemberType>
noexcept

Returns a handle to a member.

Parameters
memberThe member
Returns
A handle to the member at the specified offset

◆ memoryResource()

template<typename Type >
auto xentara::memory::MemoryHandle< Object< Type > >::memoryResource ( ) const -> MemoryResource &
noexcept

Returns the memory resource that the object resides in.

◆ offset()

template<typename Type >
auto xentara::memory::MemoryHandle< Object< Type > >::offset ( ) const -> std::size_t
noexcept

Gets the offset of the object within the block data.

◆ operator bool()

template<typename Type >
xentara::memory::MemoryHandle< Object< Type > >::operator bool ( ) const
explicitnoexcept

Checks for a null handle.

◆ operator ObjectHandle< Base >()

template<typename Type >
template<typename Base >
requires std::derived_from<Type, Base>
xentara::memory::MemoryHandle< Object< Type > >::operator ObjectHandle< Base > ( ) const

Gets a handle to an unambiguous base class.

Returns
A handle to the base class, or a null handle if this is a null handle

◆ operator++() [1/2]

template<typename Type >
auto xentara::memory::MemoryHandle< Object< Type > >::operator++ ( ) -> MemoryHandle &
noexcept

Increments the handle by a one element.

Attention
This can make the handle point to invalid data. It is your respoinsibility to ensure that the handle does not end up pointing outside of the block's memory.
Returns
Returns a reference to this object

◆ operator++() [2/2]

template<typename Type >
auto xentara::memory::MemoryHandle< Object< Type > >::operator++ ( int  ) -> MemoryHandle
noexcept

Increments the handle by a one element.

Attention
This can make the handle point to invalid data. It is your respoinsibility to ensure that the handle does not end up pointing outside of the block's memory.
Returns
The old value of the handle

◆ operator+=()

template<typename Type >
auto xentara::memory::MemoryHandle< Object< Type > >::operator+= ( std::ptrdiff_t  count) -> MemoryHandle &
noexcept

Offsets the handle by a specific number of elements.

Attention
This can make the handle point to invalid data. It is your respoinsibility to ensure that the handle does not end up pointing outside of the block's memory.
Parameters
countThe number of elements to move the handle
Returns
Returns a reference to this object

◆ operator--() [1/2]

template<typename Type >
auto xentara::memory::MemoryHandle< Object< Type > >::operator-- ( ) -> MemoryHandle &
noexcept

Decrements the handle by a one element.

Attention
This can make the handle point to invalid data. It is your respoinsibility to ensure that the handle does not end up pointing outside of the block's memory.
Returns
Returns a reference to this object

◆ operator--() [2/2]

template<typename Type >
auto xentara::memory::MemoryHandle< Object< Type > >::operator-- ( int  ) -> MemoryHandle
noexcept

Decrements the handle by a one element.

Attention
This can make the handle point to invalid data. It is your respoinsibility to ensure that the handle does not end up pointing outside of the block's memory.
Returns
The old value of the handle

◆ operator-=()

template<typename Type >
auto xentara::memory::MemoryHandle< Object< Type > >::operator-= ( std::ptrdiff_t  count) -> MemoryHandle &
noexcept

Offsets the handle by a specific number of elements.

Attention
This can make the handle point to invalid data. It is your respoinsibility to ensure that the handle does not end up pointing outside of the block's memory.
Parameters
countThe negative number of elements to move the handle
Returns
Returns a reference to this object

◆ operator<=>()

template<typename Type >
auto xentara::memory::MemoryHandle< Object< Type > >::operator<=> ( const MemoryHandle< Object< Type > > &  ) const -> auto=default
default

Comparison operator.

◆ operator=()

template<typename Type >
auto xentara::memory::MemoryHandle< Object< Type > >::operator= ( std::nullptr_t  ) -> MemoryHandle &
noexcept

Assignment operator for a null pointer.

◆ operator==() [1/2]

template<typename Type >
auto xentara::memory::MemoryHandle< Object< Type > >::operator== ( const MemoryHandle< Object< Type > > &  ) const -> bool=default
default

Comparison operator.

◆ operator==() [2/2]

template<typename Type >
auto xentara::memory::MemoryHandle< Object< Type > >::operator== ( std::nullptr_t  ) const -> bool

Comparison operator with a null pointer.

◆ rawHandle()

template<typename Type >
constexpr auto xentara::memory::MemoryHandle< Object< Type > >::rawHandle ( ) const -> const RawMemoryHandle &
constexprnoexcept

Returns a handle to the raw memory holding the object.