Open 3D Engine AzToolsFramework API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AzToolsFramework::AssetDatabase::AssetDatabaseConnection Class Reference

#include <AssetDatabaseConnection.h>

Inherits SQLite::SQLiteQueryLogBus::Handler.

Public Types

enum  LikeType { Raw , StartsWith , EndsWith , Matches }
 
using databaseInfoHandler = AZStd::function< bool(DatabaseInfoEntry &entry)>
 
using scanFolderHandler = AZStd::function< bool(ScanFolderDatabaseEntry &entry)>
 
using sourceHandler = AZStd::function< bool(SourceDatabaseEntry &entry)>
 
using combinedSourceScanFolderHandler = AZStd::function< bool(SourceAndScanFolderDatabaseEntry &entry)>
 
using jobHandler = AZStd::function< bool(JobDatabaseEntry &entry)>
 
using productHandler = AZStd::function< bool(ProductDatabaseEntry &entry)>
 
using combinedHandler = AZStd::function< bool(CombinedDatabaseEntry &entry)>
 
using jobInfoHandler = AZStd::function< bool(AzToolsFramework::AssetSystem::JobInfo &job)>
 
using sourceFileDependencyHandler = AZStd::function< bool(SourceFileDependencyEntry &entry)>
 
using legacySubIDsHandler = AZStd::function< bool(LegacySubIDsEntry &entry)>
 
using productDependencyHandler = AZStd::function< bool(ProductDependencyDatabaseEntry &entry)>
 
using productDependencyAndPathHandler = AZStd::function< bool(ProductDependencyDatabaseEntry &entry, const AZStd::string &path)>
 
using missingProductDependencyHandler = AZStd::function< bool(MissingProductDependencyDatabaseEntry &entry)>
 
using combinedProductDependencyHandler = AZStd::function< bool(AZ::Data::AssetId &asset, ProductDependencyDatabaseEntry &entry)>
 
using BuilderInfoHandler = std::function< bool(BuilderInfoEntry &&)>
 
using fileHandler = AZStd::function< bool(FileDatabaseEntry &entry)>
 
using statHandler = AZStd::function< bool(StatDatabaseEntry &entry)>
 

Public Member Functions

 AZ_CLASS_ALLOCATOR (AssetDatabaseConnection, AZ::SystemAllocator)
 
bool OpenDatabase (bool ignoreFutureAssetDBVersionError=false)
 
void CloseDatabase ()
 
virtual bool IsReadOnly () const
 
virtual bool PostOpenDatabase (bool ignoreFutureAssetDBVersionError)
 
virtual DatabaseVersion CurrentDatabaseVersion () const
 
bool QueryDatabaseInfoTable (databaseInfoHandler handler)
 
DatabaseVersion QueryDatabaseVersion ()
 
bool QueryScanFoldersTable (scanFolderHandler handler)
 
bool QuerySourcesTable (sourceHandler handler)
 
bool QueryJobsTable (jobHandler handler, AZ::Uuid builderGuid=AZ::Uuid::CreateNull(), const char *jobKey=nullptr, const char *platform=nullptr, AssetSystem::JobStatus status=AssetSystem::JobStatus::Any)
 
bool QueryProductsTable (productHandler handler, AZ::Uuid builderGuid=AZ::Uuid::CreateNull(), const char *jobKey=nullptr, const char *platform=nullptr, AssetSystem::JobStatus status=AssetSystem::JobStatus::Any)
 
bool QueryProductDependenciesTable (combinedProductDependencyHandler handler)
 
bool QueryBuilderInfoTable (const BuilderInfoHandler &handler)
 
bool QueryFilesTable (fileHandler handler)
 
bool QueryStatsTable (statHandler handler)
 
AZStd::string GetLikeActualSearchTerm (const char *likeString, LikeType likeType)
 
bool QueryScanFolderByScanFolderID (AZ::s64 scanfolderID, scanFolderHandler handler)
 
bool QueryScanFolderBySourceID (AZ::s64 sourceID, scanFolderHandler handler)
 
bool QueryScanFolderByJobID (AZ::s64 jobID, scanFolderHandler handler)
 
