Skip to navigation

holoscan::authoring::ConstructorHandle

Beta
View as MarkdownOpen in Claude

Own one typed C++ object for a registered Operator construction call.

Copies share ownership of the original object and preserve its control block; recovery never creates a second owner from a raw pointer. A handle also records the process that created it so that an object inherited through fork() is rejected rather than admitted by address.

#include <holoscan/authoring/constructor_handle.hpp>

Constructors

ConstructorHandle

holoscan::authoring::ConstructorHandle::ConstructorHandle() = default

Create an empty handle, which no construction call accepts.


Methods

as_shared

template <typename T>
expected<std::shared_ptr<T>, Error> holoscan::authoring::ConstructorHandle::as_shared(
const ConstructorHandleType<T> &type
) const

Recover an independent shared owner after checking the exact descriptor.

Returns: A shared owner of the original object, or a type-mismatch or empty-handle error.

Parameters

type
const ConstructorHandleType<T> &

Typed descriptor binding expected by the caller.

type

const ConstructorHandleDescriptor * holoscan::authoring::ConstructorHandle::type() const noexcept

Return the descriptor this handle was created with, or nullptr when empty.

operator bool

holoscan::authoring::ConstructorHandle::operator bool() const noexcept

Return whether this handle owns an object.

created_in_current_process

bool holoscan::authoring::ConstructorHandle::created_in_current_process() const noexcept

Return whether this handle was created in the calling process.

owner

const std::shared_ptr<const void> & holoscan::authoring::ConstructorHandle::owner() const noexcept

Return the type-erased owner, preserving the original control block.


Static methods

from_shared

template <typename T>
static expected<ConstructorHandle, Error> holoscan::authoring::ConstructorHandle::from_shared(
const ConstructorHandleType<T> &type,
std::shared_ptr<T> owner
)

Wrap one shared owner under its exact interface type.

Returns: The handle, or AUTHORING_CONSTRUCTOR_HANDLE_NULL for a null owner.

Parameters

type
const ConstructorHandleType<T> &

Typed descriptor binding for T.

owner
std::shared_ptr<T>

Non-null shared owner; its control block is retained unchanged.


Member variables

NameTypeDescription
owner_std::shared_ptr< const void >
type_const ConstructorHandleDescriptor *
origin_process_std::int64_t