Class BlackboardPyWrapper
Defined in File blackboard_pywrapper.hpp
Class Documentation
-
class BlackboardPyWrapper
Python-facing wrapper around the native Blackboard.
The underlying Blackboard stores strongly typed C++ values. This wrapper translates common Python types into matching C++ types on write and converts them back into Python objects on read.
Supported scalar mappings:
bool <-> bool
int <-> std::int64_t
float <-> double
str <-> std::string
bytes / bytearray <-> std::vector<uint8_t>
Supported homogeneous container mappings:
list[str] / tuple[str, …] <-> std::vector<std::string>
list[int] / tuple[int, …] <-> std::vector<std::int64_t>
list[float] / tuple[float, …] <-> std::vector<double>
list[bool] / tuple[bool, …] <-> std::vector<bool>
dict[str, str] <-> std::unordered_map<std::string, std::string>
dict[str, int] <-> std::unordered_map<std::string, std::int64_t>
dict[str, float] <-> std::unordered_map<std::string, double>
dict[str, bool] <-> std::unordered_map<std::string, bool>
Mixed containers, nested containers, and empty containers are stored as py::object because no unique native C++ element type can be inferred safely.
Public Functions
-
inline BlackboardPyWrapper()
Construct a wrapper with a newly created native Blackboard.
-
inline BlackboardPyWrapper(Blackboard &&other)
Construct a wrapper by moving an existing native Blackboard.
- Parameters:
other – Native blackboard instance to move into shared ownership.
Construct a wrapper from an existing shared native Blackboard.
- Parameters:
bb_ptr – Shared pointer to a native Blackboard.
-
inline void set(const std::string &key, py::object value)
Store a Python object in the blackboard.
The wrapper first tries to map the value to a native C++ type. If no safe native mapping exists, the value is stored as py::object.
- Parameters:
key – Blackboard key.
value – Python object to store.
-
inline py::object get(const std::string &key) const
Retrieve a Python object from the blackboard.
The native blackboard stores the type name of each entry. This method uses that exact stored type information to select the matching conversion path.
- Parameters:
key – Blackboard key.
- Returns:
Python object reconstructed from the stored native value.
-
inline void remove(const std::string &key)
Remove a value from the blackboard.
- Parameters:
key – Blackboard key to remove.
-
inline bool contains(const std::string &key) const
Check whether a key exists in the blackboard.
- Parameters:
key – Blackboard key to test.
- Returns:
True if the key exists.
-
inline int size() const
Get the number of entries in the blackboard.
- Returns:
Number of stored key-value pairs.
-
inline std::string to_string() const
Get a string representation of the blackboard contents.
- Returns:
Human-readable description of the stored keys and types.
-
inline void set_remappings(const Remappings &remappings)
Set key remappings on the underlying blackboard.
- Parameters:
remappings – Remapping table to apply.
-
inline const Remappings &get_remappings() const
Get the current key remappings.
- Returns:
Reference to the underlying remapping table.
-
inline Blackboard::SharedPtr get_cpp_blackboard() const
Access the underlying native blackboard.
- Returns:
Shared pointer to the native blackboard instance.