A thread-safe storage for key-value pairs of varying types.
More...
#include <blackboard.hpp>
|
| | Blackboard () |
| | Default constructor for Blackboard.
|
| | Blackboard (const Blackboard &other) |
| | Copy constructor for Blackboard.
|
| template<class T> |
| void | set (const std::string &name, T value) |
| | Set a value in the blackboard.
|
| template<class T> |
| T | get (const std::string &key) const |
| | Retrieve a value from the blackboard.
|
| void | remove (const std::string &key) |
| | Remove a value from the blackboard.
|
| bool | contains (const std::string &key) const |
| | Check if a key exists in the blackboard.
|
| void | copy_value_from (const Blackboard &other, const std::string &source_key, const std::string &target_key) |
| | Copy a value from another blackboard.
|
| int | size () const |
| | Get the number of key-value pairs in the blackboard.
|
| std::vector< std::string > | keys () const |
| | Get the keys visible in the current remapping scope.
|
| std::string | get_type (const std::string &key) const |
| | Get the type of a value stored in the blackboard.
|
| std::string | to_string () const |
| | Convert the contents of the blackboard to a string.
|
| void | set_remappings (const Remappings &remappings) |
| | Set the remappings of the blackboard.
|
| const Remappings & | get_remappings () const noexcept |
| | Get the remappings of the blackboard.
|
|
| const std::string & | remap (const std::string &key) const |
| | Internal method that acquires the maped key. In the case the key is not remaped, retruns the arg key.
|
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.
◆ ConstSharedPtr
◆ ConstWeakPtr
◆ SharedPtr
◆ UniquePtr
◆ WeakPtr
◆ Blackboard() [1/2]
| Blackboard::Blackboard |
( |
| ) |
|
◆ Blackboard() [2/2]
| Blackboard::Blackboard |
( |
const Blackboard & | other | ) |
|
Copy constructor for Blackboard.
- Parameters
-
| other | The instance to copy from. |
The copied blackboard shares the underlying storage with other while keeping its own local remapping table.
◆ contains()
| bool Blackboard::contains |
( |
const std::string & | key | ) |
const |
Check if a key exists in the blackboard.
- Parameters
-
- Returns
- True if the key exists, false otherwise.
◆ copy_value_from()
| void Blackboard::copy_value_from |
( |
const Blackboard & | other, |
|
|
const std::string & | source_key, |
|
|
const std::string & | target_key ) |
Copy a value from another blackboard.
- Parameters
-
| other | The source blackboard. |
| source_key | The key to read from the source blackboard. |
| target_key | The key to write in this blackboard. |
The stored value is forwarded using the existing type-erased storage so the type does not need to be known at compile time.
◆ get()
template<class T>
| T yasmin::Blackboard::get |
( |
const std::string & | key | ) |
const |
|
inline |
Retrieve a value from the blackboard.
- Template Parameters
-
| T | The type of the value to retrieve. |
- Parameters
-
| name | The key associated with the value. |
- Returns
- The value associated with the specified key.
- Exceptions
-
| std::runtime_error | if the key does not exist. |
◆ get_remappings()
| const Remappings & Blackboard::get_remappings |
( |
| ) |
const |
|
noexcept |
Get the remappings of the blackboard.
- Returns
- The remappings of the blackboard.
◆ get_type()
| std::string Blackboard::get_type |
( |
const std::string & | key | ) |
const |
Get the type of a value stored in the blackboard.
- Parameters
-
| key | The key associated with the value. |
- Returns
- A string representation of the type.
- Exceptions
-
| std::runtime_error | if the key does not exist. |
◆ keys()
| std::vector< std::string > Blackboard::keys |
( |
| ) |
const |
Get the keys visible in the current remapping scope.
- Returns
- A sorted list of visible key names.
If one or more remappings point to a stored key, the remapped names are returned instead of the underlying storage key. Multiple remapped names can therefore refer to the same stored value.
◆ make_shared()
template<typename... Args>
| std::shared_ptr< Blackboard > yasmin::Blackboard::make_shared |
( |
Args &&... | args | ) |
|
|
inlinestatic |
◆ make_unique()
template<typename... Args>
| std::unique_ptr< Blackboard > yasmin::Blackboard::make_unique |
( |
Args &&... | args | ) |
|
|
inlinestatic |
◆ remap()
| const std::string & Blackboard::remap |
( |
const std::string & | key | ) |
const |
|
private |
Internal method that acquires the maped key. In the case the key is not remaped, retruns the arg key.
- Parameters
-
| other | The instance to copy from. |
◆ remove()
| void Blackboard::remove |
( |
const std::string & | key | ) |
|
Remove a value from the blackboard.
- Parameters
-
| key | The key associated with the value to remove. |
◆ set()
template<class T>
| void yasmin::Blackboard::set |
( |
const std::string & | name, |
|
|
T | value ) |
|
inline |
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. |
◆ set_remappings()
| void Blackboard::set_remappings |
( |
const Remappings & | remappings | ) |
|
Set the remappings of the blackboard.
- Parameters
-
◆ size()
| int Blackboard::size |
( |
| ) |
const |
Get the number of key-value pairs in the blackboard.
- Returns
- The size of the blackboard.
◆ to_string()
| std::string Blackboard::to_string |
( |
| ) |
const |
Convert the contents of the blackboard to a string.
- Returns
- A string representation of the blackboard.
◆ remappings
Storage for key remappings local to this blackboard handle.
◆ storage
Shared storage for key-value pairs and type information.
The documentation for this class was generated from the following files: