|
Deki 1.3.0
Modular C++ 2D engine for embedded displays and desktop
|
Asset pipeline service - handles GUID creation, caching, and asset discovery. More...
#include <AssetPipeline.h>
Public Types | |
| enum class | SyncHandlerPolicy { OnSourceChange , Always } |
| When should a registered sync handler fire on ProcessAsset? More... | |
| using | AssetSyncHandler |
| Asset sync handler callback type Called during ProcessAsset for registered extensions. | |
| using | CacheVariantProvider |
| Cache-variant provider callback type. | |
Public Member Functions | |
| AssetPipeline () | |
| ~AssetPipeline () | |
| void | RegisterSyncHandler (const std::string &extension, AssetSyncHandler handler, SyncHandlerPolicy policy=SyncHandlerPolicy::OnSourceChange) |
| Register a sync handler for a file extension Handlers are called after an asset is processed during ImportAllAssets() or a watcher-driven Tick(), subject to the supplied policy. | |
| void | RegisterCacheHandler (const std::string &extension, AssetCacheHandler handler) |
| Register a cache handler for a file extension. | |
| void | SetDefaultCacheHandler (AssetCacheHandler handler) |
| Set the default cache handler for extensions without a specific handler. | |
| void | RegisterCacheVariantProvider (const std::string &extension, CacheVariantProvider provider) |
| Register a cache-variant provider for a file extension. | |
| std::string | MakeProjectRelative (const std::string &absolutePath) const |
| Convert an absolute path to a project-relative path. | |
| void | Start (const std::string &assetsPath, const std::string &projectPath) |
| Start the pipeline. | |
| void | Stop () |
| Stop the pipeline. | |
| void | ImportAllAssets () |
| Import all assets (called on project load). | |
| void | Tick () |
| Drain pending file-watcher events and reprocess affected assets. | |
| const AssetInfo * | GetAssetInfo (const std::string &relativePath) const |
| Get asset info by project-relative path. | |
| const AssetInfo * | GetAssetInfoByGuid (const std::string &guid) const |
| Get asset info by GUID. | |
| void | RefreshAsset (const std::string &relativePath) |
| Refresh a specific asset (reimport and regenerate cache). | |
| void | RemoveAsset (const std::string &relativePath) |
| Remove an asset from the pipeline index and GuidCache. | |
| std::string | GetAbsolutePath (const std::string &relativePath) const |
| Get absolute path from project-relative path. | |
| const std::string & | GetProjectPath () const |
| Get project path. | |
| const std::string & | GetAssetsPath () const |
| const std::unordered_map< std::string, AssetInfo > & | GetAllAssets () const |
| Get all discovered assets. | |
| std::string | GetOrCreateAssetGuid (const std::string &relativePath) |
| Get or create GUID for an asset (creates .data sidecar file). | |
| int | CleanCache () |
| Clean cache - remove orphaned cache files. | |
| void | UpdateAssetTable () |
| Update the persistent asset lookup table (cache/asset_table.bin). | |
| void | ValidateCache () |
| Validate cache integrity and remove orphaned files. | |
| const std::vector< SubAssetInfo > * | GetSubAssets (const std::string &parentGuid) const |
| Get all sub-assets for a parent asset. | |
| const SubAssetInfo * | GetSubAsset (const std::string &guid) const |
| Get sub-asset info by GUID. | |
| void | RegisterSubAssets (const std::string &parentGuid, const std::vector< SubAssetInfo > &subAssets) |
| Register sub-assets for a parent asset (generic for all asset types). | |
| bool | CompileSceneFile (const std::string &scenePath, const std::string &binaryPath) |
| bool | CompileAssetFile (const std::string &assetPath, const std::string &cachePath) |
Static Public Member Functions | |
| static AssetPipeline * | Instance () |
| Get the current active pipeline instance. | |
| static void | OnStarted (std::function< void(AssetPipeline *)> callback) |
| Register a callback to be invoked when a pipeline starts If a pipeline is already active, callback is invoked immediately. | |
| static void | OnImportComplete (std::function< void(AssetPipeline *)> callback) |
| Register a callback for when all assets have been imported. | |
| static void | ClearOnStartedCallbacks () |
| Clear all OnStarted callbacks and sync handlers. | |
| static std::string | GetAssetTypeFromExtension (const std::string &ext) |
| Get asset type name from file extension. | |
Public Attributes | |
| std::function< void(const std::string &)> | OnAssetDiscovered |
| std::function< void(const std::string &)> | OnAssetChanged |
| std::function< void(const std::string &relativePath, const std::string &guid)> | OnAssetDeleted |
| std::function< void(const std::string &)> | OnAssetCreated |
Asset pipeline service - handles GUID creation, caching, and asset discovery.
Unity-like asset import pipeline. Discovers assets, assigns GUIDs, and compiles to cache format.
Asset sync handler callback type Called during ProcessAsset for registered extensions.
| absolutePath | Absolute path to the asset file |
| guid | Asset's GUID |
| projectPath | Absolute path to the project root |
Cache-variant provider callback type.
For asset types that produce derived cache files (e.g. font baking emits one variant per requested size + atlas siblings), the owning package declares which derived GUIDs belong to a given source asset. The pipeline consults registered providers when sweeping orphaned cache files so still- needed variants are not deleted.
The provider should insert all derived GUIDs into outValidGuids. The source asset's own GUID is already kept by the pipeline — providers only need to enumerate variants.
|
strong |
| DekiEditor::AssetPipeline::AssetPipeline | ( | ) |
| DekiEditor::AssetPipeline::~AssetPipeline | ( | ) |
|
static |
Get the current active pipeline instance.
|
static |
Register a callback to be invoked when a pipeline starts If a pipeline is already active, callback is invoked immediately.
Use this to register sync handlers from package initialization code.
| callback | Function to call with the pipeline pointer |
|
static |
Register a callback for when all assets have been imported.
Called after ImportAllAssets() finishes. Use this to register sub-assets that depend on cache state (e.g., baked font variants).
| callback | Function to call with the pipeline pointer |
|
static |
Clear all OnStarted callbacks and sync handlers.
Must be called BEFORE unloading package DLLs that registered callbacks. After reload, packages will re-register via DekiPlugin_RegisterComponents.
| void DekiEditor::AssetPipeline::RegisterSyncHandler | ( | const std::string & | extension, |
| AssetSyncHandler | handler, | ||
| SyncHandlerPolicy | policy = SyncHandlerPolicy::OnSourceChange ) |
Register a sync handler for a file extension Handlers are called after an asset is processed during ImportAllAssets() or a watcher-driven Tick(), subject to the supplied policy.
Default is OnSourceChange so warm reopens are fast.
| extension | File extension including dot (e.g., ".ttf") |
| handler | Callback to invoke for assets with this extension |
| policy | When the handler should fire (default: OnSourceChange) |
| void DekiEditor::AssetPipeline::RegisterCacheHandler | ( | const std::string & | extension, |
| AssetCacheHandler | handler ) |
Register a cache handler for a file extension.
Cache handlers are called during ProcessAsset to generate cache files. Packages can override built-in handlers by registering for the same extension.
| extension | File extension including dot (e.g., ".png") |
| handler | Callback to invoke for assets with this extension |
| void DekiEditor::AssetPipeline::SetDefaultCacheHandler | ( | AssetCacheHandler | handler | ) |
Set the default cache handler for extensions without a specific handler.
| handler | Fallback handler called for unregistered extensions |
| void DekiEditor::AssetPipeline::RegisterCacheVariantProvider | ( | const std::string & | extension, |
| CacheVariantProvider | provider ) |
Register a cache-variant provider for a file extension.
Called during cache cleanup / validation. Packages that produce derived cache files (font sizes, etc.) register here so the pipeline doesn't delete their variants as orphans.
| std::string DekiEditor::AssetPipeline::MakeProjectRelative | ( | const std::string & | absolutePath | ) | const |
Convert an absolute path to a project-relative path.
| absolutePath | Absolute filesystem path |
| void DekiEditor::AssetPipeline::Start | ( | const std::string & | assetsPath, |
| const std::string & | projectPath ) |
Start the pipeline.
| assetsPath | Absolute path to assets directory |
| projectPath | Absolute path to project root |
| void DekiEditor::AssetPipeline::Stop | ( | ) |
Stop the pipeline.
| void DekiEditor::AssetPipeline::ImportAllAssets | ( | ) |
Import all assets (called on project load).
| void DekiEditor::AssetPipeline::Tick | ( | ) |
Drain pending file-watcher events and reprocess affected assets.
Call once per frame from the editor main loop. Coalesced events delivered by AssetFileWatcher (Added / Modified / Deleted) drive ProcessAsset and fire OnAssetDiscovered / OnAssetChanged / OnAssetDeleted on the main thread (downstream subscribers touch GPU resources, so this must not run on the watcher's worker thread).
| const AssetInfo * DekiEditor::AssetPipeline::GetAssetInfo | ( | const std::string & | relativePath | ) | const |
Get asset info by project-relative path.
| relativePath | e.g., "assets/textures/player.png" |
| const AssetInfo * DekiEditor::AssetPipeline::GetAssetInfoByGuid | ( | const std::string & | guid | ) | const |
Get asset info by GUID.
|
static |
Get asset type name from file extension.
| ext | File extension including dot (e.g., ".scene", ".png") |
| void DekiEditor::AssetPipeline::RefreshAsset | ( | const std::string & | relativePath | ) |
Refresh a specific asset (reimport and regenerate cache).
| relativePath | Project-relative path |
| void DekiEditor::AssetPipeline::RemoveAsset | ( | const std::string & | relativePath | ) |
Remove an asset from the pipeline index and GuidCache.
Call before RefreshAsset when an asset has been moved/renamed.
| relativePath | Project-relative path of the OLD location |
| std::string DekiEditor::AssetPipeline::GetAbsolutePath | ( | const std::string & | relativePath | ) | const |
Get absolute path from project-relative path.
|
inline |
Get project path.
|
inline |
|
inline |
Get all discovered assets.
| std::string DekiEditor::AssetPipeline::GetOrCreateAssetGuid | ( | const std::string & | relativePath | ) |
Get or create GUID for an asset (creates .data sidecar file).
| relativePath | Project-relative path |
| int DekiEditor::AssetPipeline::CleanCache | ( | ) |
Clean cache - remove orphaned cache files.
| void DekiEditor::AssetPipeline::UpdateAssetTable | ( | ) |
Update the persistent asset lookup table (cache/asset_table.bin).
This maintains cache/asset_table.bin as the single source of truth for asset resolution. Called automatically after ProcessAsset() and asset deletions. PlayMode and ExportToStorage both use this table directly.
| void DekiEditor::AssetPipeline::ValidateCache | ( | ) |
Validate cache integrity and remove orphaned files.
Called on project load to ensure cache is consistent with source assets. Removes any cache files that don't correspond to known assets.
| const std::vector< SubAssetInfo > * DekiEditor::AssetPipeline::GetSubAssets | ( | const std::string & | parentGuid | ) | const |
Get all sub-assets for a parent asset.
| parentGuid | Parent asset's GUID |
| const SubAssetInfo * DekiEditor::AssetPipeline::GetSubAsset | ( | const std::string & | guid | ) | const |
| void DekiEditor::AssetPipeline::RegisterSubAssets | ( | const std::string & | parentGuid, |
| const std::vector< SubAssetInfo > & | subAssets ) |
Register sub-assets for a parent asset (generic for all asset types).
| parentGuid | Parent asset's GUID |
| subAssets | Vector of sub-asset information |
| bool DekiEditor::AssetPipeline::CompileSceneFile | ( | const std::string & | scenePath, |
| const std::string & | binaryPath ) |
| bool DekiEditor::AssetPipeline::CompileAssetFile | ( | const std::string & | assetPath, |
| const std::string & | cachePath ) |
| std::function<void(const std::string&)> DekiEditor::AssetPipeline::OnAssetDiscovered |
| std::function<void(const std::string&)> DekiEditor::AssetPipeline::OnAssetChanged |
| std::function<void(const std::string& relativePath, const std::string& guid)> DekiEditor::AssetPipeline::OnAssetDeleted |
| std::function<void(const std::string&)> DekiEditor::AssetPipeline::OnAssetCreated |