![]() |
Olympe Engine 2.0
2D Game Engine with ECS Architecture
|
Simple map-based blackboard for task graph runtime state. More...
#include <LocalBlackboard.h>
Inheritance diagram for Olympe::LocalBlackboard:Public Member Functions | |
| LocalBlackboard () | |
| Default constructor. | |
| void | Initialize (const TaskGraphTemplate &tmpl) |
| Initialises the blackboard from a template. | |
| void | Reset () |
| Resets all variables to their default values. | |
| TaskValue | GetValue (const std::string &varName) const |
| Returns the current value of a variable. | |
| void | SetValue (const std::string &varName, const TaskValue &value) |
| Sets the value of a variable. | |
| bool | HasVariable (const std::string &varName) const |
| Returns true if a variable with the given name is registered. | |
| std::vector< std::string > | GetVariableNames () const |
| Returns all registered variable names (useful for debugging / editor). | |
| void | Serialize (std::vector< uint8_t > &outBytes) const |
| Serializes all variable names and typed values into a byte buffer. | |
| void | Deserialize (const std::vector< uint8_t > &inBytes) |
| Restores variable values from a byte buffer produced by Serialize(). | |
| void | InitializeFromEntries (const std::vector< BlackboardEntry > &entries) |
| Initializes the blackboard from a vector of BlackboardEntry (ATS VS schema v4). | |
| void | SetValueScoped (const std::string &scopedKey, const TaskValue &value) |
| Sets a value using a scoped key (prefix "local:" is stripped). | |
| TaskValue | GetValueScoped (const std::string &scopedKey) const |
| Gets a value using a scoped key (prefix "local:" is stripped). | |
Private Attributes | |
| std::unordered_map< std::string, TaskValue > | m_variables |
| Current values for each registered variable. | |
| std::unordered_map< std::string, TaskValue > | m_defaults |
| Default (initial) values used by Reset(). | |
| std::unordered_map< std::string, VariableType > | m_types |
| Declared type of each variable (used for type validation in SetValue). | |
Simple map-based blackboard for task graph runtime state.
Variables must be registered via Initialize() before use. SetValue() enforces type compatibility: the new value must match the declared type of the variable. Throws std::runtime_error on unknown variable or type mismatch.
Definition at line 37 of file LocalBlackboard.h.
| Olympe::LocalBlackboard::LocalBlackboard | ( | ) |
Default constructor.
Blackboard is empty until Initialize() is called.
Definition at line 24 of file LocalBlackboard.cpp.
Restores variable values from a byte buffer produced by Serialize().
The blackboard schema (m_types) must already be initialised via Initialize() before calling this method. Unknown variable names and type-mismatched entries are skipped with a warning log. The buffer is consumed in one pass; parsing stops on any truncation error.
| inBytes | Byte buffer previously produced by Serialize(). |
Definition at line 213 of file LocalBlackboard.cpp.
References Olympe::Bool, Olympe::EntityID, Olympe::Float, GetComponentTypeID_Static(), Olympe::Int, m_types, m_variables, Olympe::String, SYSTEM_LOG, and Olympe::Vector.
Here is the call graph for this function:Returns the current value of a variable.
| varName | Name of the variable. |
| std::runtime_error | if the variable is not registered. |
Definition at line 64 of file LocalBlackboard.cpp.
References GetComponentTypeID_Static(), and m_variables.
Referenced by Olympe::EntityBlackboard::GetLocalValue(), GetValueScoped(), and Olympe::InspectorPanel::RenderDebugBlackboard().
Here is the call graph for this function:
Here is the caller graph for this function:Gets a value using a scoped key (prefix "local:" is stripped).
Forwards "global:" scope to GlobalBlackboard singleton.
| scopedKey | Key with optional prefix. |
Definition at line 411 of file LocalBlackboard.cpp.
References Olympe::GlobalBlackboard::Get(), GetComponentTypeID_Static(), GetValue(), and Olympe::GlobalBlackboard::GetVar().
Here is the call graph for this function:| std::vector< std::string > Olympe::LocalBlackboard::GetVariableNames | ( | ) | const |
Returns all registered variable names (useful for debugging / editor).
Definition at line 99 of file LocalBlackboard.cpp.
References GetComponentTypeID_Static(), and m_variables.
Referenced by Olympe::InspectorPanel::RenderDebugBlackboard(), and Olympe::DebugPanel::RenderWatchVariables().
Here is the call graph for this function:
Here is the caller graph for this function:Returns true if a variable with the given name is registered.
| varName | Name of the variable. |
Definition at line 94 of file LocalBlackboard.cpp.
References GetComponentTypeID_Static(), and m_variables.
Referenced by Olympe::EntityBlackboard::HasLocalVariable().
Here is the call graph for this function:
Here is the caller graph for this function:| void Olympe::LocalBlackboard::Initialize | ( | const TaskGraphTemplate & | tmpl | ) |
Initialises the blackboard from a template.
Registers all local variables defined in tmpl, copying their types and default values. Any previous state is discarded.
| tmpl | The TaskGraphTemplate that owns this blackboard's schema. |
Definition at line 32 of file LocalBlackboard.cpp.
References Olympe::VariableDefinition::DefaultValue, GetComponentTypeID_Static(), m_defaults, m_types, m_variables, Olympe::VariableDefinition::Name, SYSTEM_LOG, and Olympe::VariableDefinition::Type.
Referenced by Olympe::TaskSystem::ExecuteAtomicTask(), and Olympe::EntityBlackboard::Initialize().
Here is the call graph for this function:
Here is the caller graph for this function:| void Olympe::LocalBlackboard::InitializeFromEntries | ( | const std::vector< BlackboardEntry > & | entries | ) |
Initializes the blackboard from a vector of BlackboardEntry (ATS VS schema v4).
Companion to Initialize(const TaskGraphTemplate&) for VS graphs that use the BlackboardEntry schema instead of VariableDefinition.
| entries | Blackboard entries from TaskGraphTemplate::Blackboard. |
Definition at line 342 of file LocalBlackboard.cpp.
References Olympe::BlackboardEntry::Default, GetComponentTypeID_Static(), m_defaults, m_types, m_variables, and SYSTEM_LOG.
Referenced by Olympe::TaskSystem::ExecuteVSFrame(), and Olympe::VSGraphExecutor::HandleSubGraph().
Here is the call graph for this function:
Here is the caller graph for this function:| void Olympe::LocalBlackboard::Reset | ( | ) |
Resets all variables to their default values.
Does not change the set of registered variables.
Definition at line 50 of file LocalBlackboard.cpp.
References GetComponentTypeID_Static(), m_defaults, m_variables, and SYSTEM_LOG.
Referenced by Olympe::EntityBlackboard::Reset().
Here is the call graph for this function:
Here is the caller graph for this function:Serializes all variable names and typed values into a byte buffer.
Binary format (little-endian): uint32_t count - number of variables for each variable: uint32_t nameLen - length of name in bytes <nameLen bytes> - variable name (UTF-8) uint8_t type - VariableType tag
: Bool -> uint8_t (0 = false, 1 = true) Int -> int32_t Float -> float Vector -> float x, float y, float z EntityID-> uint64_t String -> uint32_t len, <len bytes>
| outBytes | Output byte buffer (cleared before writing). |
Definition at line 139 of file LocalBlackboard.cpp.
References Olympe::Bool, Olympe::EntityID, Olympe::Float, GetComponentTypeID_Static(), Olympe::Int, m_variables, Olympe::String, SYSTEM_LOG, and Olympe::Vector.
Here is the call graph for this function:Sets the value of a variable.
The type of value must match the declared type of the variable.
| varName | Name of the variable. |
| value | New value. |
| std::runtime_error | if the variable is not registered. |
| std::runtime_error | if the type of value does not match the declared type of the variable. |
Definition at line 74 of file LocalBlackboard.cpp.
References GetComponentTypeID_Static(), Olympe::TaskValue::GetType(), m_types, and m_variables.
Referenced by Olympe::EntityBlackboard::SetLocalValue(), and SetValueScoped().
Here is the call graph for this function:
Here is the caller graph for this function:| void Olympe::LocalBlackboard::SetValueScoped | ( | const std::string & | scopedKey, |
| const TaskValue & | value | ||
| ) |
Sets a value using a scoped key (prefix "local:" is stripped).
Forwards "global:" scope to GlobalBlackboard singleton.
| scopedKey | Key with optional "local:" or "global:" prefix. |
| value | Value to set. |
Definition at line 371 of file LocalBlackboard.cpp.
References Olympe::GlobalBlackboard::Get(), GetComponentTypeID_Static(), SetValue(), Olympe::GlobalBlackboard::SetVar(), and SYSTEM_LOG.
Here is the call graph for this function:
|
private |
Default (initial) values used by Reset().
Definition at line 178 of file LocalBlackboard.h.
Referenced by Initialize(), InitializeFromEntries(), and Reset().
|
private |
Declared type of each variable (used for type validation in SetValue).
Definition at line 181 of file LocalBlackboard.h.
Referenced by Deserialize(), Initialize(), InitializeFromEntries(), and SetValue().
|
private |
Current values for each registered variable.
Definition at line 175 of file LocalBlackboard.h.
Referenced by Deserialize(), GetValue(), GetVariableNames(), HasVariable(), Initialize(), InitializeFromEntries(), Reset(), Serialize(), and SetValue().