|
Deki 0.19.0
Modular C++ 2D engine for embedded displays and desktop
|
Maps asset paths to GUIDs, read from the .data sidecar files and cached in a JSON file. More...
#include <C:/Users/kirby/Documents/Github/deki/deki-editor/deki-editor/include/deki-editor/GuidCache.h>
Public Member Functions | |
| GuidCache () | |
| ~GuidCache () | |
| bool | Load (const std::string &cachePath) |
| Loads the cache file (e.g. | |
| void | Save (const std::string &cachePath) const |
| Writes the cache file (e.g. "cache/guids.json"). | |
| void | Rebuild (const std::string &assetsRoot) |
| Clears the cache and reads every .data file under the absolute assets root. | |
| void | Sync (const std::string &assetsRoot) |
| Updates the cache from the files that changed under the absolute assets root. | |
| void | OnFileCreated (const std::string &path) |
| void | OnFileModified (const std::string &path) |
| void | OnFileDeleted (const std::string &path) |
| void | OnFileMoved (const std::string &oldPath, const std::string &newPath) |
| std::string | GetGuid (const std::string &path) const |
| The GUID of an asset path, or "" if not found. | |
| std::string | GetPath (const std::string &guid) const |
| The asset path of a GUID, or "" if not found. | |
| bool | Contains (const std::string &path) const |
| size_t | GetEntryCount () const |
| void | Clear () |
| size_t | GetCollisionsResolved () const |
| How many GUID collisions the last Rebuild/Sync resolved. | |
| void | BeginBatch () |
| Holds the file-change handlers' saves until EndBatch, which writes the file once if anything changed. | |
| void | EndBatch () |
Maps asset paths to GUIDs, read from the .data sidecar files and cached in a JSON file.
Sidecar modification times tell it what changed.
It stores only the main asset GUID. Type-specific data such as font variants belongs 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} } }
All asset paths below are relative to the assets root (e.g. "sprites/player.png").
| DekiEditor::GuidCache::GuidCache | ( | ) |
| DekiEditor::GuidCache::~GuidCache | ( | ) |
| bool DekiEditor::GuidCache::Load | ( | const std::string & | cachePath | ) |
Loads the cache file (e.g.
"cache/guids.json"). Returns false when it is missing or corrupt; the caller should then Rebuild.
| void DekiEditor::GuidCache::Save | ( | const std::string & | cachePath | ) | const |
Writes the cache file (e.g. "cache/guids.json").
| void DekiEditor::GuidCache::Rebuild | ( | const std::string & | assetsRoot | ) |
Clears the cache and reads every .data file under the absolute assets root.
| void DekiEditor::GuidCache::Sync | ( | const std::string & | assetsRoot | ) |
Updates the cache from the files that changed under the absolute assets root.
| void DekiEditor::GuidCache::OnFileCreated | ( | const std::string & | path | ) |
| void DekiEditor::GuidCache::OnFileModified | ( | const std::string & | path | ) |
| void DekiEditor::GuidCache::OnFileDeleted | ( | const std::string & | path | ) |
| void DekiEditor::GuidCache::OnFileMoved | ( | const std::string & | oldPath, |
| const std::string & | newPath ) |
| std::string DekiEditor::GuidCache::GetGuid | ( | const std::string & | path | ) | const |
The GUID of an asset path, or "" if not found.
| std::string DekiEditor::GuidCache::GetPath | ( | const std::string & | guid | ) | const |
The asset path of a GUID, or "" if not found.
| bool DekiEditor::GuidCache::Contains | ( | const std::string & | path | ) | const |
|
inline |
| void DekiEditor::GuidCache::Clear | ( | ) |
|
inline |
How many GUID collisions the last Rebuild/Sync resolved.
A collision is two live assets with the same GUID, usually because a folder was copied with its .data sidecars. The cache gives the newcomer a new GUID and rewrites its sidecar; this count lets callers report it so references do not move silently.
|
inline |
Holds the file-change handlers' saves until EndBatch, which writes the file once if anything changed.
A bulk import calls OnFileModified for every asset, and each would otherwise rewrite the whole file.
| void DekiEditor::GuidCache::EndBatch | ( | ) |