bool QueryScanFolderByProductID (AZ::s64 productID, scanFolderHandler handler)
 
bool QueryScanFolderByDisplayName (const char *displayname, scanFolderHandler handler)
 
bool QueryScanFolderByPortableKey (const char *portableKey, scanFolderHandler handler)
 
bool QuerySourceBySourceID (AZ::s64 sourceID, sourceHandler handler)
 
bool QuerySourceByScanFolderID (AZ::s64 scanFolderID, sourceHandler handler)
 
bool QuerySourceByJobID (AZ::s64 jobID, sourceHandler handler)
 
bool QuerySourceByProductID (AZ::s64 productID, sourceHandler handler)
 
bool QuerySourceBySourceGuid (AZ::Uuid sourceGuid, sourceHandler handler)
 
bool QuerySourceBySourceName (const char *exactSourceName, sourceHandler handler)
 
bool QuerySourceBySourceNameScanFolderID (const char *exactSourceName, AZ::s64 scanFolderID, sourceHandler handler)
 
bool QuerySourceLikeSourceName (const char *likeSourceName, LikeType likeType, sourceHandler handler)
 
bool QuerySourceLikeSourceNameScanFolderID (const char *likeSourceName, AZ::s64 scanFolderID, LikeType likeType, sourceHandler handler)
 
bool QuerySourceAnalysisFingerprint (const char *exactSourceName, AZ::s64 scanFolderID, AZStd::string &result)
 
bool QuerySourceAndScanfolder (combinedSourceScanFolderHandler handler)
 
bool QueryJobByJobID (AZ::s64 jobID, jobHandler handler)
 
bool QueryJobByJobKey (AZStd::string jobKey, jobHandler handler)
 
bool QueryJobByJobRunKey (AZ::u64 jobRunKey, jobHandler handler)
 
bool QueryJobByProductID (AZ::s64 productID, jobHandler handler)
 
bool QueryJobBySourceID (AZ::s64 sourceID, jobHandler handler, AZ::Uuid builderGuid=AZ::Uuid::CreateNull(), const char *jobKey=nullptr, const char *platform=nullptr, AssetSystem::JobStatus status=AssetSystem::JobStatus::Any)
 
bool QueryJobsByFailureCauseSourceID (AZ::s64 sourceID, jobHandler handler)
 
bool QueryProductByProductID (AZ::s64 productID, productHandler handler)
 
bool QueryProductByJobID (AZ::s64 jobID, productHandler handler, AZ::Uuid builderGuid=AZ::Uuid::CreateNull(), const char *jobKey=nullptr, const char *platform=nullptr, AssetSystem::JobStatus status=AssetSystem::JobStatus::Any)
 
bool QueryProductBySourceID (AZ::s64 sourceID, productHandler handler, AZ::Uuid builderGuid=AZ::Uuid::CreateNull(), const char *jobKey=nullptr, const char *platform=nullptr, AssetSystem::JobStatus status=AssetSystem::JobStatus::Any)
 
bool QueryProductBySourceGuidSubID (AZ::Uuid sourceGuid, AZ::u32 productSubID, productHandler handler)
 
bool QueryProductByProductName (const char *exactProductName, productHandler handler, AZ::Uuid builderGuid=AZ::Uuid::CreateNull(), const char *jobKey=nullptr, const char *platform=nullptr, AssetSystem::JobStatus status=AssetSystem::JobStatus::Any)
 
bool QueryProductLikeProductName (const char *likeProductName, LikeType likeType, productHandler handler, AZ::Uuid builderGuid=AZ::Uuid::CreateNull(), const char *jobKey=nullptr, const char *platform=nullptr, AssetSystem::JobStatus status=AssetSystem::JobStatus::Any)
 
bool QueryProductBySourceName (const char *exactSourceName, productHandler handler, AZ::Uuid builderGuid=AZ::Uuid::CreateNull(), const char *jobKey=nullptr, const char *platform=nullptr, AssetSystem::JobStatus status=AssetSystem::JobStatus::Any)
 
