This class provides a cache that users can use to store various types of assets.
When an asset is retreived, smart pointers are used to handle memory usage. The asset will only be deleted if all references to it are removed - including the one held by this class.
Assets with the same file path are considered duplicates. Adding an asset with duplicate path will fail.
For some assets, like CYIAssetTexture for example, a hardware asset (or GPU object) may also be available and can be used with specific classes in You.i Engine.
#include <asset/YiAssetManager.h>
Public Member Functions | |
| CYIAssetManager () | |
| virtual | ~CYIAssetManager () |
| void | AddCacheStrategy (std::unique_ptr< CYIAssetCacheStrategy > pStrategy) |
| bool | AddAsset (const std::shared_ptr< CYIAsset > &pAsset) |
| void | ExecuteCacheStrategies () |
| void | DumpAssetList () const |
| std::vector< std::shared_ptr< CYIAsset > > | GetAssets () const |
| std::shared_ptr< CYIAsset > | GetAsset (const CYIString &name) |
| std::shared_ptr< CYIAsset > | GetAssetFromPath (const CYIString &path) |
| std::shared_ptr< CYIRemoteAssetCatalog > | GetRemoteAssetCatalog (uint64_t uCatalogID) const |
| std::vector< std::shared_ptr< CYIRemoteAssetCatalog > > | GetRemoteAssetCatalogs () const |
| void | InvalidateHardwareAssets () |
| void | LoadShaders () |
| void | RemoveAllAssets () |
| void | RemoveAsset (const std::shared_ptr< CYIAsset > &pAsset) |
| void | RemoveAssetsOfType (const CYIRuntimeTypeInfo &assetType) |
| std::unique_ptr< CYIAssetCacheStrategy > | RemoveCacheStrategy (const CYIAssetCacheStrategy *pStrategy) |
| void | RestoreHardwareAssets () |
| bool | IsSystemAsset (const std::shared_ptr< const CYIAsset > &pAsset) |
Friends | |
| class | CYIAsset |
| CYIAssetManager::CYIAssetManager | ( | ) |
|
virtual |
| bool CYIAssetManager::AddAsset | ( | const std::shared_ptr< CYIAsset > & | pAsset | ) |
Adds a shared asset pAsset to the asset manager and returns true if the asset was successfully added or the asset already exists in the asset manager (determined by ID or path).
Returns false if the asset is nullptr, cannot be prepared, or an asset with the same name (with different ID or path) already exists in the asset manager.
The asset provided will be populated with a unique ID.
| void CYIAssetManager::AddCacheStrategy | ( | std::unique_ptr< CYIAssetCacheStrategy > | pStrategy | ) |
Adds an asset cache strategy pStrategy for use by the asset manager. The caching strategy cannot be nullptr.
| void CYIAssetManager::DumpAssetList | ( | ) | const |
This method prints every asset currently being managed to the log.
| void CYIAssetManager::ExecuteCacheStrategies | ( | ) |
This methods allows clients to control when the cache strategy should be applied.
Returns a shared asset after supplying a unique name, which was supplied when the asset was built. It will return a null pointer if the name cannot be found, or if the asset has been released.
Returns the CYIAsset that is associated with a unique, fully-qualified path. Returns a null pointer if the asset path is not found.
| std::vector<std::shared_ptr<CYIAsset> > CYIAssetManager::GetAssets | ( | ) | const |
Returns a list of every asset currently being managed.
| std::shared_ptr<CYIRemoteAssetCatalog> CYIAssetManager::GetRemoteAssetCatalog | ( | uint64_t | uCatalogID | ) | const |
Returns the CYIRemoteAssetCatalog that is associated with the given ID. Returns a null pointer if the CYIRemoteAssetCatalog is not found.
| std::vector<std::shared_ptr<CYIRemoteAssetCatalog> > CYIAssetManager::GetRemoteAssetCatalogs | ( | ) | const |
Returns the collection of CYIRemoteAssetCatalog that exist in the asset manager.
| void CYIAssetManager::InvalidateHardwareAssets | ( | ) |
In the event that the hardware context is lost, this method can be called to invalidate the hardware resources, which will remove all registered hardware resources.
| bool CYIAssetManager::IsSystemAsset | ( | const std::shared_ptr< const CYIAsset > & | pAsset | ) |
Returns true if the provided asset is a system asset. A system asset is an asset instantiated and tracked by You.i Engine (rather than by the user's application).
| void CYIAssetManager::LoadShaders | ( | ) |
Load default shaders used by You.i Engine. Will either load a file from disk(consoles) or load the code directly.
| void CYIAssetManager::RemoveAllAssets | ( | ) |
Removes all assets currently being cached by the asset manager.
| void CYIAssetManager::RemoveAsset | ( | const std::shared_ptr< CYIAsset > & | pAsset | ) |
Removes a software asset from the cache.
| void CYIAssetManager::RemoveAssetsOfType | ( | const CYIRuntimeTypeInfo & | assetType | ) |
Removes all assets and any associated hardware resources which match the RTTI type provided.
| std::unique_ptr<CYIAssetCacheStrategy> CYIAssetManager::RemoveCacheStrategy | ( | const CYIAssetCacheStrategy * | pStrategy | ) |
Removes the asset cache strategy pStrategy in use by the asset manager. The caching strategy pStrategy cannot be nullptr.
| void CYIAssetManager::RestoreHardwareAssets | ( | ) |
In the event that the hardware context is restored, this method can be called to restore the hardware resources after they were invalidated using InvalidateHardwareAssets.
|
friend |
|
static |
Default texture, 2x2 checker board
|
static |
Default crosshair texture
|
static |
Geometry Batch 2D shader
|
static |
NanoVG 2D shader
|
static |
RGB -> BGR texture fragment shader
|
static |
Blurring effect Horizontal
|
static |
Blurring effect Vertical
|
static |
Effect flip copy shader
|
static |
Tint Effect shader
|
static |
Tint Effect with flip copy shader
|
static |
Texture fragment shader
|
static |
Solid color fragment shader
|
static |
Default text fragment shader
|
static |
Texture fragment shader, YUV colour space
|
static |
Texture fragment shader, YUV colour space with separate UV for chroma
|
static |
SDF text fragment shader
|
static |
SDF text fragment shader
|
static |
Solid vertex color fragment shader
|
static |
Normalized [0..1] quad vertices
|
static |
Y-flipped normalized [0..1] quad vertices
|
static |
Geometry Batch 2D shader
|
static |
NanoVG 2D shader
|
static |
RGB -> BGR texture shader program
|
static |
Blurring effect Horizontal
|
static |
Blurring effect Vertical
|
static |
Effect flip copy shader
|
static |
Tint Effect shader
|
static |
Tint Effect with flip copy shader
|
static |
Texture shader program
|
static |
Solid color shader program
|
static |
Default text shader program
|
static |
Texture shader program, YUV colour space
|
static |
Texture shader program, YUV colour space with separate UV for chroma
|
static |
SDF text shader program
|
static |
SDF text shader program
|
static |
Solid vertex color shader program
|
static |
Default small crosshair texture
|
static |
Text atlas indices
|
static |
Geometry Batch 2D shader
|
static |
NanoVG 2D shader
|
static |
Default vertex shader
|
static |
Blurring effect Horizontal
|
static |
Blurring effect Vertical
|
static |
Effect flip copy shader
|
static |
Tint Effect shader
|
static |
Tint Effect with flip copy shader
|
static |
Default text vertex shader
|
static |
Vertex shader, YUV colour space
|
static |
Vertex shader, YUV colour space with separate UV for chroma
|
static |
SDF text vertex shader
|
static |
SDF text vertex shader
|
static |
Solid vertex color shader