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

Singleton that stores, serialises, and retrieves NodePreset instances. More...

#include <NodePresets.h>

Public Member Functions

void LoadPresets (const std::string &path)
 Loads presets from a JSON file at path.
 
void SavePresets (const std::string &path) const
 Saves all current presets to a JSON file at path.
 
void AddPreset (const NodePreset &preset)
 Adds or replaces a preset (matched by name).
 
void RemovePreset (const std::string &name)
 Removes the preset with the given name.
 
NodePresetGetPreset (const std::string &name)
 Returns a pointer to the preset with the given name.
 
std::vector< NodePresetGetPresetsInCategory (const std::string &category) const
 Returns all presets that belong to category.
 
int GetPresetCount () const
 Returns the total number of stored presets.
 
void Clear ()
 Removes all presets.
 

Static Public Member Functions

static NodePresetManagerGet ()
 Returns the single shared instance.
 

Private Member Functions

 NodePresetManager ()
 

Private Attributes

std::vector< NodePresetm_Presets
 

Detailed Description

Singleton that stores, serialises, and retrieves NodePreset instances.

Typical usage:

pm.LoadPresets("Config/presets.json");
p.name = "MyPatrol";
p.category = "AI";
pm.AddPreset(p);
auto* found = pm.GetPreset("MyPatrol");
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
static NodePresetManager & Get()
Returns the single shared instance.
A saved node configuration that can be applied to the active graph.
Definition NodePresets.h:37
std::string name
Unique preset identifier.
Definition NodePresets.h:38

Definition at line 69 of file NodePresets.h.

Constructor & Destructor Documentation

◆ NodePresetManager()

Olympe::NodePresetManager::NodePresetManager ( )
private

Definition at line 77 of file NodePresets.cpp.

Member Function Documentation

◆ AddPreset()

void Olympe::NodePresetManager::AddPreset ( const NodePreset preset)

Adds or replaces a preset (matched by name).

Definition at line 149 of file NodePresets.cpp.

References GetComponentTypeID_Static(), and m_Presets.

+ Here is the call graph for this function:

◆ Clear()

void Olympe::NodePresetManager::Clear ( )

Removes all presets.

Definition at line 202 of file NodePresets.cpp.

References m_Presets.

Referenced by LoadPresets().

+ Here is the caller graph for this function:

◆ Get()

NodePresetManager & Olympe::NodePresetManager::Get ( )
static

Returns the single shared instance.

Definition at line 71 of file NodePresets.cpp.

◆ GetPreset()

NodePreset * Olympe::NodePresetManager::GetPreset ( const std::string &  name)

Returns a pointer to the preset with the given name.

Returns
Pointer, or nullptr if not found.

Definition at line 175 of file NodePresets.cpp.

References GetComponentTypeID_Static(), and m_Presets.

+ Here is the call graph for this function:

◆ GetPresetCount()

int Olympe::NodePresetManager::GetPresetCount ( ) const

Returns the total number of stored presets.

Definition at line 197 of file NodePresets.cpp.

References m_Presets.

◆ GetPresetsInCategory()

std::vector< NodePreset > Olympe::NodePresetManager::GetPresetsInCategory ( const std::string &  category) const

Returns all presets that belong to category.

Definition at line 185 of file NodePresets.cpp.

References GetComponentTypeID_Static(), and m_Presets.

+ Here is the call graph for this function:

◆ LoadPresets()

void Olympe::NodePresetManager::LoadPresets ( const std::string &  path)

Loads presets from a JSON file at path.

Existing presets are replaced.

Definition at line 85 of file NodePresets.cpp.

References Clear(), Olympe::NodePreset::FromJson(), GetComponentTypeID_Static(), m_Presets, and SYSTEM_LOG.

+ Here is the call graph for this function:

◆ RemovePreset()

void Olympe::NodePresetManager::RemovePreset ( const std::string &  name)

Removes the preset with the given name.

No-op if not found.

Definition at line 163 of file NodePresets.cpp.

References GetComponentTypeID_Static(), and m_Presets.

+ Here is the call graph for this function:

◆ SavePresets()

void Olympe::NodePresetManager::SavePresets ( const std::string &  path) const

Saves all current presets to a JSON file at path.

Definition at line 124 of file NodePresets.cpp.

References GetComponentTypeID_Static(), m_Presets, and SYSTEM_LOG.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_Presets

std::vector<NodePreset> Olympe::NodePresetManager::m_Presets
private

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