holoscan::CodecRegistry

Beta
View as Markdown

Class to set codecs for data types.

This class is used to set codecs (serializer + deserializer) for data types.

#include <holoscan/codec_registry.hpp>

Constructors

CodecRegistry


Methods

get_codec

Codec & holoscan::CodecRegistry::get_codec(
const std::type_index &index
)

Get the codec function pair.

Returns: The reference to the Codec object.

Parameters

index
const std::type_index &

The type index of the parameter.

get_serializer

SerializeFunc & holoscan::CodecRegistry::get_serializer(
const std::string &codec_name
)

Get the serializer function.

Returns: The reference to the Serializer function.

Parameters

codec_name
const std::string &

The name of the codec.

get_deserializer

DeserializeFunc & holoscan::CodecRegistry::get_deserializer(
const std::string &codec_name
)

Get the deserializer function.

Returns: The reference to the Deserializer function.

Parameters

codec_name
const std::string &

The name of the codec.

name_to_index

expected<std::type_index, RuntimeError> holoscan::CodecRegistry::name_to_index(
const std::string &codec_name
)

Get the std::type_index corresponding to a codec name.

Returns: The std::type_index corresponding to the name.

Parameters

codec_name
const std::string &

The name of the codec.

index_to_name

expected<std::string, RuntimeError> holoscan::CodecRegistry::index_to_name(
const std::type_index &index
)

Get the codec name corresponding to a std::type_index.

Returns: The name of the codec.

Parameters

index
const std::type_index &

The std::type_index corresponding to the parameter.

add_codec

template <typename typeT>
void holoscan::CodecRegistry::add_codec(
std::pair<SerializeFunc, DeserializeFunc> &codec,
const std::string &codec_name,
bool overwrite = true
)

Add a codec for the type.

Template parameters

typeT
typename

The type of the parameter.

Parameters

codec
std::pair<SerializeFunc, DeserializeFunc> &

A pair containing a serialization function and deserialization function.

codec_name
const std::string &

The name of the codec to add.

overwrite
boolDefaults to true

If true, any existing codec with matching codec_name will be overwritten.


Static methods

get_instance

static CodecRegistry & holoscan::CodecRegistry::get_instance()

Get the instance object.

Returns: The reference to the CodecRegistry instance.

serialize

static expected<size_t, RuntimeError> holoscan::CodecRegistry::serialize(
const Message &message,
holoscan::Endpoint *endpoint
)

Serialize the message object.

Parameters

message
const Message &

The message to serialize.

endpoint
holoscan::Endpoint *

The serialization endpoint (buffer).

deserialize

template <typename typeT>
static expected<Message, RuntimeError> holoscan::CodecRegistry::deserialize(
holoscan::Endpoint *endpoint
)

Deserialize the message object.

Template parameters

typeT
typename

The data type within the message.

Parameters

endpoint
holoscan::Endpoint *

The serialization endpoint (buffer).


Types

Typedefs

NameDefinitionDescription
SerializeFuncstd::function< expected< size_t, RuntimeError >(const Message &, holoscan::Endpoint *)>Function type for serializing a data type.
DeserializeFuncstd::function< expected< Message, RuntimeError >(holoscan::Endpoint *)>Function type for deserializing a data type.
Codecstd::pair< SerializeFunc, DeserializeFunc >Function pair type for serialization and deserialization of a data type.

Member variables

NameTypeDescription
none_serialize staticSerializeFunc
none_deserialize staticDeserializeFunc
none_codec staticCodecDefault Codec for Arg.
index_to_name_map_std::unordered_map< std::type_index, std::string >Mapping from type_index to name.
name_to_index_map_std::unordered_map< std::string, std::type_index >Mapping from name to type_index.
codec_map_std::unordered_map< std::string, std::pair< SerializeFunc, DeserializeFunc > >Map of codec name to codec function pair.