Type-safe container for image acquisition metadata.
More...
#include <peak_common/types/peak_common_metadata.hpp>
|
| template<typename T> |
| void | SetValueByName (const std::string &name, T &&value) |
| | Stores a value using a string-based name.
|
| void | RemoveEntryByName (const std::string &name) |
| | Removes the entry using a string-based name.
|
| template<MetadataKey metadataKey, typename T> |
| void | SetValueByKey (T value) |
| | Stores a value using a strongly typed metadata key.
|
| bool | HasEntryByName (const std::string &name) const |
| | Checks if a given string key is stored in the metadata.
|
| template<MetadataKey metadataKey> |
| bool | HasEntryByKey () const |
| | Checks if a known key is stored in the metadata.
|
| Any | TryGetValueByName (const std::string &name) const |
| | Retrieves a value by string name as a type-erased object.
|
| template<typename T> |
| T | GetValueByName (const std::string &name) const |
| | Retrieves and casts the value associated with a string name.
|
| template<MetadataKey metadataKey> |
| detail::MetadataKeyTraits< metadataKey >::type | GetValueByKey () const |
| | Retrieves the value of a strongly typed metadata key.
|
| std::string | ToString () const |
| | Returns a string representation of the metadata.
|
| std::vector< std::string > | GetKeyNames () const |
| | Returns a vector of key names.
|
|
| std::ostream & | operator<< (std::ostream &os, const Metadata &metadata) |
| | Outputs the metadata keys in human-readable form.
|
Type-safe container for image acquisition metadata.
The Metadata class is a flexible container for storing key-value pairs.
It supports both:
- Arbitrary runtime keys using string identifiers (*ByName functions).
- Strongly typed compile-time keys via metadata traits (*ByKey functions).
Values are stored using a type-erased mechanism (Any) and can be retrieved either by casting or by trait-based access.
- Since
- ids_peak_common 1.0
◆ GetKeyNames()
| std::vector< std::string > GetKeyNames |
( |
| ) |
const |
|
inline |
Returns a vector of key names.
- Returns
- A vector of key names
- Since
- ids_peak_common 1.1
◆ GetValueByKey()
| detail::MetadataKeyTraits< metadataKey >::type GetValueByKey |
( |
| ) |
const |
|
inline |
Retrieves the value of a strongly typed metadata key.
Provides type-safe access to known metadata keys, defined in MetadataKey.
- Template Parameters
-
| metadataKey | The strongly typed metadata key. |
- Exceptions
-
- Returns
- The stored value of type
MetadataKeyTraits<metadataKey>::type.
- Since
- ids_peak_common 1.0
◆ GetValueByName()
template<typename T>
| T GetValueByName |
( |
const std::string & | name | ) |
const |
|
inline |
Retrieves and casts the value associated with a string name.
- Template Parameters
-
| T | The expected type of the stored value. |
- Parameters
-
| name | The name of the metadata entry. |
- Exceptions
-
- Returns
- The value cast to the requested type.
- Since
- ids_peak_common 1.0
◆ HasEntryByKey()
| bool HasEntryByKey |
( |
| ) |
const |
|
inline |
Checks if a known key is stored in the metadata.
Verifies that the key exists and that the stored type matches the expected trait type.
- Template Parameters
-
| metadataKey | The strongly typed metadata key. |
- Returns
- True if the key exists and the type matches, false otherwise.
- Since
- ids_peak_common 1.0
◆ HasEntryByName()
| bool HasEntryByName |
( |
const std::string & | name | ) |
const |
|
inline |
Checks if a given string key is stored in the metadata.
- Parameters
-
| name | The key to check for. |
- Returns
- True if the key exists, false otherwise.
- Since
- ids_peak_common 1.0
◆ RemoveEntryByName()
| void RemoveEntryByName |
( |
const std::string & | name | ) |
|
|
inline |
Removes the entry using a string-based name.
If the key does not exist, nothing happens.
- Parameters
-
| name | A runtime string identifier. |
- Since
- ids_peak_common 2.0
◆ SetValueByKey()
| void SetValueByKey |
( |
T | value | ) |
|
|
inline |
Stores a value using a strongly typed metadata key.
Ensures compile-time type safety using known metadata traits.
Known metadata keys are defined in the enum MetadataKey.
- Template Parameters
-
| metadataKey | A known metadata key (e.g. MetadataKey::DeviceTimestamp). |
| T | Type of the value. Must match detail::MetadataKeyTraits<metadataKey>::type. |
- Parameters
-
- Since
- ids_peak_common 1.0
◆ SetValueByName()
template<typename T>
| void SetValueByName |
( |
const std::string & | name, |
|
|
T && | value ) |
|
inline |
Stores a value using a string-based name.
- Template Parameters
-
| T | Type of the value to store. |
- Parameters
-
| name | A runtime string identifier. |
| value | The value to store. |
- Since
- ids_peak_common 1.0
◆ ToString()
| std::string ToString |
( |
| ) |
const |
|
inline |
Returns a string representation of the metadata.
Equivalent to writing the object to a stream with operator<<.
- Returns
- A formatted string listing the metadata keys.
- Since
- ids_peak_common 1.0
◆ TryGetValueByName()
| Any TryGetValueByName |
( |
const std::string & | name | ) |
const |
|
inline |
Retrieves a value by string name as a type-erased object.
- Parameters
-
| name | The name of the metadata entry. |
- Returns
- A Any object containing the value, or empty if not found.
- Since
- ids_peak_common 1.0
◆ operator<<
| std::ostream & operator<< |
( |
std::ostream & | os, |
|
|
const Metadata & | metadata ) |
|
friend |
Outputs the metadata keys in human-readable form.
Values are not printed since their types are unknown at runtime.
- Parameters
-
| os | The output stream. |
| metadata | The metadata to print. |
- Returns
- Reference to the stream.
- Since
- ids_peak_common 1.0
The documentation for this class was generated from the following file: