peary::utils::dictionary

Dictionary class for storing elements for lookup. More…

#include <peary/utils/dictionary.hpp>

Public Functions

Name
dictionary(std::string title)Default constructor for dictionary.
virtual ~dictionary() =defaultDefault constructor for dictionary.
template <class C > void add(std::string name, const C elem)Add a new element to the dictionary.
void add(const std::vector< std::pair< std::string, T » elements)Add multiple elements to the dictionary.
template <class C > void add(std::string name, std::shared_ptr< C > elem)Add a new element to the dictionary.
void add(const std::vector< std::pair< std::string, std::shared_ptr< T »> elements)Add multiple elements to the dictionary.
T get(std::string name) constGet the element associated with the given name.
template <typename C > std::shared_ptr< C > get(std::string name) constGet a shared pointer to the component configuration associated with the given name.
bool has(std::string name) constCheck if the dictionary contains an element with the given name.
size_t size() constGet the size of the dictionary.
std::vector< std::string > getNames() constGet all register names in the dictionary.
template <typename C > std::vector< std::string > getNames() constGet all register names in the dictionary that are of a specific type.

Detailed Description

  template <class T >
class peary::utils::dictionary;
  

Dictionary class for storing elements for lookup.

Template Parameters:

  • T The type of the elements to be stored in the dictionary

Public Functions Documentation

function dictionary

  inline explicit dictionary(
    std::string title
)
  

Default constructor for dictionary.

Parameters:

  • title The title of the dictionary, used for error messages

function ~dictionary

  virtual ~dictionary() =default
  

Default constructor for dictionary.

function add

  template <class C >
inline void add(
    std::string name,
    const C elem
)
  

Add a new element to the dictionary.

Parameters:

  • name The name of the element, which will be converted to lowercase
  • elem The element to be added, which will be copied

Template Parameters:

  • C The type of the element to be added

function add

  inline void add(
    const std::vector< std::pair< std::string, T >> elements
)
  

Add multiple elements to the dictionary.

Parameters:

  • elements A vector of pairs, where each pair contains a name and an element

Template Parameters:

  • T The type of the elements to be added

function add

  template <class C >
inline void add(
    std::string name,
    std::shared_ptr< C > elem
)
  

Add a new element to the dictionary.

Parameters:

  • name The name of the element, which will be converted to lowercase
  • elem A shared pointer to the element to be added

Template Parameters:

  • C The type of the element to be added

function add

  inline void add(
    const std::vector< std::pair< std::string, std::shared_ptr< T >>> elements
)
  

Add multiple elements to the dictionary.

Parameters:

  • elements A vector of pairs, where each pair contains a name and a shared pointer to an element

Template Parameters:

  • T The type of the elements to be added

function get

  inline T get(
    std::string name
) const
  

Get the element associated with the given name.

Parameters:

  • name The name of the element

Return: The element associated with the given name

function get

  template <typename C >
inline std::shared_ptr< C > get(
    std::string name
) const
  

Get a shared pointer to the component configuration associated with the given name.

Parameters:

  • name The name of the element

Template Parameters:

  • C The type of the component configuration to be retrieved

Return: A shared pointer to the element associated with the given name

function has

  inline bool has(
    std::string name
) const
  

Check if the dictionary contains an element with the given name.

Parameters:

  • name The name of the element to check for

function size

  inline size_t size() const
  

Get the size of the dictionary.

Return: The number of elements in the dictionary

function getNames

  inline std::vector< std::string > getNames() const
  

Get all register names in the dictionary.

Return: A vector of strings containing all register names

function getNames

  template <typename C >
inline std::vector< std::string > getNames() const
  

Get all register names in the dictionary that are of a specific type.

Template Parameters:

  • C The type of the elements to filter by

Return: A vector of strings containing the names of elements that are of type C


Updated on 2025-11-14 at 11:31:23 +0100