Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
Asset::AssetManager< Key, AssetClass > Class Template Reference

A manager which is used to look up existing assets and their loading state. More...

#include <Asset.h>

Collaboration diagram for Asset::AssetManager< Key, AssetClass >:

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

Detailed Description

template<typename Key, typename AssetClass>
class Asset::AssetManager< Key, AssetClass >

A manager which is used to look up existing assets and their loading state.

Template Parameters
KeyThe type of the assets key with which to access the data. This is most often the path to the asset on disc
AssetClassThe asset class which is a derivative of Asset::AssetBase.
Author
Konstantin Passig
Date
03.12.2025

Definition at line 141 of file Asset.h.

Constructor & Destructor Documentation

◆ AssetManager()

template<typename Key, typename AssetClass>
Asset::AssetManager< Key, AssetClass >::AssetManager ( )
default

◆ ~AssetManager()

template<typename Key, typename AssetClass>
virtual Asset::AssetManager< Key, AssetClass >::~AssetManager ( )
virtualdefault

Member Function Documentation

◆ add()

template<typename Key, typename AssetClass>
void Asset::AssetManager< Key, AssetClass >::add ( Key path,
AssetClass * asset )

Adds or overwrites a previously declared asset at a key.

Parameters
pathThe key with which to access the asset
assetThe asset to manage
Author
Konstantin Passig
Date
03.12.2025

Definition at line 241 of file Asset.h.

References assets, and TRACY_ZONE_SCOPED_NAMED.

◆ clear()

template<typename Key, typename AssetClass>
void Asset::AssetManager< Key, AssetClass >::clear ( )
virtual

Clears out all resources.

Author
Konstantin Passig
Date
03.12.2025

Definition at line 273 of file Asset.h.

References assets, and TRACY_ZONE_SCOPED_NAMED.

◆ declare()

template<typename Key, typename AssetClass>
template<typename... Args>
void Asset::AssetManager< Key, AssetClass >::declare ( Key path,
Args &&... args )

Adds an asset to the list in its unloaded state.

Template Parameters
Argsarguments to feed the empty assets constructor at the location
Parameters
pathlocation to create the asset at in the asset manager
argsarguments for the asset constructor
Author
Konstantin Passig
Date
03.12.2025

Definition at line 236 of file Asset.h.

References assets.

◆ exists()

template<typename Key, typename AssetClass>
bool Asset::AssetManager< Key, AssetClass >::exists ( Key path)

Checks if an asset already exists. This means it is declared and there is content.

Parameters
paththe key to check
Returns
true if it exists

Definition at line 248 of file Asset.h.

References assets.

◆ forEachAsset()

template<typename Key, typename AssetClass>
template<typename Func>
void Asset::AssetManager< Key, AssetClass >::forEachAsset ( Func && func) const
inline

Iterates over all assets and calls the provided callback for each.

Template Parameters
FuncCallable type that accepts (const Key&, AssetClass*)
Parameters
funcThe callback to invoke for each asset
Author
Konstantin Passig
Date
21.01.2026

Definition at line 222 of file Asset.h.

References assets.

Referenced by EngineCore::RenderingDataManager::uploadMaterialBuffers().

Here is the caller graph for this function:

◆ getAsset()

template<typename Key, typename AssetClass>
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.

Parameters
pathThe asset to get
Returns
If it exists a pointer to the Asset. If it didn't exist a std::nullopt
Author
Konstantin Passig
Date
03.12.2025

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().

Here is the caller graph for this function:

◆ getAssetLoadingState()

template<typename Key, typename AssetClass>
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.

Parameters
pathwhich asset to get the loading state for
Returns
The loading state of an asset
Author
Konstantin Passig
Date
03.12.2025

Definition at line 259 of file Asset.h.

References assets, Asset::LOADING, and Asset::UNLOADED.

◆ isDeclared()

template<typename Key, typename AssetClass>
bool Asset::AssetManager< Key, AssetClass >::isDeclared ( Key path)

Checks if an asset has been declared. If it exists it is also declared.

Parameters
pathkey to check
Returns
true if it is declared. If it is declared and exists this is also true
Author
Konstantin Passig
Date
03.12.2025

Definition at line 253 of file Asset.h.

References assets.

Member Data Documentation

◆ assets

template<typename Key, typename AssetClass>
std::unordered_map<Key, AssetClass*> Asset::AssetManager< Key, AssetClass >::assets
private

Definition at line 231 of file Asset.h.

Referenced by add(), clear(), declare(), exists(), forEachAsset(), getAsset(), getAssetLoadingState(), and isDeclared().


The documentation for this class was generated from the following file:
  • /home/magerbeton/Documents/gl3-vulkan/Engine/include/Engine/Core/Asset.h