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

Manages the global pool of ConditionPreset objects. More...

#include <ConditionPresetRegistry.h>

Public Member Functions

 ConditionPresetRegistry ()=default
 
 ConditionPresetRegistry (const ConditionPresetRegistry &)=delete
 
ConditionPresetRegistryoperator= (const ConditionPresetRegistry &)=delete
 
std::string CreatePreset (const ConditionPreset &preset)
 Adds a preset to the registry.
 
ConditionPresetGetPreset (const std::string &id)
 Returns a mutable pointer to the preset, or nullptr if not found.
 
const ConditionPresetGetPreset (const std::string &id) const
 Returns a const pointer to the preset, or nullptr if not found.
 
void UpdatePreset (const std::string &id, const ConditionPreset &updated)
 Replaces the data of an existing preset (id must already exist).
 
void DeletePreset (const std::string &id)
 Removes a preset from the registry.
 
std::string DuplicatePreset (const std::string &id)
 Creates an independent copy of an existing preset with a new UUID.
 
std::vector< std::string > GetAllPresetIDs () const
 Returns all preset UUIDs in display order.
 
size_t GetPresetCount () const
 Returns the total number of presets in the registry.
 
std::vector< std::string > FindPresetsByName (const std::string &substring) const
 Returns UUIDs of all presets whose name contains a substring.
 
std::vector< ConditionPresetGetFilteredPresets (const std::string &filter) const
 Returns all presets whose name contains the filter substring.
 
bool ValidatePresetID (const std::string &id) const
 Returns true when a preset with the given UUID exists.
 
std::vector< std::string > GetAllErrors () const
 Returns all error messages accumulated since the last Clear().
 
void Clear ()
 Clears all presets and resets error state.
 
bool Load (const std::string &filepath)
 Loads presets from a JSON file (clears existing data first).
 
void LoadFromPresetList (const std::vector< ConditionPreset > &presets)
 Loads presets from a vector of ConditionPreset objects (clears existing data first).
 
bool Save (const std::string &filepath) const
 Saves all presets to a JSON file.
 

Static Private Member Functions

static std::string GenerateID ()
 Generates a new UUID suitable for a preset ID.
 

Private Attributes

std::map< std::string, ConditionPresetm_presets
 UUID -> ConditionPreset.
 
std::vector< std::string > m_order
 UUIDs in insertion order.
 
std::vector< std::string > m_errors
 Accumulated error messages.
 

Detailed Description

Manages the global pool of ConditionPreset objects.

Presets are stored in insertion order using a std::map keyed by UUID. An ordered list (m_order) preserves display order in the UI.

Definition at line 48 of file ConditionPresetRegistry.h.

Constructor & Destructor Documentation

◆ ConditionPresetRegistry() [1/2]

Olympe::ConditionPresetRegistry::ConditionPresetRegistry ( )
default

◆ ConditionPresetRegistry() [2/2]

Olympe::ConditionPresetRegistry::ConditionPresetRegistry ( const ConditionPresetRegistry )
delete

Member Function Documentation

◆ Clear()

void Olympe::ConditionPresetRegistry::Clear ( )

Clears all presets and resets error state.

Definition at line 166 of file ConditionPresetRegistry.cpp.

References m_errors, m_order, and m_presets.

Referenced by Load(), LoadFromPresetList(), and Olympe::VisualScriptEditorPanel::LoadTemplate().

+ Here is the caller graph for this function:

◆ CreatePreset()

std::string Olympe::ConditionPresetRegistry::CreatePreset ( const ConditionPreset preset)

Adds a preset to the registry.

If preset.id is empty a new UUID is generated. If the ID already exists the operation is a no-op and the existing ID is returned.

Parameters
presetPreset to add (id may be empty — will be assigned).
Returns
The UUID of the stored preset.

Definition at line 27 of file ConditionPresetRegistry.cpp.

References GenerateID(), GetComponentTypeID_Static(), Olympe::ConditionPreset::id, m_order, and m_presets.

