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::BlackboardVariablePresetRegistry Class Reference

Singleton registry for global blackboard variable presets. More...

#include <BlackboardVariablePresetRegistry.h>

Public Member Functions

 BlackboardVariablePresetRegistry (const BlackboardVariablePresetRegistry &)=delete
 
BlackboardVariablePresetRegistryoperator= (const BlackboardVariablePresetRegistry &)=delete
 
bool LoadFromFile (const std::string &filePath)
 Loads presets from a JSON file.
 
const std::vector< BlackboardVariablePreset > & GetAllPresets () const
 Returns all loaded presets, sorted by name.
 
const BlackboardVariablePresetGetPreset (const std::string &name) const
 Returns a pointer to the preset with the given name, or nullptr.
 
std::vector< BlackboardVariablePresetGetByCategory (const std::string &category) const
 Returns all presets belonging to a given category.
 
std::vector< std::string > GetAllCategories () const
 Returns all unique category names present in the registry.
 
bool HasPreset (const std::string &name) const
 Returns true if a preset with the given name exists.
 
size_t GetCount () const
 Returns the number of loaded presets.
 
void Clear ()
 Clears all loaded presets and resets the registry.
 

Static Public Member Functions

static BlackboardVariablePresetRegistryInstance ()
 Returns the singleton instance.
 

Private Member Functions

 BlackboardVariablePresetRegistry ()=default
 

Private Attributes

std::mutex m_mutex
 Guards m_presets during concurrent access.
 
std::vector< BlackboardVariablePresetm_presets
 
std::unordered_map< std::string, size_tm_nameIndex
 name -> index in m_presets
 

Detailed Description

Singleton registry for global blackboard variable presets.

Loaded from Assets/Config/BlackboardVariablePresets.json at editor startup. Provides O(1) lookup by name via internal index map. Category queries are O(n) on the preset list but cached on first access.

Thread-safety: read-only after LoadFromFile() — no locking required.

Definition at line 50 of file BlackboardVariablePresetRegistry.h.

Constructor & Destructor Documentation

◆ BlackboardVariablePresetRegistry() [1/2]

Olympe::BlackboardVariablePresetRegistry::BlackboardVariablePresetRegistry ( const BlackboardVariablePresetRegistry )
delete

◆ BlackboardVariablePresetRegistry() [2/2]

Olympe::BlackboardVariablePresetRegistry::BlackboardVariablePresetRegistry ( )
privatedefault

Member Function Documentation

◆ Clear()

void Olympe::BlackboardVariablePresetRegistry::Clear ( )

Clears all loaded presets and resets the registry.

Definition at line 176 of file BlackboardVariablePresetRegistry.cpp.

References m_nameIndex, and m_presets.

Referenced by LoadFromFile().

+ Here is the caller graph for this function:

◆ GetAllCategories()

std::vector< std::string > Olympe::BlackboardVariablePresetRegistry::GetAllCategories ( ) const

Returns all unique category names present in the registry.

Returns
Sorted vector of category strings.

Definition at line 142 of file BlackboardVariablePresetRegistry.cpp.

References Olympe::BlackboardVariablePreset::category, GetComponentTypeID_Static(), and m_presets.

+ Here is the call graph for this function:

◆ GetAllPresets()

const std::vector< BlackboardVariablePreset > & Olympe::BlackboardVariablePresetRegistry::GetAllPresets ( ) const

Returns all loaded presets, sorted by name.

Thread-safe: protected by an internal mutex so that concurrent calls from a FileWatcher thread and the Save path cannot race.

Returns
Const reference to the internal preset list.

Definition at line 115 of file BlackboardVariablePresetRegistry.cpp.

References GetComponentTypeID_Static(), m_mutex, and m_presets.

+ Here is the call graph for this function:

◆ GetByCategory()

std::vector< BlackboardVariablePreset > Olympe::BlackboardVariablePresetRegistry::GetByCategory ( const std::string &  category) const

Returns all presets belonging to a given category.

Parameters
categoryCategory label to filter by (case-sensitive).
Returns
Vector of matching presets (may be empty).

Definition at line 131 of file BlackboardVariablePresetRegistry.cpp.

References GetComponentTypeID_Static(), and m_presets.

+ Here is the call graph for this function:

◆ GetCount()

size_t Olympe::BlackboardVariablePresetRegistry::GetCount ( ) const

Returns the number of loaded presets.

Definition at line 171 of file BlackboardVariablePresetRegistry.cpp.

References m_presets.

◆ GetPreset()

const BlackboardVariablePreset * Olympe::BlackboardVariablePresetRegistry::GetPreset ( const std::string &  name) const

Returns a pointer to the preset with the given name, or nullptr.

Parameters
nameVariable name to look up (case-sensitive).
Returns
Pointer to preset if found, nullptr otherwise.

Definition at line 122 of file BlackboardVariablePresetRegistry.cpp.

References GetComponentTypeID_Static(), m_nameIndex, and m_presets.

+ Here is the call graph for this function:

◆ HasPreset()

bool Olympe::BlackboardVariablePresetRegistry::HasPreset ( const std::string &  name) const

Returns true if a preset with the given name exists.

Parameters
nameVariable name to test.

Definition at line 166 of file BlackboardVariablePresetRegistry.cpp.

References m_nameIndex.

◆ Instance()

BlackboardVariablePresetRegistry & Olympe::BlackboardVariablePresetRegistry::Instance ( )
static

Returns the singleton instance.

Returns
Reference to the singleton.

Definition at line 26 of file BlackboardVariablePresetRegistry.cpp.

◆ LoadFromFile()

bool Olympe::BlackboardVariablePresetRegistry::LoadFromFile ( const std::string &  filePath)

Loads presets from a JSON file.

Clears any previously loaded data before loading. On parse error, logs and returns false; registry remains empty.

Parameters
filePathAbsolute or relative path to the JSON preset file.
Returns
true on success, false on file/parse error.

Definition at line 36 of file BlackboardVariablePresetRegistry.cpp.

References Clear(), GetComponentTypeID_Static(), JsonHelper::GetString(), JsonHelper::LoadJsonFromFile(), m_nameIndex, m_presets, Olympe::BlackboardVariablePreset::name, and SYSTEM_LOG.

+ Here is the call graph for this function:

◆ operator=()

BlackboardVariablePresetRegistry & Olympe::BlackboardVariablePresetRegistry::operator= ( const BlackboardVariablePresetRegistry )
delete

Member Data Documentation

◆ m_mutex

std::mutex Olympe::BlackboardVariablePresetRegistry::m_mutex
mutableprivate

Guards m_presets during concurrent access.

Definition at line 123 of file BlackboardVariablePresetRegistry.h.

Referenced by GetAllPresets().

◆ m_nameIndex

std::unordered_map<std::string, size_t> Olympe::BlackboardVariablePresetRegistry::m_nameIndex
private

name -> index in m_presets

Definition at line 125 of file BlackboardVariablePresetRegistry.h.

Referenced by Clear(), GetPreset(), HasPreset(), and LoadFromFile().

◆ m_presets

std::vector<BlackboardVariablePreset> Olympe::BlackboardVariablePresetRegistry::m_presets
private

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