bool QueryProductBySourceNameScanFolderID (const char *exactSourceName, AZ::s64 scanFolderID, productHandler handler, AZ::Uuid builderGuid=AZ::Uuid::CreateNull(), const char *jobKey=nullptr, const char *platform=nullptr, AssetSystem::JobStatus status=AssetSystem::JobStatus::Any)
 
bool QueryProductLikeSourceName (const char *likeSourceName, LikeType likeType, productHandler handler, AZ::Uuid builderGuid=AZ::Uuid::CreateNull(), const char *jobKey=nullptr, const char *platform=nullptr, AssetSystem::JobStatus status=AssetSystem::JobStatus::Any)
 
bool QueryProductByJobIDSubID (AZ::s64 jobID, AZ::u32 subId, productHandler handler)
 
bool QueryLegacySubIdsByProductID (AZ::s64 productId, legacySubIDsHandler handler)
 
bool QueryCombined (combinedHandler handler, AZ::Uuid builderGuid=AZ::Uuid::CreateNull(), const char *jobKey=nullptr, const char *platform=nullptr, AssetSystem::JobStatus status=AssetSystem::JobStatus::Any, bool includeLegacySubIDs=false)
 
bool QueryCombinedBySourceID (AZ::s64 sourceID, combinedHandler handler, AZ::Uuid builderGuid=AZ::Uuid::CreateNull(), const char *jobKey=nullptr, const char *platform=nullptr, AssetSystem::JobStatus status=AssetSystem::JobStatus::Any)
 
bool QueryCombinedByJobID (AZ::s64 jobID, combinedHandler handler, AZ::Uuid builderGuid=AZ::Uuid::CreateNull(), const char *jobKey=nullptr, const char *platform=nullptr, AssetSystem::JobStatus status=AssetSystem::JobStatus::Any)
 
bool QueryCombinedByProductID (AZ::s64 productID, combinedHandler handler, AZ::Uuid builderGuid=AZ::Uuid::CreateNull(), const char *jobKey=nullptr, const char *platform=nullptr, AssetSystem::JobStatus status=AssetSystem::JobStatus::Any)
 
bool QueryCombinedBySourceGuidProductSubId (AZ::Uuid sourceGuid, AZ::u32 productSubID, combinedHandler handler, AZ::Uuid builderGuid=AZ::Uuid::CreateNull(), const char *jobKey=nullptr, const char *platform=nullptr, AssetSystem::JobStatus status=AssetSystem::JobStatus::Any)
 
bool QueryCombinedBySourceName (const char *exactSourceName, combinedHandler handler, AZ::Uuid builderGuid=AZ::Uuid::CreateNull(), const char *jobKey=nullptr, const char *platform=nullptr, AssetSystem::JobStatus status=AssetSystem::JobStatus::Any)
 
bool QueryCombinedLikeSourceName (const char *likeSourceName, LikeType likeType, combinedHandler handler, AZ::Uuid builderGuid=AZ::Uuid::CreateNull(), const char *jobKey=nullptr, const char *platform=nullptr, AssetSystem::JobStatus status=AssetSystem::JobStatus::Any)
 
bool QueryCombinedByProductName (const char *productName, combinedHandler handler, AZ::Uuid builderGuid=AZ::Uuid::CreateNull(), const char *jobKey=nullptr, const char *platform=nullptr, AssetSystem::JobStatus status=AssetSystem::JobStatus::Any)
 
bool QueryCombinedLikeProductName (const char *productName, LikeType likeType, combinedHandler handler, AZ::Uuid builderGuid=AZ::Uuid::CreateNull(), const char *jobKey=nullptr, const char *platform=nullptr, AssetSystem::JobStatus status=AssetSystem::JobStatus::Any)
 
bool QueryJobInfoByJobID (AZ::s64 jobID, jobInfoHandler handler)
 
bool QueryJobInfoByJobRunKey (AZ::u64 jobRunKey, jobInfoHandler handler)
 
bool QueryJobInfoByJobKey (AZStd::string jobKey, jobInfoHandler handler)
 
