DEKI/ENGINE docs
manual api reference
Deki 0.40.1
Modular C++ engine with a visual editor, for 2D and 3D
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 ()
void BeginBatch ()
 Holds the file-change handlers' saves until EndBatch, which writes the file once if anything changed.
void Clear ()
bool Contains (const std::string &path) const
void EndBatch ()
size_t GetCollisionsResolved () const
 How many GUID collisions the last Rebuild/Sync resolved.
size_t GetEntryCount () const
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 Load (const std::string &cachePath)
 Loads the cache file (e.g.
void OnFileCreated (const std::string &path)
void OnFileDeleted (const std::string &path)
void OnFileModified (const std::string &path)
void OnFileMoved (const std::string &oldPath, const std::string &newPath)
void Rebuild (const std::string &assetsRoot)
 Clears the cache and reads every .data file under the absolute assets root.
void Save (const std::string &cachePath) const
 Writes the cache file (e.g. "cache/guids.json").
void Sync (const std::string &assetsRoot)
 Updates the cache from the files that changed under the absolute assets root.

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

◆ 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.

◆ Clear()

void DekiEditor::GuidCache::Clear ( )

◆ Contains()

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

◆ EndBatch()

void DekiEditor::GuidCache::EndBatch ( )

◆ 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.

◆ GetEntryCount()

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

◆ 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.

◆ 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.

◆ OnFileCreated()

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

◆ OnFileDeleted()

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

◆ OnFileModified()

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

◆ OnFileMoved()

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

◆ Rebuild()

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

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

◆ Save()

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

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

◆ Sync()

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

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


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