![]() |
Olympe Engine 2.0
2D Game Engine with ECS Architecture
|
Singleton registry for global blackboard variable presets. More...
#include <BlackboardVariablePresetRegistry.h>
Public Member Functions | |
| BlackboardVariablePresetRegistry (const BlackboardVariablePresetRegistry &)=delete | |
| BlackboardVariablePresetRegistry & | operator= (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 BlackboardVariablePreset * | GetPreset (const std::string &name) const |
| Returns a pointer to the preset with the given name, or nullptr. | |
| std::vector< BlackboardVariablePreset > | GetByCategory (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 BlackboardVariablePresetRegistry & | Instance () |
| Returns the singleton instance. | |
Private Member Functions | |
| BlackboardVariablePresetRegistry ()=default | |
Private Attributes | |
| std::mutex | m_mutex |
| Guards m_presets during concurrent access. | |
| std::vector< BlackboardVariablePreset > | m_presets |
| std::unordered_map< std::string, size_t > | m_nameIndex |
| name -> index in m_presets | |
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.
|
delete |
|
privatedefault |
| 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:| std::vector< std::string > Olympe::BlackboardVariablePresetRegistry::GetAllCategories | ( | ) | const |
Returns all unique category names present in the registry.
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:| 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.
Definition at line 115 of file BlackboardVariablePresetRegistry.cpp.
References GetComponentTypeID_Static(), m_mutex, and m_presets.
Here is the call graph for this function:| std::vector< BlackboardVariablePreset > Olympe::BlackboardVariablePresetRegistry::GetByCategory | ( | const std::string & | category | ) | const |
Returns all presets belonging to a given category.
| category | Category label to filter by (case-sensitive). |
Definition at line 131 of file BlackboardVariablePresetRegistry.cpp.
References GetComponentTypeID_Static(), and m_presets.
Here is the call graph for this function:| size_t Olympe::BlackboardVariablePresetRegistry::GetCount | ( | ) | const |
Returns the number of loaded presets.
Definition at line 171 of file BlackboardVariablePresetRegistry.cpp.
References m_presets.
| const BlackboardVariablePreset * Olympe::BlackboardVariablePresetRegistry::GetPreset | ( | const std::string & | name | ) | const |
Returns a pointer to the preset with the given name, or nullptr.
| name | Variable name to look up (case-sensitive). |
Definition at line 122 of file BlackboardVariablePresetRegistry.cpp.
References GetComponentTypeID_Static(), m_nameIndex, and m_presets.
Here is the call graph for this function:Returns true if a preset with the given name exists.
| name | Variable name to test. |
Definition at line 166 of file BlackboardVariablePresetRegistry.cpp.
References m_nameIndex.
|
static |
Returns the singleton instance.
Definition at line 26 of file BlackboardVariablePresetRegistry.cpp.
Loads presets from a JSON file.
Clears any previously loaded data before loading. On parse error, logs and returns false; registry remains empty.
| filePath | Absolute or relative path to the JSON preset file. |
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:
|
delete |
|
mutableprivate |
Guards m_presets during concurrent access.
Definition at line 123 of file BlackboardVariablePresetRegistry.h.
Referenced by GetAllPresets().
|
private |
name -> index in m_presets
Definition at line 125 of file BlackboardVariablePresetRegistry.h.
Referenced by Clear(), GetPreset(), HasPreset(), and LoadFromFile().
|
private |
Definition at line 124 of file BlackboardVariablePresetRegistry.h.
Referenced by Clear(), GetAllCategories(), GetAllPresets(), GetByCategory(), GetCount(), GetPreset(), and LoadFromFile().