Referenced by DuplicatePreset(), and Olympe::ConditionPresetLibraryPanel::OnAddPresetClicked().

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

◆ DeletePreset()

void Olympe::ConditionPresetRegistry::DeletePreset ( const std::string &  id)

Removes a preset from the registry.

If the ID is not found, the call is a no-op.

Parameters
idPreset UUID to remove.

Definition at line 74 of file ConditionPresetRegistry.cpp.

References GetComponentTypeID_Static(), m_order, and m_presets.

Referenced by Olympe::ConditionPresetLibraryPanel::OnDeleteConfirmed().

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

◆ DuplicatePreset()

std::string Olympe::ConditionPresetRegistry::DuplicatePreset ( const std::string &  id)

Creates an independent copy of an existing preset with a new UUID.

The copy's name is suffixed with " (Copy)". Returns the new UUID, or an empty string if the source ID is not found.

Parameters
idSource preset UUID.
Returns
UUID of the newly created duplicate.

Definition at line 84 of file ConditionPresetRegistry.cpp.

References CreatePreset(), GetComponentTypeID_Static(), GetPreset(), and Olympe::ConditionPreset::id.

Referenced by Olympe::ConditionPresetLibraryPanel::OnDuplicatePresetClicked().

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

◆ FindPresetsByName()

std::vector< std::string > Olympe::ConditionPresetRegistry::FindPresetsByName ( const std::string &  substring) const

Returns UUIDs of all presets whose name contains a substring.

Case-sensitive search.

Parameters
substringSearch string.

Definition at line 112 of file ConditionPresetRegistry.cpp.

References GetComponentTypeID_Static(), m_order, and m_presets.

Referenced by Olympe::NodeConditionsEditModal::GetFilteredPresetsForDropdown(), and Olympe::NodeConditionsPanel::GetFilteredPresetsForDropdown().

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

◆ GenerateID()

std::string Olympe::ConditionPresetRegistry::GenerateID ( )
staticprivate

Generates a new UUID suitable for a preset ID.

Definition at line 285 of file ConditionPresetRegistry.cpp.

References GetComponentTypeID_Static().

Referenced by CreatePreset().

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

◆ GetAllErrors()

std::vector< std::string > Olympe::ConditionPresetRegistry::GetAllErrors ( ) const

Returns all error messages accumulated since the last Clear().

Definition at line 161 of file ConditionPresetRegistry.cpp.

References m_errors.

◆ GetAllPresetIDs()

std::vector< std::string > Olympe::ConditionPresetRegistry::GetAllPresetIDs ( ) const

Returns all preset UUIDs in display order.

Definition at line 101 of file ConditionPresetRegistry.cpp.

References m_order.

Referenced by Olympe::NodeConditionsEditModal::GetFilteredPresetsForDropdown(), Olympe::NodeConditionsPanel::GetFilteredPresetsForDropdown(), and Olympe::VisualScriptEditorPanel::SyncPresetsFromRegistryToTemplate().

+ Here is the caller graph for this function:

◆ GetFilteredPresets()

std::vector< ConditionPreset > Olympe::ConditionPresetRegistry::GetFilteredPresets ( const std::string &  filter) const

Returns all presets whose name contains the filter substring.

If filter is empty, returns all presets in display order. Case-sensitive search.

Parameters
filterSearch string (empty = match all).
Returns
Vector of matching ConditionPreset objects.

Definition at line 129 of file ConditionPresetRegistry.cpp.

References GetComponentTypeID_Static(), m_order, and m_presets.

Referenced by Olympe::ConditionPresetLibraryPanel::GetFilteredPresets(), Olympe::PresetDropdownHelper::GetVisiblePresetCount(), Olympe::PresetDropdownHelper::Render(), and Olympe::NodeConditionsPanel::RenderInlineAddCondition().

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

◆ GetPreset() [1/2]

ConditionPreset * Olympe::ConditionPresetRegistry::GetPreset ( const std::string &  id)

◆ GetPreset() [2/2]

const ConditionPreset * Olympe::ConditionPresetRegistry::GetPreset ( const std::string &  id) const

