XII Release 0.1.0
Loading...
Searching...
No Matches
xiiAssetCurator Class Reference

Public Member Functions

Setup
void StartInitialize (const xiiApplicationFileSystemConfig &cfg)
 Starts init task. Need to call WaitForInitialize to finish before loading docs.
void WaitForInitialize ()
 Waits for init task to finish.
void Deinitialize ()
void MainThreadTick (bool bTopLevel)
High Level Functions
xiiDateTime GetLastFullTransformDate () const
void StoreFullTransformDate ()
xiiStatus TransformAllAssets (xiiBitflags< xiiTransformFlags > transformFlags, const xiiPlatformProfile *pAssetProfile=nullptr)
 Transforms all assets and writes the lookup tables. If the given platform is empty, the active platform is used.
xiiTransformStatus TransformAsset (const xiiUuid &assetGuid, xiiBitflags< xiiTransformFlags > transformFlags, const xiiPlatformProfile *pAssetProfile=nullptr)
xiiTransformStatus CreateThumbnail (const xiiUuid &assetGuid)
xiiStatus GetAssetResaveOrder (xiiStringView sPrefixPath, xiiDynamicArray< xiiUuid > &out_order) const
 Copyright (c) Theophilus Eriata. All Rights Reserved.
xiiStatus ResaveAllAssets (xiiStringView sPrefixPath)
void TransformAssetsForSceneExport (const xiiPlatformProfile *pAssetProfile=nullptr)
xiiResult WriteAssetTables (const xiiPlatformProfile *pAssetProfile=nullptr, bool bForce=false)
 Writes the asset lookup table for the given platform, or the currently active platform if nullptr is passed.
Manual and Automatic Change Notification
void NotifyOfFileChange (xiiStringView sAbsolutePath)
 Allows to tell the system of a new or changed file, that might be of interest to the Curator.
void NotifyOfAssetChange (const xiiUuid &assetGuid)
 Allows to tell the system to re-evaluate an assets status.
void UpdateAssetLastAccessTime (const xiiUuid &assetGuid)
void CheckFileSystem ()
 Checks file system for any changes. Call in case the file system watcher does not pick up certain changes.
void NeedsReloadResources (const xiiUuid &assetGuid)
void InvalidateAssetsWithTransformState (xiiAssetInfo::TransformState state)
Utilities
void GenerateTransitiveHull (const xiiStringView sAssetOrPath, xiiSet< xiiString > &inout_deps, bool bIncludeTransformDeps=false, bool bIncludeThumbnailDeps=false, bool bIncludePackageDeps=false) const
void GenerateInverseTransitiveHull (const xiiAssetInfo *pAssetInfo, xiiSet< xiiUuid > &inout_inverseDeps, bool bIncludeTransformDeps=false, bool bIncludeThumbnailDeps=false, bool bIncludePackageDeps=false) const
 Generates one inverse transitive hull for all the types dependencies that are enabled. The set will contain inverse dependencies that can reach the given asset (pAssetInfo) via any combination of the enabled reference types. As only assets can have dependencies, the inverse hull is always just asset GUIDs.
xiiResult WriteDependencyDGML (const xiiUuid &guid, xiiStringView sOutputFile) const
void ClearAssetCaches (xiiAssetDocumentManager::OutputReliability threshold)

Public Attributes

xiiEvent< const xiiAssetCuratorEvent & > m_Events

Friends

class xiiUpdateTask
class xiiAssetProcessor
class xiiProcessTask

Asset Access

using xiiLockedSubAsset = xiiLockedObject<xiiMutex, const xiiSubAsset>
using xiiLockedSubAssetTable = xiiLockedObject<xiiMutex, const xiiHashTable<xiiUuid, xiiSubAsset>>
using xiiLockedAssetTable = xiiLockedObject<xiiMutex, const xiiHashTable<xiiUuid, xiiAssetInfo*>>
const xiiLockedSubAsset FindSubAsset (xiiStringView sPathOrGuid, bool bExhaustiveSearch=false) const
const xiiLockedSubAsset GetSubAsset (const xiiUuid &assetGuid) const
 Same as GetAssteInfo, but wraps the return value into a xiiLockedSubAsset struct.
