holoscan::MetadataDictionary

Beta
View as Markdown

Class to define a metadata dictionary object.

#include <holoscan/metadata.hpp>

Constructors

MetadataDictionary

inlineexplicit
holoscan::MetadataDictionary::MetadataDictionary(
const MetadataPolicy &policy = MetadataPolicy::kDefault
)

Destructor

~MetadataDictionary

virtual holoscan::MetadataDictionary::~MetadataDictionary() = default

Assignment operators

operator=


Methods

keys

std::vector<std::string> holoscan::MetadataDictionary::keys() const

Get a vector of the keys in the dictionary.

operator[]

std::shared_ptr<MetadataObject> & holoscan::MetadataDictionary::operator[](
const std::string &
)

Provide indexing into the underlying dictionary.

get

std::shared_ptr<MetadataObject> holoscan::MetadataDictionary::get(
const std::string &key
) const

Get a shared pointer to the MetadataObject corresponding to the provided key.

See the templated variant of get for a version of this method that extracts the std::any value from the MetadataObject and performs the any_cast<ValueT> operation on it.

Returns: The value corresponding to the key

Parameters

key
const std::string &

The key for the value to retrieve.

set

void holoscan::MetadataDictionary::set(
const std::string &key,
std::shared_ptr<MetadataObject> value
)

Insert a new value at the specified key (or update an existing one).

This method inserts a new item. If the key already exists, this method will have a behavior that depends on the policy (MetadataPolicy) set for this dictionary.

For this method, kInplaceUpdate behaves the same as kUpdate.

Parameters

key
const std::string &

The key for the value to insert (or update).

value
std::shared_ptr<MetadataObject>

The value to store.

policy

void holoscan::MetadataDictionary::policy(
const MetadataPolicy &metadata_policy
)

Set the metadata policy used by this MetadataDictionary.

has_key

bool holoscan::MetadataDictionary::has_key(
const std::string &key
) const

Determine if an item already exists in the dictionary.

Returns: Returns true if the key already exists in the dictionary, false otherwise.

Parameters

key
const std::string &

The key for the value to insert (or update).

erase

bool holoscan::MetadataDictionary::erase(
const std::string &key
)

Erase an item from the dictionary.

Returns: Returns true if the key was erased and false if the key was not found.

Parameters

key
const std::string &

The key of the item to erase.

begin

Iterator holoscan::MetadataDictionary::begin()

begin() iterator of the underlying dictionary

end

Iterator holoscan::MetadataDictionary::end()

end() iterator of the underlying dictionary

find

Iterator holoscan::MetadataDictionary::find(
const std::string &key
)

find() on the underlying dictionary. Returns an iterator to the element if found, else end()

clear

void holoscan::MetadataDictionary::clear()

clear all values from the dictionary

size

std::size_t holoscan::MetadataDictionary::size() const

return the number of items in the dictionary

swap

void holoscan::MetadataDictionary::swap(
MetadataDictionary &other
) noexcept

swap the contents of this dictionary and other

deep_copy

MetadataDictionary holoscan::MetadataDictionary::deep_copy() const

Create a deep copy of this dictionary.

Creates a new MetadataDictionary with its own independent copy of the underlying map and MetadataObjects. This is useful when you need to store a snapshot of metadata that won’t be affected by subsequent modifications to the original.

Returns: A new MetadataDictionary with independent copies of all data

merge

void holoscan::MetadataDictionary::merge(
MetadataDictionary &other
)

merge (move) the contents of other dictionary into this dictionary

insert

void holoscan::MetadataDictionary::insert(
MetadataDictionary &other
)

Insert items the other dictionary into this dictionary.

Pre-existing values are not updated.

update

void holoscan::MetadataDictionary::update(
MetadataDictionary &other
)

Update the dictionary with items present in other.

This method will update the dictionary with values from other. If a key already exists in this dictionary, the behavior is determined by the policy (MetadataPolicy) set for this dictionary.

For this method, kInplaceUpdate behaves the same as kUpdate.

Parameters

other
MetadataDictionary &

Metadata dictionary to copy items from

ensure_unique

bool holoscan::MetadataDictionary::ensure_unique()

If the dictionary is shared, make a copy of it so that it is unique.


Types

Typedefs

NameDefinition
MapTypestd::unordered_map< std::string, std::shared_ptr< MetadataObject > >
IteratorMapType::iterator
ConstIteratorMapType::const_iterator

Member variables

NameTypeDescription
dictionary_std::shared_ptr< MapType >The underlying dictionary object.
policy_MetadataPolicyThe policy for handling metadata.