16#ifndef YASMIN__BLACKBOARD__BLACKBOARD_HPP
17#define YASMIN__BLACKBOARD__BLACKBOARD_HPP
46 std::map<std::string, BlackboardValueInterface *>
values;
54 const std::string &
remap(
const std::string &key);
75 template <
class T> T
get(
const std::string &key) {
79 std::lock_guard<std::recursive_mutex> lk(this->mutex);
82 throw std::runtime_error(
"Element " + key +
83 " does not exist in the blackboard");
88 return b_value->
get();
97 template <
class T>
void set(std::string name, T value) {
101 std::lock_guard<std::recursive_mutex> lk(this->mutex);
105 this->values.insert({name, b_value});
116 void remove(
const std::string &key);
123 bool contains(
const std::string &key);
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
const std::string & remap(const std::string &key)
Internal method that acquires the maped key. In the case the key is not remaped, retruns the arg key.
Definition blackboard.cpp:74
T get(const std::string &key)
Retrieve a value from the blackboard.
Definition blackboard.hpp:75
std::map< std::string, std::string > remapping
Storage for key-value pairs.
Definition blackboard.hpp:48
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:97
int size()
Get the number of key-value pairs in the blackboard.
Definition blackboard.cpp:56
Blackboard()
Default constructor for Blackboard.
Definition blackboard.cpp:23
void set_remapping(const std::map< std::string, std::string > &remapping)
Set the remapping of the blackboard.
Definition blackboard.cpp:82
const std::map< std::string, std::string > & get_remapping()
Get the remapping of the blackboard.
Definition blackboard.cpp:87
void remove(const std::string &key)
Remove a value from the blackboard.
Definition blackboard.cpp:38
~Blackboard()
Destructor for Blackboard.
Definition blackboard.cpp:31
bool contains(const std::string &key)
Check if a key exists in the blackboard.
Definition blackboard.cpp:47
std::recursive_mutex mutex
Mutex for thread safety.
Definition blackboard.hpp:44
std::string to_string()
Convert the contents of the blackboard to a string.
Definition blackboard.cpp:61
#define YASMIN_LOG_DEBUG(text,...)
Definition logs.hpp:159
Definition blackboard.hpp:30
Definition blackboard.hpp:29