const xiiLockedSubAssetTable GetKnownSubAssets () const
 Returns the table of all known assets in a locked structure.
const xiiLockedAssetTable GetKnownAssets () const
 Returns the table of all known assets in a locked structure.
xiiUInt64 GetAssetDependencyHash (xiiUuid assetGuid)
 Computes the combined hash for the asset and its dependencies. Returns 0 if anything went wrong.
xiiUInt64 GetAssetReferenceHash (xiiUuid assetGuid)
 Computes the combined hash for the asset and its references. Returns 0 if anything went wrong.
xiiAssetInfo::TransformState IsAssetUpToDate (const xiiUuid &assetGuid, const xiiPlatformProfile *pAssetProfile, const xiiAssetDocumentTypeDescriptor *pTypeDescriptor, xiiUInt64 &out_uiAssetHash, xiiUInt64 &out_uiThumbHash, xiiUInt64 &out_uiPackageHash, bool bForce=false)
void GetAssetTransformStats (xiiUInt32 &out_uiNumAssets, xiiHybridArray< xiiUInt32, xiiAssetInfo::TransformState::COUNT > &out_count)
 Returns the number of assets in the system and how many are in what transform state.
xiiString FindDataDirectoryForAsset (xiiStringView sAbsoluteAssetPath) const
 Iterates over all known data directories and returns the absolute path to the directory in which this asset is located.
xiiResult FindBestMatchForFile (xiiStringBuilder &ref_sFile, xiiArrayPtr< xiiString > allowedFileExtensions) const
void FindAllUses (xiiUuid assetGuid, xiiSet< xiiUuid > &ref_uses, bool bTransitive) const
 Copyright (c) Theophilus Eriata. All Rights Reserved.
void FindAllUses (xiiStringView sAbsolutePath, xiiSet< xiiUuid > &ref_uses) const
bool IsReferenced (xiiStringView sAbsolutePath) const

Asset Platform Configurations

const xiiPlatformProfile * GetDevelopmentAssetProfile () const
 Copyright (c) Theophilus Eriata. All Rights Reserved.
const xiiPlatformProfile * GetActiveAssetProfile () const
 The currently active target platform for asset processing.
xiiUInt32 GetActiveAssetProfileIndex () const
 Returns the index of the currently active asset platform configuration.
xiiUInt32 FindAssetProfileByName (const char *szPlatform)
 Returns xiiInvalidIndex if no config with the given name exists. Name comparison is case insensitive.
xiiUInt32 GetNumAssetProfiles () const
const xiiPlatformProfile * GetAssetProfile (xiiUInt32 uiIndex) const
 Always returns a valid config. E.g. even if xiiInvalidIndex is passed in, it will fall back to the default config (at index 0).
xiiPlatformProfile * GetAssetProfile (xiiUInt32 uiIndex)
 Always returns a valid config. E.g. even if xiiInvalidIndex is passed in, it will fall back to the default config (at index 0).
xiiPlatformProfile * CreateAssetProfile ()
 Adds a new profile. The name should be set afterwards to a unique name.
xiiResult DeleteAssetProfile (xiiPlatformProfile *pProfile)
void SetActiveAssetProfileByIndex (xiiUInt32 uiIndex, bool bForceReevaluation=false)
xiiResult SaveAssetProfiles ()
 Saves the current asset configurations. Returns failure if the output file could not be written to.
xiiResult ReloadAssetProfiles ()
xiiStatus ApplyAssetProfiles (xiiArrayPtr< const xiiPlatformProfile *const > profiles, xiiUInt32 uiActiveProfile)
xiiResult SaveRuntimeProfiles ()
 Saves all runtime profile files, stopping at the first write failure.

Member Function Documentation

◆ ApplyAssetProfiles()

xiiStatus xiiAssetCurator::ApplyAssetProfiles ( xiiArrayPtr< const xiiPlatformProfile *const > profiles,
xiiUInt32 uiActiveProfile )

