Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
Olympe::NodeGraph::BlackboardSystem Class Reference

Manages named blackboard variables for a graph. More...

#include <BlackboardSystem.h>

Public Member Functions

 BlackboardSystem ()=default
 
 ~BlackboardSystem ()=default
 
bool HasEntry (const std::string &name) const
 Check if an entry exists.
 
const BlackboardValueGetEntry (const std::string &name) const
 Get a const pointer to an entry.
 
bool CreateEntry (const std::string &name, BlackboardType type, const BlackboardValue &initialValue)
 Create a new entry.
 
bool RemoveEntry (const std::string &name)
 Remove an entry.
 
bool RenameEntry (const std::string &oldName, const std::string &newName)
 Rename an entry.
 
bool SetValue (const std::string &name, const BlackboardValue &value)
 Update the value of an existing entry.
 
const std::map< std::string, BlackboardValue > & GetAll () const
 Get all entries (for UI / serialization)
 
json ToJson () const
 Serialize blackboard to JSON.
 
void FromJson (const json &j)
 Deserialize blackboard from JSON.
 

Static Private Member Functions

static std::string TypeToString (BlackboardType t)
 Convert a BlackboardType to its string representation.
 
static BlackboardType StringToType (const std::string &s)
 Convert a string to BlackboardType (returns Int on unknown)
 

Private Attributes

std::map< std::string, BlackboardValuem_entries
 

Detailed Description

Manages named blackboard variables for a graph.

Definition at line 62 of file BlackboardSystem.h.

Constructor & Destructor Documentation

◆ BlackboardSystem()

Olympe::NodeGraph::BlackboardSystem::BlackboardSystem ( )
default

◆ ~BlackboardSystem()

Olympe::NodeGraph::BlackboardSystem::~BlackboardSystem ( )
default

Member Function Documentation

◆ CreateEntry()

bool Olympe::NodeGraph::BlackboardSystem::CreateEntry ( const std::string &  name,
BlackboardType  type,
const BlackboardValue initialValue 
)

Create a new entry.

Parameters
nameVariable name (must be unique)
typeVariable type
initialValueInitial value
Returns
true if created, false if name already exists

Definition at line 37 of file BlackboardSystem.cpp.

References GetComponentTypeID_Static(), HasEntry(), m_entries, SYSTEM_LOG, Olympe::NodeGraph::BlackboardValue::type, and TypeToString().

+ Here is the call graph for this function:

◆ FromJson()

void Olympe::NodeGraph::BlackboardSystem::FromJson ( const json j)

Deserialize blackboard from JSON.

Parameters
jJSON array produced by ToJson()

Definition at line 176 of file BlackboardSystem.cpp.

References JsonHelper::GetBool(), GetComponentTypeID_Static(), JsonHelper::GetFloat(), JsonHelper::GetInt(), JsonHelper::GetString(), m_entries, StringToType(), and Olympe::NodeGraph::BlackboardValue::type.

+ Here is the call graph for this function:

◆ GetAll()

const std::map< std::string, BlackboardValue > & Olympe::NodeGraph::BlackboardSystem::GetAll ( ) const

Get all entries (for UI / serialization)

Returns
Const reference to internal map

Definition at line 126 of file BlackboardSystem.cpp.

References m_entries.

◆ GetEntry()

const BlackboardValue * Olympe::NodeGraph::BlackboardSystem::GetEntry ( const std::string &  name) const

Get a const pointer to an entry.

Parameters
nameVariable name
Returns
Const pointer or nullptr if not found

Definition at line 23 of file BlackboardSystem.cpp.

References GetComponentTypeID_Static(), and m_entries.

+ Here is the call graph for this function:

◆ HasEntry()

bool Olympe::NodeGraph::BlackboardSystem::HasEntry ( const std::string &  name) const

Check if an entry exists.

Parameters
nameVariable name

Definition at line 18 of file BlackboardSystem.cpp.

References m_entries.

Referenced by CreateEntry(), and RenameEntry().

+ Here is the caller graph for this function:

◆ RemoveEntry()

bool Olympe::NodeGraph::BlackboardSystem::RemoveEntry ( const std::string &  name)

Remove an entry.

Parameters
nameVariable name
Returns
true if removed, false if not found

Definition at line 61 of file BlackboardSystem.cpp.

References GetComponentTypeID_Static(), m_entries, and SYSTEM_LOG.

+ Here is the call graph for this function:

◆ RenameEntry()

bool Olympe::NodeGraph::BlackboardSystem::RenameEntry ( const std::string &  oldName,
const std::string &  newName 
)

Rename an entry.

Parameters
oldNameCurrent variable name
newNameNew variable name
Returns
true if renamed, false on error (not found, or newName already used)

Definition at line 74 of file BlackboardSystem.cpp.

References GetComponentTypeID_Static(), HasEntry(), m_entries, and SYSTEM_LOG.

+ Here is the call graph for this function:

◆ SetValue()

bool Olympe::NodeGraph::BlackboardSystem::SetValue ( const std::string &  name,
const BlackboardValue value 
)

Update the value of an existing entry.

Parameters
nameVariable name
valueNew value (type must match the entry's type)
Returns
true if updated, false if not found or type mismatch

Definition at line 103 of file BlackboardSystem.cpp.

References GetComponentTypeID_Static(), m_entries, SYSTEM_LOG, and Olympe::NodeGraph::BlackboardValue::type.

+ Here is the call graph for this function:

◆ StringToType()

BlackboardType Olympe::NodeGraph::BlackboardSystem::StringToType ( const std::string &  s)
staticprivate

Convert a string to BlackboardType (returns Int on unknown)

Definition at line 253 of file BlackboardSystem.cpp.

References GetComponentTypeID_Static().

Referenced by FromJson().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ToJson()

json Olympe::NodeGraph::BlackboardSystem::ToJson ( ) const

Serialize blackboard to JSON.

Returns
JSON array of variable objects

Definition at line 135 of file BlackboardSystem.cpp.

References GetComponentTypeID_Static(), m_entries, and TypeToString().

Referenced by Olympe::NodeGraph::GraphDocument::ToJson().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ TypeToString()

std::string Olympe::NodeGraph::BlackboardSystem::TypeToString ( BlackboardType  t)
staticprivate

Convert a BlackboardType to its string representation.

Definition at line 240 of file BlackboardSystem.cpp.

References GetComponentTypeID_Static().

Referenced by CreateEntry(), and ToJson().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_entries

std::map<std::string, BlackboardValue> Olympe::NodeGraph::BlackboardSystem::m_entries
private

The documentation for this class was generated from the following files: