DEKI/ENGINE docs
Deki 0.19.0
Modular C++ 2D engine for embedded displays and desktop
Loading...
Searching...
No Matches
DekiEditor::GuidCache Class Reference

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 ()

Detailed Description

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").

Constructor & Destructor Documentation

◆ GuidCache()

DekiEditor::GuidCache::GuidCache ( )

◆ ~GuidCache()

DekiEditor::GuidCache::~GuidCache ( )

Member Function Documentation

◆ Load()

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.

◆ Save()

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

Writes the cache file (e.g. "cache/guids.json").

◆ Rebuild()

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

Clears the cache and reads every .data file under the absolute assets root.

◆ Sync()

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

Updates the cache from the files that changed under the absolute assets root.

◆ OnFileCreated()

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

◆ OnFileModified()

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

◆ OnFileDeleted()

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

◆ OnFileMoved()

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

◆ GetGuid()

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

The GUID of an asset path, or "" if not found.

◆ GetPath()

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

The asset path of a GUID, or "" if not found.

◆ Contains()

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

◆ GetEntryCount()

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

◆ Clear()

void DekiEditor::GuidCache::Clear ( )

◆ GetCollisionsResolved()

size_t DekiEditor::GuidCache::GetCollisionsResolved ( ) const
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.

◆ BeginBatch()

void DekiEditor::GuidCache::BeginBatch ( )
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.

◆ EndBatch()

void DekiEditor::GuidCache::EndBatch ( )

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