Skip to navigation

holoscan::config::Document

Beta
View as Markdown

Own an immutable backend-neutral configuration document.

Copies share immutable state and are safe for concurrent reads. Every successful edit publishes a distinct Document; no operation mutates the baseline. Documents created by config_io may also retain original-source identity and an internal lossless scalar-span sidecar.

#include <holoscan/config/document.hpp>

Constructors

Document

holoscan::config::Document::Document(
std::shared_ptr<const detail::DocumentState> state
) noexcept

Methods

root

ConfigView holoscan::config::Document::root() const noexcept

Return a shareable view of the root value.

at

ConfigView holoscan::config::Document::at(
const Path &path
) const

Return the value at an owned path.

Returns: A shareable view.

Throws: ConfigException with CONFIG_PATH_NOT_FOUND or CONFIG_TYPE_MISMATCH on lookup failure.

Parameters

path
const Path &

Root-relative RFC 6901 path.

try_at

ConfigResult<ConfigView> holoscan::config::Document::try_at(
const Path &path
) const

Try to return the value at an owned path.

Returns: A shareable view or CONFIG_PATH_NOT_FOUND/CONFIG_TYPE_MISMATCH.

Parameters

path
const Path &

Root-relative RFC 6901 path.

find

std::optional<ConfigView> holoscan::config::Document::find(
const Path &path
) const

Find a value without treating absence as failure.

Returns: The optional shareable view; absence is not an error.

Throws: ConfigException on a traversal/type failure.

Parameters

path
const Path &

Root-relative RFC 6901 path.

try_find

ConfigResult<std::optional<ConfigView>> holoscan::config::Document::try_find(
const Path &path
) const

Try to find a value without treating absence as failure.

Returns: The optional shareable view, or a traversal/type failure.

Parameters

path
const Path &

Root-relative RFC 6901 path.

get

template <class T>
T holoscan::config::Document::get(
const Path &path,
) const

Decode one addressed value through the explicit ConfigCodec specialization.

Returns: The decoded value.

Throws: ConfigException on a path or codec failure.

Template parameters

T
class

Owning destination type satisfying ConfigCodable.

Parameters

path
const Path &

Root-relative path.

options
DecodeOptionsDefaults to DecodeOptions{}

Immutable typed-decoding policy.

try_get

template <class T>
ConfigResult<T> holoscan::config::Document::try_get(
const Path &path,
) const

Try to decode one addressed value through the explicit ConfigCodec specialization.

Returns: The decoded value or a structured path/codec failure.

Template parameters

T
class

Owning destination type satisfying ConfigCodable.

Parameters

path
const Path &

Root-relative path.

options
DecodeOptionsDefaults to DecodeOptions{}

Immutable typed-decoding policy.

patch

template <class T>
T holoscan::config::Document::patch(
const Path &path,
T baseline,
) const

Apply an object-valued configuration patch to a typed baseline transactionally.

The baseline is encoded, recursively merged with the addressed object, and decoded into one successor. Neither baseline nor this document is modified on success or failure.

Returns: The typed successor.

Throws: ConfigException on a path, type, or codec failure.

Template parameters

T
class

Owning type satisfying ConfigCodable.

Parameters

path
const Path &

Path to an object-valued patch.

baseline
T

Baseline value copied into the transaction.

options
DecodeOptionsDefaults to DecodeOptions{}

Immutable decoding policy for the successor.

try_patch

template <class T>
ConfigResult<T> holoscan::config::Document::try_patch(
const Path &path,
T baseline,
) const

Try to apply an object-valued configuration patch to a typed baseline.

Returns: The typed successor or a structured path/type/codec failure.

Template parameters

T
class

Owning type satisfying ConfigCodable.

Parameters

path
const Path &

Path to an object-valued patch.

baseline
T

Baseline value copied into the transaction.

options
DecodeOptionsDefaults to DecodeOptions{}

Immutable decoding policy for the successor.

replace

template <class T>
Document holoscan::config::Document::replace(
const Path &path,
T &&value
) const

Encode a typed value and transactionally replace an existing path.

Returns: A successor document.

Throws: ConfigException on a codec or edit failure.

Template parameters

T
class

Type satisfying ConfigCodable after cv/ref removal.

Parameters

path
const Path &

Existing destination path.

value
T &&

Typed replacement value; the caller retains ownership.

try_replace

template <class T>
ConfigResult<Document> holoscan::config::Document::try_replace(
const Path &path,
T &&value
) const

Try to encode a typed value and replace an existing path transactionally.

Returns: A successor document or a structured codec/edit failure.

Template parameters

T
class

Type satisfying ConfigCodable after cv/ref removal.

Parameters

path
const Path &

Existing destination path.

value
T &&

Typed replacement value; the caller retains ownership.

patched

Document holoscan::config::Document::patched(
std::span<const Edit> edits
) const

Apply a non-overlapping batch of immutable edits transactionally.

In lossless mode, only existing non-root scalar replacements that retain semantic kind and source style are admitted; every byte outside the replaced scalar tokens is preserved. A lossless document parsed from alias-bearing YAML rejects every edit; parse it with Preservation::kSemanticOnly when edits are required. Structural edits clear source-byte preservation authority in semantic-only documents.

Returns: A successor document.

Throws: ConfigException on failure, with this document unchanged.

Parameters

edits
std::span<const Edit>

Complete transaction. Duplicate or ancestor/descendant paths conflict.

try_patched

ConfigResult<Document> holoscan::config::Document::try_patched(
std::span<const Edit> edits
) const

Try to apply a non-overlapping batch of immutable edits transactionally.

Returns: A successor document, or a structured failure with this document unchanged.

Parameters

edits
std::span<const Edit>

Complete transaction. Duplicate or ancestor/descendant paths conflict.

digest

ConfigDigest holoscan::config::Document::digest() const noexcept

Return immutable semantic identity and optional original-source provenance.


Static methods

from_value

static Document holoscan::config::Document::from_value(
)

Create a document and compute its semantic identity.

Returns: The immutable document.

Throws: ConfigException on allocation or semantic encoding failure.

Parameters

root
ConfigValue

Root value to share with the document.

try_from_value

static ConfigResult<Document> holoscan::config::Document::try_from_value(
) noexcept

Try to create a document and compute its semantic identity.

Returns: The immutable document or a structured allocation/encoding failure.

Parameters

root
ConfigValue

Root value to share with the document.


Member variables

NameTypeDescription
state_std::shared_ptr< const detail::DocumentState >