← API Reference Class

template<typename T, typename ... KeyArgs> asge::game::asset::AssetPool

A VFS-backed, path-keyed cache of shared_ptr<Asset<T>>, loaded via a caller-supplied Loader on first request.

#include <AssetPool.hpp>

KeyArgs extends the cache key past the virtual path for asset types a bare path doesn't fully identify — e.g. a font's bake pixel height, so "fonts/x.ttf" at two different sizes gets two independent cache entries (see AssetManager's AssetPool<graphics::Font, int>). The key is the exact virtual-path string plus KeyArgs as passed to GetOrLoad — it is not canonicalized, so two differently-formatted but VFS-equivalent virtual paths (e.g. a leading /) are cached separately.

Public Types

#using asset_ptr = std::shared_ptr< Asset< T > >
#using Loader = std::function< Result< T >(filesystem::Path const &, KeyArgs...)>

Loads T from a resolved real path plus this pool's extra key args.

Private Types

#using Key = std::tuple< str::String, KeyArgs... >private

Private Attributes

#std::unordered_map< Key, asset_ptr, KeyHash > m_Assetsprivate
#Loader m_Loaderprivate

Public Member Functions

#explicit AssetPool(Loader inLoader) noexcept
#AssetPool(AssetPool const &)=delete
#AssetPool & operator=(AssetPool const &)=delete
#AssetPool(AssetPool &&)=default
#AssetPool & operator=(AssetPool &&)=default
#Result< asset_ptr > GetOrLoad(filesystem::VirtualFileSystem const &inVfs, str::StringCRef inVirtualPath, KeyArgs ...inArgs) noexcept

Returns the cached asset for this virtual path/key, loading it through the VFS and Loader on a cache miss.

A VFS resolve failure or a Loader failure is returned as-is and nothing is cached for that key, so a later call retries the load.

#void Remove(str::StringCRef inVirtualPath, KeyArgs ...inArgs) noexcept

Remove a cached asset from the pool.