bool QueryJobInfoBySourceNameScanFolderId (const char *sourceName, AZ::s64 scanfolderId, jobInfoHandler handler, AZ::Uuid builderGuid=AZ::Uuid::CreateNull(), const char *jobKey=nullptr, const char *platform=nullptr, AssetSystem::JobStatus status=AssetSystem::JobStatus::Any)
 
bool QuerySourceDependencies (sourceFileDependencyHandler handler)
 Query all source dependencies.
 
bool QuerySourceDependencyBySourceDependencyId (AZ::s64 sourceDependencyID, sourceFileDependencyHandler handler)
 direct query - look up table row by row ID
 
bool QuerySourceDependencyByDependsOnSource (AZ::Uuid sourceGuid, const char *sourceName, const char *scanFolderPath, AzToolsFramework::AssetDatabase::SourceFileDependencyEntry::TypeOfDependency dependencyType, sourceFileDependencyHandler handler)
 
bool QuerySourceDependencyByDependsOnSourceWildcard (AZ::Uuid sourceGuid, const char *sourceName, const char *absolutePath, sourceFileDependencyHandler handler)
 
bool QueryDependsOnSourceBySourceDependency (AZ::Uuid sourceGuid, AzToolsFramework::AssetDatabase::SourceFileDependencyEntry::TypeOfDependency dependencyType, sourceFileDependencyHandler handler)
 
bool QueryProductDependenciesThatDependOnProductBySourceId (AZ::s64 sourceId, productDependencyHandler handler)
 
bool QueryProductDependencyByProductDependencyId (AZ::s64 productDependencyID, productDependencyHandler handler)
 
bool QueryProductDependencyByProductId (AZ::s64 productID, productDependencyHandler handler)
 
bool QueryProductDependencyBySourceGuidSubId (AZ::Uuid guid, AZ::u32 subId, const AZStd::string &platform, productDependencyHandler handler)
 
bool QueryDirectProductDependencies (AZ::s64 productID, productHandler handler)
 
bool QueryDirectReverseProductDependenciesBySourceGuidSubId (AZ::Uuid dependencySourceGuid, AZ::u32 dependencySubId, productHandler handler)
 
bool QueryDirectReverseProductDependenciesBySourceGuidAllPlatforms (AZ::Uuid dependencySourceGuid, productDependencyHandler handler)
 
bool QueryAllProductDependencies (AZ::s64 productID, productHandler handler)
 
bool QueryUnresolvedProductDependencies (productDependencyHandler handler)
 
bool QueryProductDependencyExclusions (productDependencyHandler handler)
 
bool QueryProductDependenciesUnresolvedAdvanced (const AZStd::vector< AZStd::string > &searchPaths, productDependencyAndPathHandler handler)
 
bool QueryMissingProductDependencyByProductId (AZ::s64 productId, missingProductDependencyHandler handler)
 
bool DeleteMissingProductDependencyByProductId (AZ::s64 productId)
 
bool QueryMissingProductDependencyByMissingProductDependencyId (AZ::s64 productDependencyId, missingProductDependencyHandler handler)
 
bool QueryFileByFileID (AZ::s64 fileID, fileHandler handler)
 
bool QueryFilesByFileNameAndScanFolderID (const char *fileName, AZ::s64 scanfolderID, fileHandler handler)
 
bool QueryFilesLikeFileNameAndScanFolderID (const char *likeFileName, LikeType likeType, AZ::s64 scanfolderID, fileHandler handler)
 
bool QueryFilesByScanFolderID (AZ::s64 scanFolderID, fileHandler handler)
 
bool QueryFileByFileNameScanFolderID (const char *fileName, AZ::s64 scanFolderID, fileHandler handler)
 
bool QueryStatByStatName (const char *statName, statHandler handler)
 
bool QueryStatLikeStatName (const char *statName, statHandler handler)
 
void SetQueryLogging (bool enableLogging)
 
void LogQuery (const char *statement, const AZStd::string &params) override
 
void LogResultId (AZ::s64 rowId) override
 

Protected Member Functions

virtual void CreateStatements ()
 
virtual AZStd::string GetAssetDatabaseFilePath ()
 
bool ValidateDatabaseTable (const char *callName, const char *tableName)
 
auto GetCombinedResultAsLambda ()
 
bool GetCombinedResult (const char *callName, SQLite::Statement *statement, AssetDatabaseConnection::combinedHandler handler, AZ::Uuid builderGuid=AZ::Uuid::CreateNull(), const char *jobKey=nullptr, AssetSystem::JobStatus status=AssetSystem::JobStatus::Any, bool includeLegacyAssetIDs=false)
 

Protected Attributes

SQLite::Connectionm_databaseConnection
 
AZStd::unordered_set< AZStd::string > m_validatedTables
 

Detailed Description

The Connection class represents a read-only connection to the asset database specifically (as opposed to a sql connection). Things like the Asset Processor derive from this in order to provide read-write access and curate the database. You may have as many of these connections as you wish, each represents a single connection to the asset database for use by a specific thread. All general read only queries are added here. Since this is meant for tools, we only care about queries which return data here, no modifications allowed here. Currently the Asset Processor is the only program allowed to modify the database. As such it derives from this class and overrides ReadOnly to return false which allows it to write / curate the database. However most systems only need to read and be notified of changes, so when they derive they don't override anything but CreateStatements to add specific queries that only make sense for their specific purpose, otherwise that statement should be added to this class so it can be reused by any system that needs it. Note that if a system needs read only access and has no special query needs, then this class can be used directly.

Member Function Documentation

◆ QueryDependsOnSourceBySourceDependency()

bool AzToolsFramework::AssetDatabase::AssetDatabaseConnection::QueryDependsOnSourceBySourceDependency ( AZ::Uuid  sourceGuid,
AzToolsFramework::AssetDatabase::SourceFileDependencyEntry::TypeOfDependency  dependencyType,
sourceFileDependencyHandler  handler 
)

Query everything 'sourceDependency' depends on. Optional nullable 'dependentFilter' filters it to only resulting dependencies which are LIKE the filter.

◆ QueryDirectReverseProductDependenciesBySourceGuidSubId()

bool AzToolsFramework::AssetDatabase::AssetDatabaseConnection::QueryDirectReverseProductDependenciesBySourceGuidSubId ( AZ::Uuid  dependencySourceGuid,
AZ::u32  dependencySubId,
productHandler  handler 
)

Query products which depend on the product with "dependencySubId" and whose source file has "dependencySourceGuid") These finds all incoming dependencies: everything that depends on the given asset. Similar to QueryDirectProductDependencies, this query deals with product dependencies but retrieves rows from Products, not ProductDependencies.

◆ QueryProductDependenciesUnresolvedAdvanced()

bool AzToolsFramework::AssetDatabase::AssetDatabaseConnection::QueryProductDependenciesUnresolvedAdvanced ( const AZStd::vector< AZStd::string > &  searchPaths,
productDependencyAndPathHandler  handler 
)

Returns any unresolved dependencies which match (by exact or wildcard match) the input searchPaths The extra path returned for each row is the searchPath entry that was matched with the returned dependency entry

Parameters
searchPathsvector of relative paths to search for matches

◆ QuerySourceDependencyByDependsOnSource()

bool AzToolsFramework::AssetDatabase::AssetDatabaseConnection::QuerySourceDependencyByDependsOnSource ( AZ::Uuid  sourceGuid,
const char *  sourceName,
const char *  scanFolderPath,
AzToolsFramework::AssetDatabase::SourceFileDependencyEntry::TypeOfDependency  dependencyType,
sourceFileDependencyHandler  handler 
)

Query sources which depend on 'dependsOnSource' Reverse dependencies are incoming dependencies: what assets depend on me?

◆ QuerySourceDependencyByDependsOnSourceWildcard()

bool AzToolsFramework::AssetDatabase::AssetDatabaseConnection::QuerySourceDependencyByDependsOnSourceWildcard ( AZ::Uuid  sourceGuid,
const char *  sourceName,
const char *  absolutePath,
sourceFileDependencyHandler  handler 
)

Attempt to match either DEP_SourcetoSource or DEP_JobToJob Then allow DEP_SourceLikeMatch with Wildcard characters


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