16#ifndef YASMIN__BLACKBOARD__BLACKBOARD_HPP
17#define YASMIN__BLACKBOARD__BLACKBOARD_HPP
46 std::map<std::string, BlackboardValueInterface *>
values;
67 template <
class T> T
get(std::string name) {
71 std::lock_guard<std::recursive_mutex> lk(this->mutex);
74 throw std::runtime_error(
"Element " + name +
75 " does not exist in the blackboard");
79 return b_value->
get();
88 template <
class T>
void set(std::string name, T value) {
92 std::lock_guard<std::recursive_mutex> lk(this->mutex);
96 this->values.insert({name, b_value});
107 void remove(std::string name);
A template class that wraps a value of type T.
Definition blackboard_value.hpp:41
T get()
Retrieve the stored value.
Definition blackboard_value.hpp:56
A thread-safe storage for key-value pairs of varying types.
Definition blackboard.hpp:41
std::map< std::string, BlackboardValueInterface * > values
Storage for key-value pairs.
Definition blackboard.hpp:46
void set(std::string name, T value)
Set a value in the blackboard.
Definition blackboard.hpp:88
int size()
Get the number of key-value pairs in the blackboard.
Definition blackboard.cpp:53
T get(std::string name)
Retrieve a value from the blackboard.
Definition blackboard.hpp:67
Blackboard()
Default constructor for Blackboard.
Definition blackboard.cpp:23
bool contains(std::string name)
Check if a key exists in the blackboard.
Definition blackboard.cpp:46
~Blackboard()
Destructor for Blackboard.
Definition blackboard.cpp:31
std::recursive_mutex mutex
Mutex for thread safety.
Definition blackboard.hpp:44
void remove(std::string name)
Remove a value from the blackboard.
Definition blackboard.cpp:38
std::string to_string()
Convert the contents of the blackboard to a string.
Definition blackboard.cpp:58
#define YASMIN_LOG_DEBUG(text,...)
Definition logs.hpp:74
Definition blackboard.hpp:29