class dlstreamer::Dictionary#

Overview#

Dictionary is general-purpose key-value container. More…

#include <dictionary.h>

class Dictionary {
public:
    // methods

    virtual std::string name() const = 0;
    virtual std::vector<std::string> keys() const = 0;
    virtual std::optional<Any> try_get(std::string_view key) const = 0;
    virtual std::pair<const void*, size_t> try_get_array(std::string_view key) const = 0;
    virtual void set(std::string_view key, Any value) = 0;
    virtual void set_array(std::string_view key, const void* data, size_t nbytes) = 0;
    virtual void set_name(std::string const& name) = 0;

    template <typename T>
    T get(std::string_view key) const;

    template <typename T>
    T get(std::string_view key, T default_value) const;

    template <class T>
    const std::vector<T> get_array(std::string_view key) const;
};

// direct descendants

class BaseDictionary;
class DictionaryProxy;
class GSTDictionary;
class GSTROIDictionary;

Detailed Documentation#

Dictionary is general-purpose key-value container.

Methods#

virtual std::string name() const = 0

Returns dictionary name. Utility function find_metadata uses it to find metadata by specified name.

virtual std::vector<std::string> keys() const = 0

Returns a vector of all the available keys in the dictionary.

virtual std::optional<Any> try_get(std::string_view key) const = 0

Returns dictionary element by key. If no handle with the specified key, returns empty std::optional.

Parameters:

key

the key of the dictionary element to find

virtual std::pair<const void*, size_t> try_get_array(std::string_view key) const = 0

Returns memory buffer stored in dictionary. The first element of returned std::pair is pointer to memory buffer, second element is buffer size in bytes. If no buffer with the specified key, returns {nullptr,0}.

Parameters:

key

the key of the memory buffer to find

virtual void set(std::string_view key, Any value) = 0

Adds element into the dictionary. If the dictionary already contains an element with specified key, the existing value will be overwritten.

Parameters:

key

the key of the element to add

value

the value of the element to add

virtual void set_array(std::string_view key, const void* data, size_t nbytes) = 0

Allocates memory buffer and copies data from buffer specified in function parameters, and adds memory buffer to the dictionary. If the dictionary already contains an buffer with specified key, the existing buffer will be overwritten.

Parameters:

key

the key of the memory buffer to add

data

pointer to the memory buffer to add

nbytes

size (in bytes) of the memory buffer to add

virtual void set_name(std::string const& name) = 0

Sets name of dictionary. The existing name will be overwritten.

Parameters:

name

dictionary name