Class Blackboard

Class Documentation

class Blackboard

A thread-safe storage for key-value pairs of varying types.

The Blackboard class allows storing, retrieving, and managing values associated with string keys in a thread-safe manner using a recursive mutex. Values are stored as pointers to BlackboardValueInterface instances.

Public Functions

Blackboard()

Default constructor for Blackboard.

Blackboard(const Blackboard &other)

Copy constructor for Blackboard.

Parameters:

other – The instance to copy from.

~Blackboard()

Destructor for Blackboard.

template<class T>
inline T get(const std::string &key)

Retrieve a value from the blackboard.

Template Parameters:

T – The type of the value to retrieve.

Parameters:

name – The key associated with the value.

Throws:

std::runtime_error – if the key does not exist.

Returns:

The value associated with the specified key.

template<class T>
inline void set(std::string name, T value)

Set a value in the blackboard.

Template Parameters:

T – The type of the value to store.

Parameters:
  • name – The key to associate with the value.

  • value – The value to store.

void remove(const std::string &key)

Remove a value from the blackboard.

Parameters:

key – The key associated with the value to remove.

bool contains(const std::string &key)

Check if a key exists in the blackboard.

Parameters:

key – The key to check.

Returns:

True if the key exists, false otherwise.

int size()

Get the number of key-value pairs in the blackboard.

Returns:

The size of the blackboard.

std::string to_string()

Convert the contents of the blackboard to a string.

Returns:

A string representation of the blackboard.

void set_remapping(const std::map<std::string, std::string> &remapping)

Set the remapping of the blackboard.

Parameters:

remapping – The remapping to set.

const std::map<std::string, std::string> &get_remapping()

Get the remapping of the blackboard.

Returns:

The remapping of the blackboard.