|
Vulkan Schnee 0.0.1
High-performance rendering engine
|
A manager which is used to look up existing assets and their loading state. More...
#include <Asset.h>
Public Member Functions | |
| AssetManager ()=default | |
| virtual | ~AssetManager ()=default |
| template<typename... Args> | |
| void | declare (Key path, Args &&... args) |
| Adds an asset to the list in its unloaded state. | |
| void | add (Key path, AssetClass *asset) |
| Adds or overwrites a previously declared asset at a key. | |
| bool | exists (Key path) |
| Checks if an asset already exists. This means it is declared and there is content. | |
| bool | isDeclared (Key path) |
| Checks if an asset has been declared. If it exists it is also declared. | |
| CpuLoadingState | getAssetLoadingState (const Key &path) |
| Gets a loading state for an asset. If the asset is not yet declared it will return that it is UNLOADED. | |
| std::optional< AssetClass * > | getAsset (const Key &path) |
| Try's to get an asset. If the asset does not exist (can be checked with exists) it will return a std::nullopt. | |
| virtual void | clear () |
| Clears out all resources. | |
| template<typename Func> | |
| void | forEachAsset (Func &&func) const |
| Iterates over all assets and calls the provided callback for each. | |
Private Attributes | |
| std::unordered_map< Key, AssetClass * > | assets |
A manager which is used to look up existing assets and their loading state.
| Key | The type of the assets key with which to access the data. This is most often the path to the asset on disc |
| AssetClass | The asset class which is a derivative of Asset::AssetBase. |
|
default |
|
virtualdefault |
| void Asset::AssetManager< Key, AssetClass >::add | ( | Key | path, |
| AssetClass * | asset ) |
Adds or overwrites a previously declared asset at a key.
| path | The key with which to access the asset |
| asset | The asset to manage |
Definition at line 241 of file Asset.h.
References assets, and TRACY_ZONE_SCOPED_NAMED.
|
virtual |
Clears out all resources.
Definition at line 273 of file Asset.h.
References assets, and TRACY_ZONE_SCOPED_NAMED.
| void Asset::AssetManager< Key, AssetClass >::declare | ( | Key | path, |
| Args &&... | args ) |
Adds an asset to the list in its unloaded state.
| Args | arguments to feed the empty assets constructor at the location |
| path | location to create the asset at in the asset manager |
| args | arguments for the asset constructor |
Definition at line 236 of file Asset.h.
References assets.
| bool Asset::AssetManager< Key, AssetClass >::exists | ( | Key | path | ) |
|
inline |
Iterates over all assets and calls the provided callback for each.
| Func | Callable type that accepts (const Key&, AssetClass*) |
| func | The callback to invoke for each asset |
Definition at line 222 of file Asset.h.
References assets.
Referenced by EngineCore::RenderingDataManager::uploadMaterialBuffers().
| std::optional< AssetClass * > Asset::AssetManager< Key, AssetClass >::getAsset | ( | const Key & | path | ) |
Try's to get an asset. If the asset does not exist (can be checked with exists) it will return a std::nullopt.
| path | The asset to get |
Definition at line 266 of file Asset.h.
References assets, and TRACY_ZONE_SCOPED_NAMED.
Referenced by EngineCore::RenderingDataManager::collectMaterialsFromScene(), EngineCore::RenderingDataManager::processCompletedMeshletGenerations(), EngineCore::RenderingDataManager::updatePrimitiveData(), and EngineCore::RenderingDataManager::updatePrimitiveDataInstanced().
| CpuLoadingState Asset::AssetManager< Key, AssetClass >::getAssetLoadingState | ( | const Key & | path | ) |
Gets a loading state for an asset. If the asset is not yet declared it will return that it is UNLOADED.
| path | which asset to get the loading state for |
Definition at line 259 of file Asset.h.
References assets, Asset::LOADING, and Asset::UNLOADED.
| bool Asset::AssetManager< Key, AssetClass >::isDeclared | ( | Key | path | ) |
|
private |
Definition at line 231 of file Asset.h.
Referenced by add(), clear(), declare(), exists(), forEachAsset(), getAsset(), getAssetLoadingState(), and isDeclared().