An asset representing remote asset catalogs.
This class represents a catalog of assets hosted remotely. It can download an asset manifest and undecoded asset data, and decode asset data belonging to this catalog.
An asset manifest can be downloaded by calling DownloadManifest or DownloadManifestAndAssets.
Assets to download must be added to the download list prior to being downloaded using AddAssetToDownloadList. The assets names to add to the download list must be known to the user for the appropriate manifest that is downloaded. These assets can then be downloaded by calling DownloadAssets or DownloadManifestAndAssets. While downloading assets that have dependecies on other files, their dependencies will be added to the download list and downloaded.
When download has completed assets can be decoded by calling GetAsset.
#include <asset/YiRemoteAssetCatalog.h>

Public Types | |
| enum | FAILURE_TYPE { INVALID_URL, NETWORK_ERROR, INVALID_ASSET, INVALID_MANIFEST } |
Public Types inherited from CYIAsset | |
| enum | PATH_TYPE { PATH_ABSOLUTE = 0, PATH_RELATIVE } |
Public Member Functions | |
| virtual | ~CYIRemoteAssetCatalog () |
| const CYIUrl & | GetUrl () const |
| uint64_t | GetCatalogID () const |
| CYIString | GetAbsoluteCatalogUrlForAsset (const CYIString &assetName) const |
| CYIString | GetRelativeCatalogUrlForAsset (const CYIString &assetName) const |
| void | DownloadManifest (const CYIUrl &url) |
| void | DownloadAssets () |
| void | DownloadManifestAndAssets (const CYIUrl &url) |
| void | CancelDownload () |
| virtual std::pair< uint32_t, uint32_t > | GetApproximateSize () const override |
| bool | AddAssetToDownloadList (const CYIString &assetName, const CYIRuntimeTypeInfo &assetTypeInfo) |
| void | RemoveAssetFromDownloadList (const CYIString &assetName) |
| std::shared_ptr< CYIAsset > | GetAsset (const CYIString &assetName) const |
| void | ClearData () |
| std::vector< CYIString > | GetAssetList () const |
| const CYIAssetManifest & | GetAssetManifest () const |
| bool | IsManifestDownloaded () const |
| bool | IsAssetInDownloadList (const CYIString &assetName) const |
Public Member Functions inherited from CYIAsset | |
| virtual | ~CYIAsset () |
| const CYIString & | GetPath () const |
| CYIAssetLoadParams * | GetLoadParameters () const |
| bool | SetName (const CYIString &name) |
| const CYIString & | GetName () const |
| bool | Load () |
| void | Unload () |
| bool | IsLoaded () const |
| bool | Equals (const std::shared_ptr< CYIAsset > &pAsset) |
| virtual bool | Prepare () |
Public Member Functions inherited from CYIScriptableRTTIObject | |
| CYIScriptableRTTIObject () | |
| virtual | ~CYIScriptableRTTIObject () |
| virtual const CYIRuntimeTypeInfo * | GetRuntimeTypeInfoForScriptObject () const override |
Public Member Functions inherited from CYIScriptableObject | |
| CYIScriptableObject () | |
| CYIScriptableObject (const CYIScriptableObject &other) | |
| CYIScriptableObject & | operator= (const CYIScriptableObject &other) |
| virtual | ~CYIScriptableObject () |
| CYIBindingImplementation * | GetBindingImplementation () const |
| void | SetBindingImplementation (CYIBindingImplementation *pBindingImplementation) |
Public Member Functions inherited from CYISignalHandler | |
| CYISignalHandler () | |
| CYISignalHandler (const CYISignalHandler &rSignalHandler) | |
| virtual | ~CYISignalHandler () |
| CYISignalHandler & | operator= (const CYISignalHandler &rSignalHandler) |
| void | MoveToThread (CYIThread *pThread) |
| This function allows the user to override the default thread affinity to any CYIThread that may or may not be running. More... | |
| CYIThreadHandle | GetThreadAffinity () const |
| void | SetThreadAffinity (const CYIThreadHandle &rThreadAffinity) |
| virtual bool | IsConnected () const |
| virtual bool | IsConnected (const CYISignalBase &rSignal) const |
| void | Disconnect (CYISignalBase &rSignal) |
| void | DisconnectFromAllSignals () |
Public Member Functions inherited from CYIThread::Listener | |
| Listener () | |
| virtual | ~Listener () |
| virtual void | OnThreadStarted (CYIThread *) |
| virtual void | OnThreadTerminated (CYIThread *) |
| virtual void | OnThreadFinished (CYIThread *) |
Static Public Member Functions | |
| static std::shared_ptr< CYIRemoteAssetCatalog > | Create (const CYIString &name) |
Public Attributes | |
| CYISignal< const CYIUrl & > | AssetDownloadCompleted |
| CYISignal< const CYIUrl &, const FAILURE_TYPE, const CYIUrl & > | AssetDownloadFailed |
| CYISignal< const CYIUrl &, const FAILURE_TYPE > | ManifestDownloadFailed |
| CYISignal< const CYIUrl & > | DownloadCancelled |
| CYISignal< const CYIUrl & > | ManifestDownloadCompleted |
Protected Member Functions | |
| CYIRemoteAssetCatalog (const CYIString &name) | |
| const std::vector< uint8_t > & | GetData (const CYIString &assetName) const |
| void | OnManifestDownloadCompleted (const std::shared_ptr< CYIHTTPRequest > &pRequest, const std::shared_ptr< CYIHTTPResponse > &pResponse, bool bCachedResponse) |
| void | OnManifestDownloadFailed (const std::shared_ptr< CYIHTTPRequest > &pRequest, const HTTP_STATUS_CODE statusCode, const CYIString &errorMessage) |
| void | OnAssetDownloadCompleted (const CYIUrl &url) |
| void | OnAssetDownloadFailed (CYIRemoteAssetDownloadHelper::FAILURE_TYPE eFailureType, const CYIUrl &url) |
| std::shared_ptr< CYIAsset > | DecodeAsset (const CYIString &path, CYIAssetLoadParams *pLoadParams=nullptr) const |
| CYIUrl | GetAssetDownloadURL (const CYIString &assetName, const CYIRuntimeTypeInfo &typeInfo) const |
| bool | QueueTemplateDependenciesForDownload (const CYIString &assetName) |
Protected Member Functions inherited from CYIAsset | |
| CYIAsset () | |
| ssize_t | GetID () const |
| void | SetPath (const CYIString &path, PATH_TYPE ePathType) |
| void | SetApproximateSize (uint32_t nSize) |
| void | SetLoaded (bool bAssetLoaded) |
| void | SetLoadParameters (std::unique_ptr< CYIAssetLoadParams > pParams) |
| virtual void | OnLoad () |
| virtual void | OnUnload () |
Protected Member Functions inherited from CYIScriptableRTTIObject | |
| virtual std::pair< const CYIRuntimeTypeInfo *, const void * > | GetRuntimeTypeInfoWithObject () const =0 |
Friends | |
| class | CYIAssetLoader |
Additional Inherited Members | |
Static Protected Attributes inherited from CYIAsset | |
| static ssize_t | INVALID_ID |
The types of failures that may occur in downloading, parsing, or decoding a manifest and its assets.
|
virtual |
|
protected |
Constructs a CYIRemoteAssetCatalog initialized with name so that it can be retrieved later or shared with other objects.
| bool CYIRemoteAssetCatalog::AddAssetToDownloadList | ( | const CYIString & | assetName, |
| const CYIRuntimeTypeInfo & | assetTypeInfo | ||
| ) |
Adds an asset named assetName and with the type assetTypeInfo to the list of assets to download. Returns false when the assetName is empty, or when the asset is already added to the download list.
| void CYIRemoteAssetCatalog::CancelDownload | ( | ) |
Cancels the download of the manifest associated with this catalog and cancels the downloads of all assets.
| void CYIRemoteAssetCatalog::ClearData | ( | ) |
Clears all of the downloaded undecoded data held by this catalog and the manifest. It will also remove all asset names from the download list.
|
static |
Returns a new instance of CYIRemoteAssetCatalog initialized with name.
|
protected |
Decodes an asset from the catalog with the given path, adds it to the CYIAssetManager, and returns it.
| void CYIRemoteAssetCatalog::DownloadAssets | ( | ) |
Downloads the undecoded asset data of the named assets specified by calling AddAssetToDownloadList. This function will emit either AssetDownloadCompleted on success or AssetDownloadFailed on failure.
| void CYIRemoteAssetCatalog::DownloadManifest | ( | const CYIUrl & | url | ) |
Sets the URL of the manifest associated with this catalog to url and downloads it. This function will emit either ManifestDownloadCompleted on success or ManifestDownloadFailed on failure.
| void CYIRemoteAssetCatalog::DownloadManifestAndAssets | ( | const CYIUrl & | url | ) |
Sets the URL of the manifest associated with this catalog to url, downloads it, and then downloads the assets specified by calling AddAssetToDownloadList.
Returns the absolute path to the asset with name assetName. The catalog url for an absolute path will be in the following format: (catalog://[ID]:abs/path/assetName).
|
overridevirtual |
Calculates and returns the approximate number of bytes currently used by this asset. The first item of the returned pair object represents the memory currently taken in the CPU main memory, and the second item of the returned pair object represents the memory currently taken in the GPU memory.
Reimplemented from CYIAsset.
Decodes and returns an asset from the catalog with the given asset name, assetName.
|
protected |
Get the full download url for the given asset.
| std::vector<CYIString> CYIRemoteAssetCatalog::GetAssetList | ( | ) | const |
Returns a list of asset names for the assets specified by calling AddAssetToDownloadList.
| const CYIAssetManifest& CYIRemoteAssetCatalog::GetAssetManifest | ( | ) | const |
Returns the asset manifest contained in this catalog.
| uint64_t CYIRemoteAssetCatalog::GetCatalogID | ( | ) | const |
Returns the ID of the catalog. The ID is generated and unique.
|
protected |
Returns the undecoded, downloaded data for the asset added to this catalog with the name assetName. If the asset is not found or has not finished downloading it will return an empty vector.
Returns the relative path to the asset with name assetName. The catalog url for an relative path will be in the following format: (catalog://[ID]:rel/assetName).
| const CYIUrl& CYIRemoteAssetCatalog::GetUrl | ( | ) | const |
Returns the URL of the manifest associated with this catalog.
| bool CYIRemoteAssetCatalog::IsAssetInDownloadList | ( | const CYIString & | assetName | ) | const |
Returns true if the asset with name assetName is in the list of assets to download.
| bool CYIRemoteAssetCatalog::IsManifestDownloaded | ( | ) | const |
Returns true if the manifest download completed successfully.
|
protected |
Called when the asset with url has finished downloading.
|
protected |
Called when the asset with url has failed downloading.
|
protected |
Called when the catalog manifest download is complete to parse the manifest.
|
protected |
Called when the catalog manifest download has failed.
|
protected |
Queues all of the dependencies for an asset from the catalog with the given assetName for download. Returns true if dependencies were added to the download list to download; false if there were no dependencies or all of the dependencies have already been added to the download list.
| void CYIRemoteAssetCatalog::RemoveAssetFromDownloadList | ( | const CYIString & | assetName | ) |
Removes an asset with the name assetName from the list of assets to download.
|
friend |
Emitted when the download of the assets has finished and provides the URL of the completed manifest download.
| CYISignal<const CYIUrl & , const FAILURE_TYPE, const CYIUrl & > CYIRemoteAssetCatalog::AssetDownloadFailed |
Emitted when the download of the assets has failed and provides the URL of the manifest, the URL of the asset, and the failure reason.
Emitted when the manifest download or asset download has been cancelled and provides the URL of the manifest.
Emitted when the catalog download has completed and provides the URL of the completed manifest download.
| CYISignal<const CYIUrl &, const FAILURE_TYPE> CYIRemoteAssetCatalog::ManifestDownloadFailed |
Emitted when the download has failed and provides the URL of the failed manifest download with the failure reason.