Returns a const pointer to the preset, or nullptr if not found.

Parameters
idPreset UUID.

Definition at line 52 of file ConditionPresetRegistry.cpp.

References GetComponentTypeID_Static(), and m_presets.

+ Here is the call graph for this function:

◆ GetPresetCount()

size_t Olympe::ConditionPresetRegistry::GetPresetCount ( ) const

Returns the total number of presets in the registry.

Definition at line 106 of file ConditionPresetRegistry.cpp.

References m_presets.

◆ Load()

bool Olympe::ConditionPresetRegistry::Load ( const std::string &  filepath)

Loads presets from a JSON file (clears existing data first).

Expected format:

{
"version": 1,
"presets": [ ... ]
}
Parameters
filepathPath to the JSON file.
Returns
true on success, false on file/parse error.

Definition at line 177 of file ConditionPresetRegistry.cpp.

References Clear(), Olympe::ConditionPreset::FromJson(), GetComponentTypeID_Static(), m_errors, m_order, and m_presets.

Referenced by Olympe::VSGraphExecutor::HandleBranch().

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

◆ LoadFromPresetList()

void Olympe::ConditionPresetRegistry::LoadFromPresetList ( const std::vector< ConditionPreset > &  presets)

Loads presets from a vector of ConditionPreset objects (clears existing data first).

Phase 24 — Supports graph-embedded presets. This method is used when presets are deserialized from a blueprint JSON instead of from an external file. Each preset's UUID is preserved from the preset object itself.

Parameters
presetsVector of ConditionPreset objects to load.

Definition at line 263 of file ConditionPresetRegistry.cpp.

References Clear(), GetComponentTypeID_Static(), m_order, and m_presets.

Referenced by Olympe::VisualScriptEditorPanel::Initialize(), and Olympe::VisualScriptEditorPanel::LoadTemplate().

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

◆ operator=()

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

◆ Save()

bool Olympe::ConditionPresetRegistry::Save ( const std::string &  filepath) const

Saves all presets to a JSON file.

Creates the file if it does not exist; overwrites if it does. Parent directories must already exist.

Parameters
filepathDestination path.
Returns
true on success, false on write error.

Definition at line 232 of file ConditionPresetRegistry.cpp.

References GetComponentTypeID_Static(), m_errors, m_order, and m_presets.

Referenced by Olympe::ConditionPresetLibraryPanel::OnAddPresetClicked(), Olympe::ConditionPresetLibraryPanel::OnDeleteConfirmed(), and Olympe::ConditionPresetLibraryPanel::OnDuplicatePresetClicked().

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

◆ UpdatePreset()

void Olympe::ConditionPresetRegistry::UpdatePreset ( const std::string &  id,
const ConditionPreset updated 
)

Replaces the data of an existing preset (id must already exist).

If the ID is not found, logs an error and returns without modifying state. The preset's id field in updated is forced to match id.

Parameters
idPreset UUID to update.
updatedNew preset data.

Definition at line 60 of file ConditionPresetRegistry.cpp.

References GetComponentTypeID_Static(), Olympe::ConditionPreset::id, m_errors, and m_presets.

+ Here is the call graph for this function:

◆ ValidatePresetID()

bool Olympe::ConditionPresetRegistry::ValidatePresetID ( const std::string &  id) const

Returns true when a preset with the given UUID exists.

Definition at line 156 of file ConditionPresetRegistry.cpp.

References m_presets.

Referenced by Olympe::NodeConditionsPanel::Validate().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_errors

std::vector<std::string> Olympe::ConditionPresetRegistry::m_errors
mutableprivate

Accumulated error messages.

Definition at line 214 of file ConditionPresetRegistry.h.

Referenced by Clear(), GetAllErrors(), Load(), Save(), and UpdatePreset().

◆ m_order

std::vector<std::string> Olympe::ConditionPresetRegistry::m_order
private

◆ m_presets

std::map<std::string, ConditionPreset> Olympe::ConditionPresetRegistry::m_presets
private

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