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

#include <EntityBlackboard.h>

+ Inheritance diagram for Olympe::EntityBlackboard:
+ Collaboration diagram for Olympe::EntityBlackboard:

Public Member Functions

 EntityBlackboard (uint32_t entityID=0)
 
 ~EntityBlackboard ()
 
void Initialize (const TaskGraphTemplate &tmpl, const std::unordered_map< std::string, TaskValue > *globalOverrides=nullptr)
 
void Reset ()
 
void Clear ()
 
TaskValue GetValueScoped (const std::string &varName) const
 
void SetValueScoped (const std::string &varName, const TaskValue &value)
 
TaskValue GetGlobalValue (const std::string &globalKey) const
 
void SetGlobalValue (const std::string &globalKey, const TaskValue &value)
 
TaskValue GetLocalValue (const std::string &localKey) const
 
void SetLocalValue (const std::string &localKey, const TaskValue &value)
 
bool HasVariableScoped (const std::string &varName) const
 
bool HasGlobalVariable (const std::string &globalKey) const
 
bool HasLocalVariable (const std::string &localKey) const
 
size_t GetTotalVariableCount () const
 
size_t GetGlobalVariableCount () const
 
size_t GetLocalVariableCount () const
 
uint32_t GetEntityID () const
 
std::string DebugSummary () const
 
void DebugPrint () const
 
json ExportGlobalsToJson () const
 
bool ImportGlobalsFromJson (const json &data)
 
- Public Member Functions inherited from Olympe::LocalBlackboard
 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).
 

Protected Attributes

uint32_t m_entityID
 
std::unordered_map< std::string, TaskValuem_globalVars
 
std::unordered_map< std::string, VariableTypem_globalTypes
 

Static Private Member Functions

static void ParseScopedName (const std::string &scopedName, std::string &outPrefix, std::string &outName)
 

Detailed Description

Definition at line 30 of file EntityBlackboard.h.

Constructor & Destructor Documentation

◆ EntityBlackboard()

Olympe::EntityBlackboard::EntityBlackboard ( uint32_t  entityID = 0)
explicit

Definition at line 18 of file EntityBlackboard.cpp.

◆ ~EntityBlackboard()

Olympe::EntityBlackboard::~EntityBlackboard ( )

Definition at line 23 of file EntityBlackboard.cpp.

Member Function Documentation

◆ Clear()

void Olympe::EntityBlackboard::Clear ( )

Definition at line 76 of file EntityBlackboard.cpp.

References m_globalTypes, and m_globalVars.

◆ DebugPrint()

void Olympe::EntityBlackboard::DebugPrint ( ) const

Definition at line 280 of file EntityBlackboard.cpp.

References DebugSummary(), GetGlobalVariableCount(), GetLocalVariableCount(), and SYSTEM_LOG.

+ Here is the call graph for this function:

◆ DebugSummary()

std::string Olympe::EntityBlackboard::DebugSummary ( ) const

Definition at line 271 of file EntityBlackboard.cpp.

References GetComponentTypeID_Static(), GetGlobalVariableCount(), GetLocalVariableCount(), and m_entityID.

Referenced by DebugPrint().

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

◆ ExportGlobalsToJson()

json Olympe::EntityBlackboard::ExportGlobalsToJson ( ) const

◆ GetEntityID()

uint32_t Olympe::EntityBlackboard::GetEntityID ( ) const

Definition at line 266 of file EntityBlackboard.cpp.

References m_entityID.

◆ GetGlobalValue()

TaskValue Olympe::EntityBlackboard::GetGlobalValue ( const std::string &  globalKey) const

Definition at line 133 of file EntityBlackboard.cpp.

References Olympe::GlobalEntryDefinition::DefaultValue, Olympe::GlobalTemplateBlackboard::Get(), GetComponentTypeID_Static(), m_globalTypes, m_globalVars, SYSTEM_LOG, and Olympe::VariableTypeToString().

Referenced by GetValueScoped().

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

◆ GetGlobalVariableCount()

size_t Olympe::EntityBlackboard::GetGlobalVariableCount ( ) const

Definition at line 255 of file EntityBlackboard.cpp.

References m_globalVars.

Referenced by DebugPrint(), DebugSummary(), and GetTotalVariableCount().

+ Here is the caller graph for this function:

◆ GetLocalValue()

TaskValue Olympe::EntityBlackboard::GetLocalValue ( const std::string &  localKey) const

Definition at line 211 of file EntityBlackboard.cpp.

References GetComponentTypeID_Static(), and Olympe::LocalBlackboard::GetValue().

