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

Process-wide singleton blackboard storing TaskValue entries. More...

#include <GlobalBlackboard.h>

Public Member Functions

TaskValue GetVar (const std::string &key) const
 Reads a variable by key.
 
void SetVar (const std::string &key, const TaskValue &value)
 Writes or creates a variable.
 
bool IsDirty () const
 Returns true if any variable has been modified since the last ClearDirty().
 
void MarkDirty ()
 Marks the blackboard as modified (called automatically by SetVar).
 
void ClearDirty ()
 Clears the dirty flag (call after persisting).
 
bool HasVar (const std::string &key) const
 Checks whether a variable exists.
 
void Clear ()
 Removes all variables (useful in tests / level transitions).
 

Static Public Member Functions

static GlobalBlackboardGet ()
 Returns the singleton instance.
 

Private Member Functions

 GlobalBlackboard ()=default
 
 ~GlobalBlackboard ()=default
 
 GlobalBlackboard (const GlobalBlackboard &)=delete
 
GlobalBlackboardoperator= (const GlobalBlackboard &)=delete
 
 GlobalBlackboard (GlobalBlackboard &&)=delete
 
GlobalBlackboardoperator= (GlobalBlackboard &&)=delete
 

Private Attributes

std::unordered_map< std::string, TaskValuem_store
 
bool m_dirty = false
 

Detailed Description

Process-wide singleton blackboard storing TaskValue entries.

All VS graph nodes sharing the same process can read and write GlobalBlackboard variables using the "global:" scope prefix.

Example:

// Write:
GlobalBlackboard::Get().SetVar("GamePhase", TaskValue(std::string("Combat")));
// Read:
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
void SetVar(const std::string &key, const TaskValue &value)
Writes or creates a variable.
static GlobalBlackboard & Get()
Returns the singleton instance.
TaskValue GetVar(const std::string &key) const
Reads a variable by key.
C++14-compliant type-safe value container for task parameters.

Definition at line 50 of file GlobalBlackboard.h.

Constructor & Destructor Documentation

◆ GlobalBlackboard() [1/3]

Olympe::GlobalBlackboard::GlobalBlackboard ( )
privatedefault

◆ ~GlobalBlackboard()

Olympe::GlobalBlackboard::~GlobalBlackboard ( )
privatedefault

◆ GlobalBlackboard() [2/3]

Olympe::GlobalBlackboard::GlobalBlackboard ( const GlobalBlackboard )
privatedelete

◆ GlobalBlackboard() [3/3]

Olympe::GlobalBlackboard::GlobalBlackboard ( GlobalBlackboard &&  )
privatedelete

Member Function Documentation

◆ Clear()

void Olympe::GlobalBlackboard::Clear ( )
inline

Removes all variables (useful in tests / level transitions).

Definition at line 119 of file GlobalBlackboard.h.

References m_dirty, and m_store.

◆ ClearDirty()

void Olympe::GlobalBlackboard::ClearDirty ( )
inline

Clears the dirty flag (call after persisting).

Definition at line 104 of file GlobalBlackboard.h.

References m_dirty.

◆ Get()

static GlobalBlackboard & Olympe::GlobalBlackboard::Get ( )
inlinestatic

Returns the singleton instance.

Returns
Reference to the single GlobalBlackboard instance.

Definition at line 57 of file GlobalBlackboard.h.

References GetComponentTypeID_Static().

Referenced by Olympe::LocalBlackboard::GetValueScoped(), and Olympe::LocalBlackboard::SetValueScoped().

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

◆ GetVar()

TaskValue Olympe::GlobalBlackboard::GetVar ( const std::string &  key) const
inline

Reads a variable by key.

Parameters
keyVariable name (without "global:" prefix).
Returns
Stored TaskValue, or default TaskValue() (None) if not found.

Definition at line 69 of file GlobalBlackboard.h.

References GetComponentTypeID_Static(), and m_store.

Referenced by Olympe::LocalBlackboard::GetValueScoped().

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

◆ HasVar()

bool Olympe::GlobalBlackboard::HasVar ( const std::string &  key) const
inline

Checks whether a variable exists.

Parameters
keyVariable name (without "global:" prefix).
Returns
true if the variable exists.

Definition at line 111 of file GlobalBlackboard.h.

References GetComponentTypeID_Static(), and m_store.

+ Here is the call graph for this function:

◆ IsDirty()

bool Olympe::GlobalBlackboard::IsDirty ( ) const
inline

Returns true if any variable has been modified since the last ClearDirty().

Definition at line 94 of file GlobalBlackboard.h.

References m_dirty.

◆ MarkDirty()

void Olympe::GlobalBlackboard::MarkDirty ( )
inline

Marks the blackboard as modified (called automatically by SetVar).

Definition at line 99 of file GlobalBlackboard.h.

References m_dirty.

◆ operator=() [1/2]

GlobalBlackboard & Olympe::GlobalBlackboard::operator= ( const GlobalBlackboard )
privatedelete

◆ operator=() [2/2]

GlobalBlackboard & Olympe::GlobalBlackboard::operator= ( GlobalBlackboard &&  )
privatedelete

◆ SetVar()

void Olympe::GlobalBlackboard::SetVar ( const std::string &  key,
const TaskValue value 
)
inline

Writes or creates a variable.

Parameters
keyVariable name (without "global:" prefix).
valueValue to store.

Definition at line 85 of file GlobalBlackboard.h.

References GetComponentTypeID_Static(), m_dirty, and m_store.

Referenced by Olympe::LocalBlackboard::SetValueScoped().

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

Member Data Documentation

◆ m_dirty

bool Olympe::GlobalBlackboard::m_dirty = false
private

Definition at line 136 of file GlobalBlackboard.h.

Referenced by Clear(), ClearDirty(), IsDirty(), MarkDirty(), and SetVar().

◆ m_store

std::unordered_map<std::string, TaskValue> Olympe::GlobalBlackboard::m_store
private

Definition at line 135 of file GlobalBlackboard.h.

Referenced by Clear(), GetVar(), HasVar(), and SetVar().


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