IDS peak ICV v1.1.0
Loading...
Searching...
No Matches
Metadata Class Reference

Public Member Functions

None __init__ (self)
 Initialize an empty metadata container.
 
None set_value_by_name (self, str key, Any value)
 Store a value using a string-based key.
 
bool has_entry_by_name (self, str key)
 Check if a string key is present in the metadata.
 
Any try_get_value_by_name (self, str key)
 Retrieve a value by string key, returning None if not found.
 
T get_value_by_name (self, Type[T] expected_type, str key)
 Retrieve the value for a key and validate that it is of the expected type.
 
None set_value_by_key (self, MetadataKey key, Any value)
 Store a value using a strongly typed metadata key.
 
bool has_entry_by_key (self, MetadataKey key)
 Check if a strongly typed metadata key is present and matches the expected type.
 
Any get_value_by_key (self, MetadataKey key)
 Retrieve the value of a strongly typed metadata key.
 
List[str] get_key_names (self)
 Returns a list of metadata key names.
 
bool __eq__ (self, Any other)
 Check if two metadata are equal.
 
bool __ne__ (self, Any other)
 Check if two metadata are not equal.
 
str __str__ (self)
 Return a human-readable string of metadata keys and values.
 
str __repr__ (self)
 Return an unambiguous string of the Metadata object.
 

Protected Attributes

dict _data = {}
 

Detailed Description

A type-safe container for metadata key-value pairs.

This class provides a flexible mechanism for storing and retrieving metadata:

  • Arbitrary runtime keys (string string_values).
  • Strongly typed keys defined in a schema.

Values are stored in a Python dictionary but accessed with additional safety checks to ensure type correctness.

Example usage::

metadata = Metadata()
metadata.set_value_by_key(MetadataKey.DEVICE_FRAME_ID, 1)
print(metadata.get_value_by_key(MetadataKey.DEVICE_FRAME_ID)) # outputs: 1
print(metadata.has_entry_by_key(MetadataKey.DEVICE_FRAME_ID)) # outputs: True

Definition at line 9 of file metadata.py.

Constructor & Destructor Documentation

◆ __init__()

None __init__ ( self)

Initialize an empty metadata container.

Definition at line 31 of file metadata.py.

Member Function Documentation

◆ __eq__()

bool __eq__ ( self,
Any other )

Check if two metadata are equal.

Parameters
otherAnother Metadata object
Returns
True if metadata are equal, False otherwise

Definition at line 146 of file metadata.py.

◆ __ne__()

bool __ne__ ( self,
Any other )

Check if two metadata are not equal.

Parameters
otherAnother metadata object
Returns
True if metadata are not equal, False otherwise

Definition at line 159 of file metadata.py.

◆ __repr__()

str __repr__ ( self)

Return an unambiguous string of the Metadata object.

Definition at line 182 of file metadata.py.

◆ __str__()

str __str__ ( self)

Return a human-readable string of metadata keys and values.

Example: { "DeviceFrameID": 42, "DeviceTimestamp": 1695472000, "custom_data": "xyz" }

Definition at line 170 of file metadata.py.

◆ get_key_names()

List[str] get_key_names ( self)

Returns a list of metadata key names.

Returns
A list of metadata key names

Definition at line 137 of file metadata.py.

◆ get_value_by_key()

Any get_value_by_key ( self,
MetadataKey key )

Retrieve the value of a strongly typed metadata key.

Parameters
keyA MetadataKey object.
Exceptions
OutOfRangeExceptionIf the key does not exist.
InvalidCastExceptionIf the type does not match.
Returns
The stored value.

Definition at line 116 of file metadata.py.

◆ get_value_by_name()

T get_value_by_name ( self,
Type[T] expected_type,
str key )

Retrieve the value for a key and validate that it is of the expected type.

Parameters
expected_typeThe expected type of the stored value.
keyThe metadata key.
Exceptions
OutOfRangeExceptionIf the key does not exist.
InvalidCastExceptionIf the stored type does not match.
Returns
The stored value cast to the expected type.

Definition at line 66 of file metadata.py.

◆ has_entry_by_key()

bool has_entry_by_key ( self,
MetadataKey key )

Check if a strongly typed metadata key is present and matches the expected type.

Parameters
keyA MetadataKey object.
Returns
True if the key exists and type matches, False otherwise.

Definition at line 104 of file metadata.py.

◆ has_entry_by_name()

bool has_entry_by_name ( self,
str key )

Check if a string key is present in the metadata.

Parameters
keyThe metadata key.
Returns
True if the key exists, False otherwise.

Definition at line 46 of file metadata.py.

◆ set_value_by_key()

None set_value_by_key ( self,
MetadataKey key,
Any value )

Store a value using a strongly typed metadata key.

Parameters
keyA MetadataKey object containing key name and expected type.
valueThe value to store.
Exceptions
InvalidCastExceptionIf the value type does not match the trait type.

Definition at line 88 of file metadata.py.

◆ set_value_by_name()

None set_value_by_name ( self,
str key,
Any value )

Store a value using a string-based key.

Parameters
keyRuntime string string_value.
valueValue to store.

Definition at line 36 of file metadata.py.

◆ try_get_value_by_name()

Any try_get_value_by_name ( self,
str key )

Retrieve a value by string key, returning None if not found.

Parameters
keyThe metadata key.
Returns
The stored value if found, otherwise None.

Definition at line 56 of file metadata.py.

Field Documentation

◆ _data

dict _data = {}
protected

Definition at line 34 of file metadata.py.