Referenced by GetValueScoped().

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

◆ GetLocalVariableCount()

size_t Olympe::EntityBlackboard::GetLocalVariableCount ( ) const

Definition at line 260 of file EntityBlackboard.cpp.

Referenced by DebugPrint(), DebugSummary(), and GetTotalVariableCount().

+ Here is the caller graph for this function:

◆ GetTotalVariableCount()

size_t Olympe::EntityBlackboard::GetTotalVariableCount ( ) const

Definition at line 250 of file EntityBlackboard.cpp.

References GetGlobalVariableCount(), and GetLocalVariableCount().

+ Here is the call graph for this function:

◆ GetValueScoped()

TaskValue Olympe::EntityBlackboard::GetValueScoped ( const std::string &  varName) const

Definition at line 82 of file EntityBlackboard.cpp.

References GetComponentTypeID_Static(), GetGlobalValue(), GetLocalValue(), HasLocalVariable(), and ParseScopedName().

+ Here is the call graph for this function:

◆ HasGlobalVariable()

bool Olympe::EntityBlackboard::HasGlobalVariable ( const std::string &  globalKey) const

Definition at line 240 of file EntityBlackboard.cpp.

References GetComponentTypeID_Static(), and m_globalVars.

Referenced by HasVariableScoped().

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

◆ HasLocalVariable()

bool Olympe::EntityBlackboard::HasLocalVariable ( const std::string &  localKey) const

Definition at line 245 of file EntityBlackboard.cpp.

References GetComponentTypeID_Static(), and Olympe::LocalBlackboard::HasVariable().

Referenced by GetValueScoped(), HasVariableScoped(), and SetValueScoped().

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

◆ HasVariableScoped()

bool Olympe::EntityBlackboard::HasVariableScoped ( const std::string &  varName) const

Definition at line 221 of file EntityBlackboard.cpp.

References GetComponentTypeID_Static(), HasGlobalVariable(), HasLocalVariable(), and ParseScopedName().

+ Here is the call graph for this function:

◆ ImportGlobalsFromJson()

bool Olympe::EntityBlackboard::ImportGlobalsFromJson ( const json data)

◆ Initialize()

void Olympe::EntityBlackboard::Initialize ( const TaskGraphTemplate tmpl,
const std::unordered_map< std::string, TaskValue > *  globalOverrides = nullptr 
)

◆ ParseScopedName()

void Olympe::EntityBlackboard::ParseScopedName ( const std::string &  scopedName,
std::string &  outPrefix,
std::string &  outName 
)
staticprivate

Definition at line 416 of file EntityBlackboard.cpp.

References GetComponentTypeID_Static().

Referenced by GetValueScoped(), HasVariableScoped(), and SetValueScoped().

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

◆ Reset()

void Olympe::EntityBlackboard::Reset ( )

◆ SetGlobalValue()

void Olympe::EntityBlackboard::SetGlobalValue ( const std::string &  globalKey,
const TaskValue value 
)

Definition at line 169 of file EntityBlackboard.cpp.

References Olympe::GlobalTemplateBlackboard::Get(), GetComponentTypeID_Static(), Olympe::TaskValue::GetType(), m_globalTypes, m_globalVars, Olympe::None, SYSTEM_LOG, Olympe::GlobalEntryDefinition::Type, and Olympe::VariableTypeToString().

Referenced by SetValueScoped().

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

◆ SetLocalValue()

void Olympe::EntityBlackboard::SetLocalValue ( const std::string &  localKey,
const TaskValue value 
)

Definition at line 216 of file EntityBlackboard.cpp.

References GetComponentTypeID_Static(), and Olympe::LocalBlackboard::SetValue().

Referenced by SetValueScoped().

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

◆ SetValueScoped()

void Olympe::EntityBlackboard::SetValueScoped ( const std::string &  varName,
const TaskValue value 
)

Definition at line 106 of file EntityBlackboard.cpp.

References GetComponentTypeID_Static(), HasLocalVariable(), ParseScopedName(), SetGlobalValue(), and SetLocalValue().

+ Here is the call graph for this function:

Member Data Documentation

◆ m_entityID

uint32_t Olympe::EntityBlackboard::m_entityID
protected

Definition at line 69 of file EntityBlackboard.h.

Referenced by DebugSummary(), GetEntityID(), Initialize(), and Reset().

◆ m_globalTypes

std::unordered_map<std::string, VariableType> Olympe::EntityBlackboard::m_globalTypes
protected

◆ m_globalVars

std::unordered_map<std::string, TaskValue> Olympe::EntityBlackboard::m_globalVars
protected

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