Flint Engine
Modular C++20 2D game engine powered by SDL3
Loading...
Searching...
No Matches
Flint::IAssetLoader Class Referenceabstract

Abstract interface for loading raw asset data by path. More...

#include <flint/core/asset-loader.h>

+ Inheritance diagram for Flint::IAssetLoader:
+ Collaboration diagram for Flint::IAssetLoader:

Public Member Functions

virtual std::vector< char > getAsset (const std::string &path)=0
 Load the asset at path and return its raw bytes.
 
virtual bool hasAsset (const std::string &path) const =0
 Check whether an asset exists without loading it.
 
virtual bool isDoneLoading () const =0
 Query whether all assets have finished loading.
 
virtual uint64_t getAssetRevision (const std::string &path) const =0
 Return an opaque token that changes when path's contents change.
 

Detailed Description

Abstract interface for loading raw asset data by path.

Implementations might load from disk, a ZIP archive, or an in-memory store. The engine calls getAsset() to obtain byte blobs that are then handed to texture loaders, shader compilers, and so on.

Definition at line 18 of file asset-loader.h.

Member Function Documentation

◆ getAsset()

virtual std::vector< char > Flint::IAssetLoader::getAsset ( const std::string & path)
pure virtual

Load the asset at path and return its raw bytes.

Parameters
pathAsset path, relative to the loader's root.
Returns
A vector containing the full contents of the asset.
Exceptions
Implementation-definedexception if the asset cannot be found or read.

Implemented in Flint::FileSystem.

◆ getAssetRevision()

virtual uint64_t Flint::IAssetLoader::getAssetRevision ( const std::string & path) const
pure virtual

Return an opaque token that changes when path's contents change.

Only meaningful for equality comparison against a previously returned value for the same path. Not a timestamp, not ordered, not a counter.

Zero is reserved to mean "no such asset". Implementations must return 0 for any path that is absent or unreadable, and must never return 0 for an asset that getAsset() could successfully load. A loader that cannot track changes should still return a stable nonzero value for assets it has — returning 0 marks them permanently missing and disables hot reload.

Parameters
pathAsset path to query.
Returns
Nonzero revision token, or 0 if the asset is unavailable.

Implemented in Flint::FileSystem.

◆ hasAsset()

virtual bool Flint::IAssetLoader::hasAsset ( const std::string & path) const
pure virtual

Check whether an asset exists without loading it.

Parameters
pathAsset path to test.
Returns
true if the asset is available, false otherwise.

Implemented in Flint::FileSystem.

◆ isDoneLoading()

virtual bool Flint::IAssetLoader::isDoneLoading ( ) const
pure virtual

Query whether all assets have finished loading.

For synchronous loaders this always returns true. Async loaders may return false while background loading is in progress.

Returns
true when the loader is ready to serve all assets.

Implemented in Flint::FileSystem.


The documentation for this class was generated from the following file: