Skip to content

Commit b382cfb

Browse files
committed
adding type registry toblackboard
1 parent a398194 commit b382cfb

6 files changed

Lines changed: 130 additions & 472 deletions

File tree

yasmin/include/yasmin/blackboard/blackboard.hpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ class Blackboard {
4444
std::recursive_mutex mutex;
4545
/// Storage for key-value pairs.
4646
std::map<std::string, BlackboardValueInterface *> values;
47-
/// Storage for key-value pairs.
47+
/// Storage for type information for each key.
48+
std::map<std::string, std::string> type_registry;
49+
/// Storage for key remapping.
4850
std::map<std::string, std::string> remapping;
4951

5052
/** @brief Internal method that acquires the maped key. In the case the key is
@@ -62,8 +64,8 @@ class Blackboard {
6264
*/
6365
Blackboard(const Blackboard &other);
6466

65-
/** @brief Destructor for Blackboard. */
66-
~Blackboard();
67+
/** @brief Virtual destructor for Blackboard. */
68+
virtual ~Blackboard();
6769

6870
/**
6971
* @brief Retrieve a value from the blackboard.
@@ -103,9 +105,12 @@ class Blackboard {
103105
if (!this->contains(name)) {
104106
BlackboardValue<T> *b_value = new BlackboardValue<T>(value);
105107
this->values.insert({name, b_value});
108+
this->type_registry.insert({name, b_value->get_type()});
106109

107110
} else {
108-
((BlackboardValue<T> *)this->values.at(name))->set(value);
111+
BlackboardValue<T> *b_value = (BlackboardValue<T> *)this->values.at(name);
112+
b_value->set(value);
113+
this->type_registry[name] = b_value->get_type();
109114
}
110115
}
111116

@@ -128,6 +133,14 @@ class Blackboard {
128133
*/
129134
int size();
130135

136+
/**
137+
* @brief Get the type of a value stored in the blackboard.
138+
* @param key The key associated with the value.
139+
* @return A string representation of the type.
140+
* @throws std::runtime_error if the key does not exist.
141+
*/
142+
std::string get_type(const std::string &key);
143+
131144
/**
132145
* @brief Convert the contents of the blackboard to a string.
133146
* @return A string representation of the blackboard.

0 commit comments

Comments
 (0)