Persists and publishes a complete profile collection in the supplied order. Index zero must be Default. The input is cloned; ownership is retained by the caller. Must be called on the main thread between asset operations. Stops processor jobs and hashing during publication. A failed file installation rolls back previously installed files and leaves live profiles unchanged. Rollback failures are reported with retained backup paths. This is not a crash-safe transaction across files. Successful publication invalidates all existing profile pointers.

◆ ClearAssetCaches()

void xiiAssetCurator::ClearAssetCaches ( xiiAssetDocumentManager::OutputReliability threshold)

Deletes all files in all asset caches, except for the asset outputs that exceed the threshold.

-> OutputReliability::Perfect -> deletes everything -> OutputReliability::Good -> keeps the 'Perfect' files -> OutputReliability::Unknown -> keeps the 'Good' and 'Perfect' files

◆ DeleteAssetProfile()

xiiResult xiiAssetCurator::DeleteAssetProfile ( xiiPlatformProfile * pProfile)

Deletes the given asset profile, if possible.

The function fails when the given profile is the main profile (at index 0), or it is the currently active profile.

◆ FindAllUses() [1/2]

void xiiAssetCurator::FindAllUses ( xiiStringView sAbsolutePath,
xiiSet< xiiUuid > & ref_uses ) const

Returns all assets that use a file for transform. Use this to e.g. figure which assets still reference a .tga file in the project.

Parameters
sAbsolutePathAbsolute path to any file inside a data directory.
ref_usesList of assets that use 'sAbsolutePath'. Any previous content of the set is not removed.

◆ FindAllUses() [2/2]

void xiiAssetCurator::FindAllUses ( xiiUuid assetGuid,
xiiSet< xiiUuid > & ref_uses,
bool bTransitive ) const

Copyright (c) Theophilus Eriata. All Rights Reserved.

Finds all transform, thumbnail and package uses of an asset or sub-asset.

Parameters
assetGuidThe asset to find use cases for.
usesList of assets that use 'assetGuid'. Any previous content of the set is not removed.
transitiveIf set, will also find indirect uses of the asset.

◆ FindBestMatchForFile()

xiiResult xiiAssetCurator::FindBestMatchForFile ( xiiStringBuilder & ref_sFile,
xiiArrayPtr< xiiString > allowedFileExtensions ) const

Uses knowledge about all existing files on disk to find the best match for a file. Very slow.

Parameters
sFileFile name (may include a path) to search for. Will be modified both on success and failure to give a 'reasonable' result.

◆ FindSubAsset()

const xiiAssetCurator::xiiLockedSubAsset xiiAssetCurator::FindSubAsset ( xiiStringView sPathOrGuid,
bool bExhaustiveSearch = false ) const

Tries to find the asset information for an asset identified through a string.

The string may be a stringyfied asset GUID or a relative or absolute path. The function will try all possibilities. If no asset can be found, an empty/invalid xiiAssetInfo is returned. If bExhaustiveSearch is set the function will go through all known assets and find the closest match.

◆ GenerateTransitiveHull()

void xiiAssetCurator::GenerateTransitiveHull ( const xiiStringView sAssetOrPath,
xiiSet< xiiString > & inout_deps,
bool bIncludeTransformDeps = false,
bool bIncludeThumbnailDeps = false,
bool bIncludePackageDeps = false ) const

Generates one transitive hull for all the dependencies that are enabled. The set will contain dependencies that are reachable via any combination of enabled reference types. Resolves asset paths and sub-assets to their owners for traversal. Unresolved references remain in the output as leaves. Existing output does not suppress traversal. Cycles are visited once per owner.

◆ GetAssetResaveOrder()

xiiStatus xiiAssetCurator::GetAssetResaveOrder ( xiiStringView sPrefixPath,
xiiDynamicArray< xiiUuid > & out_order ) const

Copyright (c) Theophilus Eriata. All Rights Reserved.

