|
Deki 1.3.0
Modular C++ 2D engine for embedded displays and desktop
|
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. | |
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} } }
| DekiEditor::GuidCache::GuidCache | ( | ) |
| DekiEditor::GuidCache::~GuidCache | ( | ) |
| bool DekiEditor::GuidCache::Load | ( | const std::string & | cachePath | ) |
Load cache from disk.
| cachePath | Path to cache file (e.g., "cache/guids.json") |
| void DekiEditor::GuidCache::Save | ( | const std::string & | cachePath | ) | const |
Save cache to disk.
| cachePath | Path to cache file (e.g., "cache/guids.json") |
| void DekiEditor::GuidCache::Rebuild | ( | const std::string & | assetsRoot | ) |
Full rebuild - clears cache and scans all .data files.
| assetsRoot | Absolute path to assets directory |
| void DekiEditor::GuidCache::Sync | ( | const std::string & | assetsRoot | ) |
Incremental sync - updates cache based on file changes.
| assetsRoot | Absolute path to assets directory |
| void DekiEditor::GuidCache::OnFileCreated | ( | const std::string & | path | ) |
Handle new file creation (hot reload).
| path | Asset path relative to assets root (e.g., "sprites/player.png") |
| void DekiEditor::GuidCache::OnFileModified | ( | const std::string & | path | ) |
Handle file modification (hot reload).
| path | Asset path relative to assets root |
| void DekiEditor::GuidCache::OnFileDeleted | ( | const std::string & | path | ) |
Handle file deletion (hot reload).
| path | Asset path relative to assets root |
| void DekiEditor::GuidCache::OnFileMoved | ( | const std::string & | oldPath, |
| const std::string & | newPath ) |
Handle file move/rename (hot reload).
| oldPath | Previous asset path relative to assets root |
| newPath | New asset path relative to assets root |
| std::string DekiEditor::GuidCache::GetGuid | ( | const std::string & | path | ) | const |
Get GUID for an asset path.
| path | Asset path relative to assets root |
| std::string DekiEditor::GuidCache::GetPath | ( | const std::string & | guid | ) | const |
Get asset path for a GUID.
| guid | GUID string |
| bool DekiEditor::GuidCache::Contains | ( | const std::string & | path | ) | const |
Check if a path is tracked in the cache.
| path | Asset path relative to assets root |
|
inline |
Get number of cached entries.
| void DekiEditor::GuidCache::Clear | ( | ) |
Clear all cached data.
|
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.