The asset loader provides an interface for loading asset objects, which in turn wrap resource objects like bitmaps, shaders, etc.
Asset objects are produced by decoding specific files though the CYIAssetDecoder interface. The asset loader can have multiple decoders registered, depending on the number of file format types your application needs to support.
Assets can be loaded synchronously or asynchronously depending on the needs of the application.
In order to help manage the large variety of asset types needed by some applications, the asset loader should be supplied with an asset location via an CYIAssetLocator object. The asset locator will provide the asset loader with a a base directory and specialized paths for specific asset types.
#include <asset/YiAssetLoader.h>

Classes | |
| class | DecodeListener |
| Listener interface for asynchronously decoded asset objects. More... | |
Public Member Functions | |
| CYIAssetLoader () | |
| virtual | ~CYIAssetLoader () |
| void | AddDecoder (std::unique_ptr< CYIAssetDecoder > pDecoder) |
| std::unique_ptr< CYIAssetDecoder > | RemoveDecoder (const CYIAssetDecoder *pDecoder) |
| uint32_t | GetDecoderCount () |
| std::shared_ptr< CYIAsset > | Load (const CYIRuntimeTypeInfo &assetType, const CYIString &filename, CYIAssetLoadParams *pLoadParams=nullptr) |
| std::shared_ptr< CYIAsset > | LoadFromPath (const CYIRuntimeTypeInfo &assetType, const CYIString &path, CYIAssetLoadParams *pLoadParams=nullptr) |
| std::shared_ptr< CYIAsset > | LoadFromPath (const CYIString &path, CYIAssetLoadParams *pLoadParams=nullptr) |
| bool | LoadFromPath (const std::shared_ptr< CYIAsset > &pAsset) |
| std::shared_ptr< CYIAsset > | Load (const CYIRuntimeTypeInfo &assetType, const uint8_t *pData, uint32_t nDataSize, CYIAssetLoadParams *pLoadParams=nullptr) |
| int32_t | LoadAsync (const CYIRuntimeTypeInfo &assetType, const CYIString &filename, CYIAssetLoadParams *pLoadParams, DecodeListener *pListener, void *pListenerPrivate) |
| int32_t | LoadAsyncFromPath (const CYIRuntimeTypeInfo &assetType, const CYIString &path, CYIAssetLoadParams *pLoadParams, DecodeListener *pListener, void *pListenerPrivate) |
| int32_t | LoadAsyncFromPath (const CYIString &path, CYIAssetLoadParams *pLoadParams, DecodeListener *pListener, void *pListenerPrivate) |
| int32_t | LoadAsync (const CYIRuntimeTypeInfo &assetType, const uint8_t *pData, uint32_t nDataSize, CYIAssetLoadParams *pLoadParams, DecodeListener *pListener, void *pListenerPrivate) |
| void | AbortAsyncLoad (int32_t nDecodeTaskID) |
| uint32_t | GetAsyncJobsCount () |
| CYIString | ProbeExtension (const CYIRuntimeTypeInfo &assetType, const uint8_t *pData, uint32_t nDataSize) const |
| CYIString | ProbeExtension (const uint8_t *pData, uint32_t nDataSize) const |
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 *) |
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) |
| virtual const CYIRuntimeTypeInfo * | GetRuntimeTypeInfoForScriptObject () const |
Static Public Member Functions | |
| static void | SetAssetLocator (const CYIAssetLocator &rLocator) |
| static const CYIAssetLocator & | GetAssetLocator () |
Friends | |
| class | CYIDecoderThread |
| CYIAssetLoader::CYIAssetLoader | ( | ) |
Creates an asset loader with no associated decoders.
|
virtual |
Destroys the asset loader and all the associated decoders.
| void CYIAssetLoader::AbortAsyncLoad | ( | int32_t | nDecodeTaskID | ) |
Aborts the specified asynchronous asset decoding task. This method will try to synchronously abort the decoding task and guarantees that the listener won't be called for this decoding task.
| void CYIAssetLoader::AddDecoder | ( | std::unique_ptr< CYIAssetDecoder > | pDecoder | ) |
Adds an asset decoder to the asset loader ahead of any existing decoders.
|
static |
Returns the default asset root locator.
| uint32_t CYIAssetLoader::GetAsyncJobsCount | ( | ) |
Returns the current number of uncompleted asynchronous decoding jobs
| uint32_t CYIAssetLoader::GetDecoderCount | ( | ) |
Returns the number of decoders currently registered.
| std::shared_ptr<CYIAsset> CYIAssetLoader::Load | ( | const CYIRuntimeTypeInfo & | assetType, |
| const CYIString & | filename, | ||
| CYIAssetLoadParams * | pLoadParams = nullptr |
||
| ) |
Loads an asset of the specified assetType which is named by filename. Any additional parameters required by the asset decoded should be supplied through the specialized CYIAssetLoadParams type.
filename will be located using the system root locator.
| std::shared_ptr<CYIAsset> CYIAssetLoader::Load | ( | const CYIRuntimeTypeInfo & | assetType, |
| const uint8_t * | pData, | ||
| uint32_t | nDataSize, | ||
| CYIAssetLoadParams * | pLoadParams = nullptr |
||
| ) |
Loads an asset of the specified assetType, the contents of which are contains in pData. Any additional parameters required by the asset decoded should be supplied through the specialized CYIAssetLoadParams type.
| int32_t CYIAssetLoader::LoadAsync | ( | const CYIRuntimeTypeInfo & | assetType, |
| const CYIString & | filename, | ||
| CYIAssetLoadParams * | pLoadParams, | ||
| DecodeListener * | pListener, | ||
| void * | pListenerPrivate | ||
| ) |
Asynchronously loads an asset of the specified assetType which named by filename. Any additional parameters required by the asset decoded should be supplied through the specialized CYIAssetLoadParams type. Once the asset has been loaded, the pListener object will be called back. Any private data needing to be passed back to the application through the DecodeListener interface should supply it through the pListenerPrivate pointer.
filename will be located using the system root locator.
The function will return a unique job identifier which can be used to cancel the loading task.
| int32_t CYIAssetLoader::LoadAsync | ( | const CYIRuntimeTypeInfo & | assetType, |
| const uint8_t * | pData, | ||
| uint32_t | nDataSize, | ||
| CYIAssetLoadParams * | pLoadParams, | ||
| DecodeListener * | pListener, | ||
| void * | pListenerPrivate | ||
| ) |
Asynchronously loads an asset of the specified assetType, the contents of which are contains in pData. Any additional parameters required by the asset decoded should be supplied through the specialized CYIAssetLoadParams type. Once the asset has been loaded, the pListener object will be called back. Any private data needing to be passed back to the application through the DecodeListener interface should supply it through the pListenerPrivate pointer.
The function will return a unique job identifier which can be used to cancel the loading task.
| int32_t CYIAssetLoader::LoadAsyncFromPath | ( | const CYIRuntimeTypeInfo & | assetType, |
| const CYIString & | path, | ||
| CYIAssetLoadParams * | pLoadParams, | ||
| DecodeListener * | pListener, | ||
| void * | pListenerPrivate | ||
| ) |
Asynchronously loads an asset of the specified assetType which is pointed to by path. Any additional parameters required by the asset decoded should be supplied through the specialized CYIAssetLoadParams type. Once the asset has been loaded, the pListener object will be called back. Any private data needing to be passed back to the application through the DecodeListener interface should supply it through the pListenerPrivate pointer.
The function will return a unique job identifier which can be used to cancel the loading task.
| int32_t CYIAssetLoader::LoadAsyncFromPath | ( | const CYIString & | path, |
| CYIAssetLoadParams * | pLoadParams, | ||
| DecodeListener * | pListener, | ||
| void * | pListenerPrivate | ||
| ) |
Asynchronously loads an asset which is pointed to by path. Any additional parameters required by the asset decoded should be supplied through the specialized CYIAssetLoadParams type. Once the asset has been loaded, the pListener object will be called back. Any private data needing to be passed back to the application through the DecodeListener interface should supply it through the pListenerPrivate pointer.
The function will return a unique job identifier which can be used to cancel the loading task.
| std::shared_ptr<CYIAsset> CYIAssetLoader::LoadFromPath | ( | const CYIRuntimeTypeInfo & | assetType, |
| const CYIString & | path, | ||
| CYIAssetLoadParams * | pLoadParams = nullptr |
||
| ) |
Loads an asset of the specified assetType which is pointed to by path. Any additional parameters required by the asset decoded should be supplied through the specialized CYIAssetLoadParams type.
| std::shared_ptr<CYIAsset> CYIAssetLoader::LoadFromPath | ( | const CYIString & | path, |
| CYIAssetLoadParams * | pLoadParams = nullptr |
||
| ) |
Loads an asset which is pointed to by path. Any additional parameters required by the asset decoder should be supplied through the specialized CYIAssetLoadParams type.
| bool CYIAssetLoader::LoadFromPath | ( | const std::shared_ptr< CYIAsset > & | pAsset | ) |
Loads and populates an existing asset which has a path set and optionally a load parameter required by the asset decoder. This function is called automaticaly when calling CYIAsset::Load
| CYIString CYIAssetLoader::ProbeExtension | ( | const CYIRuntimeTypeInfo & | assetType, |
| const uint8_t * | pData, | ||
| uint32_t | nDataSize | ||
| ) | const |
Examine the data, look for a compatible decoder then return the associate extension, or an empty string if one cannot be found.
| CYIString CYIAssetLoader::ProbeExtension | ( | const uint8_t * | pData, |
| uint32_t | nDataSize | ||
| ) | const |
Examine the data, look for a compatible decoder then return the associate extension, or an empty string if one cannot be found.
| std::unique_ptr<CYIAssetDecoder> CYIAssetLoader::RemoveDecoder | ( | const CYIAssetDecoder * | pDecoder | ) |
Removes an asset decoder from the asset loader.
|
static |
Sets the asset locator.
|
friend |