Plans a deterministic dependency-first resave of the selected path subtree. Empty prefix selects all assets. Includes transform, thumbnail and package references; external dependencies are already supplied by their existing metadata. Cycles fail with an empty output and no document writes.

◆ GetDevelopmentAssetProfile()

const xiiPlatformProfile * xiiAssetCurator::GetDevelopmentAssetProfile ( ) const

Copyright (c) Theophilus Eriata. All Rights Reserved.

The main platform on which development happens. E.g. "Default".

TODO: review this concept

◆ IsAssetUpToDate()

xiiAssetInfo::TransformState xiiAssetCurator::IsAssetUpToDate ( const xiiUuid & assetGuid,
const xiiPlatformProfile * pAssetProfile,
const xiiAssetDocumentTypeDescriptor * pTypeDescriptor,
xiiUInt64 & out_uiAssetHash,
xiiUInt64 & out_uiThumbHash,
xiiUInt64 & out_uiPackageHash,
bool bForce = false )

Evaluates the requested profile, defaulting to the active profile. Non-active evaluations do not read or replace the active-profile state cache. The profile must remain alive and unchanged during evaluation.

◆ IsReferenced()

bool xiiAssetCurator::IsReferenced ( xiiStringView sAbsolutePath) const

Returns whether a file is referenced, i.e. used for transforming an asset. Use this to e.g. figure out whether a .tga file is still in use by any asset.

Parameters
sAbsolutePathAbsolute path to any file inside a data directory.
Returns
True, if at least one asset references the given file.

◆ ReloadAssetProfiles()

xiiResult xiiAssetCurator::ReloadAssetProfiles ( )

Reloads changed profile definitions from disk, preserving the active profile by name. Must be called between asset operations on the main thread. Stops background hashing before replacing profiles; all previously obtained profile pointers are invalidated on change. Invalid input leaves the current definitions and active profile unchanged.

◆ ResaveAllAssets()

xiiStatus xiiAssetCurator::ResaveAllAssets ( xiiStringView sPrefixPath)

Main-thread operation. Reports cancellation and save failures. Keeps existing documents open; opens and closes other documents through their managers. Does not hold the curator lock while saving.

◆ SetActiveAssetProfileByIndex()

void xiiAssetCurator::SetActiveAssetProfileByIndex ( xiiUInt32 uiIndex,
bool bForceReevaluation = false )

Switches the currently active asset target platform.

Broadcasts xiiAssetCuratorEvent::Type::ActivePlatformChanged on change.

◆ TransformAssetsForSceneExport()

void xiiAssetCurator::TransformAssetsForSceneExport ( const xiiPlatformProfile * pAssetProfile = nullptr)

Some assets are not automatically updated by the asset dependency detection (mainly Collections) because of their transitive data dependencies. So we must update them when the user does something 'significant' like doing TransformAllAssets or a scene export.

◆ WriteDependencyDGML()

xiiResult xiiAssetCurator::WriteDependencyDGML ( const xiiUuid & guid,
xiiStringView sOutputFile ) const

Generates a DGML graph of all transform and thumbnail dependencies. Writes all dependency categories, retaining missing references as leaf nodes. Returns write failures.


The documentation for this class was generated from the following files:
  • /home/runner/work/XII/XII/Source/Editor/EditorFramework/Assets/AssetCurator.h
  • /home/runner/work/XII/XII/Source/Editor/EditorFramework/Assets/Implementation/AssetCurator.cpp
  • /home/runner/work/XII/XII/Source/Editor/EditorFramework/Assets/Implementation/AssetDependencyGraph.cpp
  • /home/runner/work/XII/XII/Source/Editor/EditorFramework/Assets/Implementation/AssetProfile.cpp
  • /home/runner/work/XII/XII/Source/Editor/EditorFramework/Assets/Implementation/AssetProfilePersistence.cpp
  • /home/runner/work/XII/XII/Source/Editor/EditorFramework/Assets/Implementation/AssetResave.cpp
  • /home/runner/work/XII/XII/Source/Editor/EditorFramework/Assets/Implementation/AssetUpdates.cpp