Deki 1.3.0
Modular C++ 2D engine for embedded displays and desktop
Loading...
Searching...
No Matches
DekiEditor::GuidCache Class Reference

Cache for mapping asset paths to GUIDs using .data sidecar files. More...

#include <GuidCache.h>

Public Member Functions

 GuidCache ()
 ~GuidCache ()
bool Load (const std::string &cachePath)
 Load cache from disk.
void Save (const std::string &cachePath) const
 Save cache to disk.
void Rebuild (const std::string &assetsRoot)
 Full rebuild - clears cache and scans all .data files.
void Sync (const std::string &assetsRoot)
 Incremental sync - updates cache based on file changes.
void OnFileCreated (const std::string &path)
 Handle new file creation (hot reload).
void OnFileModified (const std::string &path)
 Handle file modification (hot reload).
void OnFileDeleted (const std::string &path)
 Handle file deletion (hot reload).
void OnFileMoved (const std::string &oldPath, const std::string &newPath)
 Handle file move/rename (hot reload).
std::string GetGuid (const std::string &path) const
 Get GUID for an asset path.
std::string GetPath (const std::string &guid) const
 Get asset path for a GUID.
bool Contains (const std::string &path) const
 Check if a path is tracked in the cache.
size_t GetEntryCount () const
 Get number of cached entries.
void Clear ()
 Clear all cached data.
size_t GetCollisionsResolved () const
 Number of GUID collisions resolved during the last Rebuild/Sync.

Detailed Description

Cache for mapping asset paths to GUIDs using .data sidecar files.

Provides efficient GUID lookups by caching path-to-GUID mappings in a JSON file. Syncs with .data sidecar files on disk, tracking modification times to detect changes.

This cache only stores the main asset GUID. Domain-specific information like font variants should be stored in the .data sidecar files themselves.

Cache file format (cache/guids.json): { "version": 3, "entries": { "sprites/player.png": {"guid": "abc123...", "sidecarMtime": 1706540123}, "fonts/Quicksand.ttf": {"guid": "def456...", "sidecarMtime": 1706540456} } }

Constructor & Destructor Documentation

◆ GuidCache()

DekiEditor::GuidCache::GuidCache ( )

◆ ~GuidCache()

DekiEditor::GuidCache::~GuidCache ( )

Member Function Documentation

◆ Load()

bool DekiEditor::GuidCache::Load ( const std::string & cachePath)

Load cache from disk.

Parameters
cachePathPath to cache file (e.g., "cache/guids.json")
Returns
true on success, false if file missing/corrupt (caller should Rebuild)

◆ Save()

void DekiEditor::GuidCache::Save ( const std::string & cachePath) const

Save cache to disk.

Parameters
cachePathPath to cache file (e.g., "cache/guids.json")

◆ Rebuild()

void DekiEditor::GuidCache::Rebuild ( const std::string & assetsRoot)

Full rebuild - clears cache and scans all .data files.

Parameters
assetsRootAbsolute path to assets directory

◆ Sync()

void DekiEditor::GuidCache::Sync ( const std::string & assetsRoot)

Incremental sync - updates cache based on file changes.

Parameters
assetsRootAbsolute path to assets directory

◆ OnFileCreated()

void DekiEditor::GuidCache::OnFileCreated ( const std::string & path)

Handle new file creation (hot reload).

Parameters
pathAsset path relative to assets root (e.g., "sprites/player.png")

◆ OnFileModified()

void DekiEditor::GuidCache::OnFileModified ( const std::string & path)

Handle file modification (hot reload).

Parameters
pathAsset path relative to assets root

◆ OnFileDeleted()

void DekiEditor::GuidCache::OnFileDeleted ( const std::string & path)

Handle file deletion (hot reload).

Parameters
pathAsset path relative to assets root

◆ OnFileMoved()

void DekiEditor::GuidCache::OnFileMoved ( const std::string & oldPath,
const std::string & newPath )

Handle file move/rename (hot reload).

Parameters
oldPathPrevious asset path relative to assets root
newPathNew asset path relative to assets root

◆ GetGuid()

std::string DekiEditor::GuidCache::GetGuid ( const std::string & path) const

Get GUID for an asset path.

Parameters
pathAsset path relative to assets root
Returns
GUID string, or empty if not found

◆ GetPath()

std::string DekiEditor::GuidCache::GetPath ( const std::string & guid) const

Get asset path for a GUID.

Parameters
guidGUID string
Returns
Asset path relative to assets root, or empty if not found

◆ Contains()

bool DekiEditor::GuidCache::Contains ( const std::string & path) const

Check if a path is tracked in the cache.

Parameters
pathAsset path relative to assets root

◆ GetEntryCount()

size_t DekiEditor::GuidCache::GetEntryCount ( ) const
inline

Get number of cached entries.

◆ Clear()

void DekiEditor::GuidCache::Clear ( )

Clear all cached data.

◆ GetCollisionsResolved()

size_t DekiEditor::GuidCache::GetCollisionsResolved ( ) const
inline

Number of GUID collisions resolved during the last Rebuild/Sync.

A collision is two live assets carrying the same GUID — normally because a folder was copied with its .data sidecars. The cache mints a fresh GUID for the newcomer and rewrites its sidecar; this counter exists so callers can report that it happened rather than have references silently move.


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