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

#include <EditorAutosaveManager.h>

Public Member Functions

 EditorAutosaveManager ()=default
 
 ~EditorAutosaveManager ()
 
void Init (std::function< void()> saveFn, float debounceSec=1.5f, float periodicIntervalSec=60.0f)
 Set the timing parameters and an optional legacy save callback.
 
void ScheduleSave (double nowSec)
 Notify the manager that a change occurred (legacy overload).
 
void ScheduleSave (double nowSec, std::function< std::string()> serializeFn, std::string filePath, std::string fallbackPrefix="GameData/AI/autosave_")
 Notify the manager that a change occurred (per-save lambda overload).
 
void Tick (double nowSec)
 Must be called once per frame to advance timers and launch saves.
 
void Flush ()
 Block until any running async save finishes.
 

Private Member Functions

void LaunchAsync ()
 
void LaunchAsyncWrite (std::string data, std::string path)
 

Private Attributes

std::function< void()> m_saveFn
 
std::function< std::string()> m_pendingSerializeFn
 
std::string m_pendingFilePath
 
std::string m_pendingFallbackPrefix
 
int m_fallbackCounter = 0
 
float m_debounceSec = 1.5f
 
float m_periodicIntervalSec = 60.0f
 
double m_debounceDeadline = -1.0
 
double m_lastSaveTime = -1.0
 
bool m_dirty = false
 
std::future< voidm_future
 

Detailed Description

Definition at line 42 of file EditorAutosaveManager.h.

Constructor & Destructor Documentation

◆ EditorAutosaveManager()

Olympe::EditorAutosaveManager::EditorAutosaveManager ( )
default

◆ ~EditorAutosaveManager()

Olympe::EditorAutosaveManager::~EditorAutosaveManager ( )
inline

Definition at line 46 of file EditorAutosaveManager.h.

References Flush().

+ Here is the call graph for this function:

Member Function Documentation

◆ Flush()

void Olympe::EditorAutosaveManager::Flush ( )

Block until any running async save finishes.

Call from Shutdown() or destructor.

Definition at line 105 of file EditorAutosaveManager.cpp.

References m_future.

Referenced by Olympe::BehaviorTreeDebugWindow::Shutdown(), Olympe::NodeGraphPanel::Shutdown(), and ~EditorAutosaveManager().

+ Here is the caller graph for this function:

◆ Init()

void Olympe::EditorAutosaveManager::Init ( std::function< void()>  saveFn,
float  debounceSec = 1.5f,
float  periodicIntervalSec = 60.0f 
)

Set the timing parameters and an optional legacy save callback.

Parameters
saveFnLegacy callable executed on a background thread. Pass nullptr when using the per-save lambda overload.
debounceSecSeconds to wait after the last ScheduleSave() before saving.
periodicIntervalSecMaximum seconds between forced flushes (0 = disabled).

Definition at line 13 of file EditorAutosaveManager.cpp.

References GetComponentTypeID_Static(), m_debounceSec, m_periodicIntervalSec, and m_saveFn.

Referenced by Olympe::BehaviorTreeDebugWindow::Initialize(), and Olympe::NodeGraphPanel::Initialize().

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

◆ LaunchAsync()

void Olympe::EditorAutosaveManager::LaunchAsync ( )
private

Definition at line 113 of file EditorAutosaveManager.cpp.

References GetComponentTypeID_Static(), m_future, and m_saveFn.

Referenced by Tick().

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

◆ LaunchAsyncWrite()

void Olympe::EditorAutosaveManager::LaunchAsyncWrite ( std::string  data,
std::string  path 
)
private

Definition at line 134 of file EditorAutosaveManager.cpp.

References GetComponentTypeID_Static(), and m_future.

Referenced by Tick().

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

◆ ScheduleSave() [1/2]

void Olympe::EditorAutosaveManager::ScheduleSave ( double  nowSec)

Notify the manager that a change occurred (legacy overload).

Resets the debounce timer; uses the saveFn supplied to Init().

Parameters
nowSecCurrent time in seconds (e.g. ImGui::GetTime()).

Definition at line 22 of file EditorAutosaveManager.cpp.

References GetComponentTypeID_Static(), m_debounceDeadline, m_debounceSec, and m_dirty.

Referenced by Olympe::NodeGraphPanel::RenderGraph().

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

◆ ScheduleSave() [2/2]

