StormByte 3.0.0
C++26 foundation of the StormByte suite
Loading...
Searching...
No Matches
StormByte::Safe::Detail::Owner Class Referencefinal

Opaque unique state and creator-module lifetime callbacks. More...

#include <StormByte/safe/owner.hxx>

Public Types

using Clone = void* (*)(const void*) noexcept
 Creator-module deep-copy callback; null reports failure.
using Destroy = void (*)(void*) noexcept
 Creator-module destruction callback.

Public Member Functions

 Owner () noexcept
 Empty owner.
 Owner (void *state, Clone clone, Destroy destroy)
 Adopt state and callbacks.
 Owner (const Owner &other)
 Deep copy in the original module.
 Owner (Owner &&other) noexcept
 Transfer state; source becomes empty.
 ~Owner () noexcept
 Release exclusively through the original callback.
Owner & operator= (const Owner &other)
 Strong-guarantee deep copy.
Owner & operator= (Owner &&other) noexcept
 Release old state and transfer.
void * Get () const noexcept
 Borrow opaque state for a provider-defined typed facade.

Detailed Description

Opaque unique state and creator-module lifetime callbacks.

Note
The creator and Base must remain loaded until every copy is destroyed.

Member Typedef Documentation

◆ Clone

using StormByte::Safe::Detail::Owner::Clone = void* (*)(const void*) noexcept

Creator-module deep-copy callback; null reports failure.

◆ Destroy

using StormByte::Safe::Detail::Owner::Destroy = void (*)(void*) noexcept

Creator-module destruction callback.

Constructor & Destructor Documentation

◆ Owner() [1/4]

StormByte::Safe::Detail::Owner::Owner ( )
noexcept

Empty owner.

◆ Owner() [2/4]

StormByte::Safe::Detail::Owner::Owner ( void * state,
Clone clone,
Destroy destroy )

Adopt state and callbacks.

Parameters
stateOwned state.
cloneProvider-module deep-copy callback, or null for move-only ownership.
destroyProvider-module release callback; required when state is non-null.
Exceptions
StormByte::ExceptionIf state is non-null and destroy is null; ownership is not transferred.

◆ Owner() [3/4]

StormByte::Safe::Detail::Owner::Owner ( const Owner & other)

Deep copy in the original module.

Parameters
otherSource.
Exceptions
StormByte::ExceptionIf the source is non-clonable or provider cloning fails.

◆ Owner() [4/4]

StormByte::Safe::Detail::Owner::Owner ( Owner && other)
noexcept

Transfer state; source becomes empty.

Parameters
otherSource.

◆ ~Owner()

StormByte::Safe::Detail::Owner::~Owner ( )
noexcept

Release exclusively through the original callback.

Member Function Documentation

◆ Get()

void * StormByte::Safe::Detail::Owner::Get ( ) const
noexcept

Borrow opaque state for a provider-defined typed facade.

Returns
Borrowed state pointer, or null after move.
Note
Invalid after this owner is moved from, replaced or destroyed; do not retain it.

◆ operator=() [1/2]

Owner & StormByte::Safe::Detail::Owner::operator= ( const Owner & other)

Strong-guarantee deep copy.

Parameters
otherSource.
Returns
This owner.

◆ operator=() [2/2]

Owner & StormByte::Safe::Detail::Owner::operator= ( Owner && other)
noexcept

Release old state and transfer.

Parameters
otherSource.
Returns
This owner.

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