void Olympe::EditorAutosaveManager::ScheduleSave ( double  nowSec,
std::function< std::string()>  serializeFn,
std::string  filePath,
std::string  fallbackPrefix = "GameData/AI/autosave_" 
)

Notify the manager that a change occurred (per-save lambda overload).

Serialization runs on the calling (UI) thread inside Tick() just before the background write is launched.

Parameters
nowSecCurrent time in seconds (e.g. ImGui::GetTime()).
serializeFnCalled on the UI thread to produce the data to write. Return an empty string to skip writing.
filePathDestination path. If empty, the fallback path is used.
fallbackPrefixPrefix for the fallback filename when filePath is empty. A monotonically-increasing counter is appended. Defaults to "GameData/AI/autosave_".

Definition at line 28 of file EditorAutosaveManager.cpp.

References GetComponentTypeID_Static(), m_debounceDeadline, m_debounceSec, m_dirty, m_pendingFallbackPrefix, m_pendingFilePath, and m_pendingSerializeFn.

+ Here is the call graph for this function:

◆ Tick()

void Olympe::EditorAutosaveManager::Tick ( double  nowSec)

Must be called once per frame to advance timers and launch saves.

Must be called on the UI thread so that the per-save serializer runs on the correct thread.

Parameters
nowSecCurrent time in seconds (e.g. ImGui::GetTime()).

Definition at line 40 of file EditorAutosaveManager.cpp.

References GetComponentTypeID_Static(), LaunchAsync(), LaunchAsyncWrite(), m_debounceDeadline, m_dirty, m_fallbackCounter, m_future, m_lastSaveTime, m_pendingFallbackPrefix, m_pendingFilePath, m_pendingSerializeFn, m_periodicIntervalSec, and m_saveFn.

Referenced by Olympe::NodeGraphPanel::RenderContent().

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

Member Data Documentation

◆ m_debounceDeadline

double Olympe::EditorAutosaveManager::m_debounceDeadline = -1.0
private

Definition at line 114 of file EditorAutosaveManager.h.

Referenced by ScheduleSave(), ScheduleSave(), and Tick().

◆ m_debounceSec

float Olympe::EditorAutosaveManager::m_debounceSec = 1.5f
private

Definition at line 111 of file EditorAutosaveManager.h.

Referenced by Init(), ScheduleSave(), and ScheduleSave().

◆ m_dirty

bool Olympe::EditorAutosaveManager::m_dirty = false
private

Definition at line 117 of file EditorAutosaveManager.h.

Referenced by ScheduleSave(), ScheduleSave(), and Tick().

◆ m_fallbackCounter

int Olympe::EditorAutosaveManager::m_fallbackCounter = 0
private

Definition at line 109 of file EditorAutosaveManager.h.

Referenced by Tick().

◆ m_future

std::future<void> Olympe::EditorAutosaveManager::m_future
private

Definition at line 119 of file EditorAutosaveManager.h.

Referenced by Flush(), LaunchAsync(), LaunchAsyncWrite(), and Tick().

◆ m_lastSaveTime

double Olympe::EditorAutosaveManager::m_lastSaveTime = -1.0
private

Definition at line 115 of file EditorAutosaveManager.h.

Referenced by Tick().

◆ m_pendingFallbackPrefix

std::string Olympe::EditorAutosaveManager::m_pendingFallbackPrefix
private

Definition at line 108 of file EditorAutosaveManager.h.

Referenced by ScheduleSave(), and Tick().

◆ m_pendingFilePath

std::string Olympe::EditorAutosaveManager::m_pendingFilePath
private

Definition at line 107 of file EditorAutosaveManager.h.

Referenced by ScheduleSave(), and Tick().

◆ m_pendingSerializeFn

std::function<std::string()> Olympe::EditorAutosaveManager::m_pendingSerializeFn
private

Definition at line 106 of file EditorAutosaveManager.h.

Referenced by ScheduleSave(), and Tick().

◆ m_periodicIntervalSec

float Olympe::EditorAutosaveManager::m_periodicIntervalSec = 60.0f
private

Definition at line 112 of file EditorAutosaveManager.h.

Referenced by Init(), and Tick().

◆ m_saveFn

std::function<void()> Olympe::EditorAutosaveManager::m_saveFn
private

Definition at line 103 of file EditorAutosaveManager.h.

Referenced by Init(), LaunchAsync(), and Tick().


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