Gamedev Framework (gf)
0.3.0
A C++11 framework for 2D games
|
A generic cache for resources. More...
#include <gf/ResourceManager.h>
Public Types | |
using | Loader = std::function< std::unique_ptr< T >(const Path &)> |
A resource loader. More... | |
Public Member Functions | |
ResourceCache (Loader loader) | |
Constructor. More... | |
ResourceCache (const ResourceCache &)=delete | |
Deleted copy constructor. More... | |
ResourceCache & | operator= (const ResourceCache &)=delete |
Deleted copy assignment. More... | |
T & | getResource (AssetManager &assetManager, const Path &filename) |
Get a resource. More... | |
A generic cache for resources.
This function is a low-level class that is used in gf::ResourceManager. It is generic enough so that you can use it for your own purpose.
using gf::ResourceCache< T >::Loader = std::function<std::unique_ptr<T>(const Path&)> |
A resource loader.
|
inlineexplicit |
Constructor.
loader | A resource loader |
|
delete |
Deleted copy constructor.
|
inline |
Get a resource.
If the resource exists in the cache, it is returned immediately. Otherwise, it is searched thanks to an asset manager and put in the cache. If the resource is not found, an exception is thrown.
assetManager | An asset manager |
filename | The filename of the resource |
std::runtime_error | If the resource is not found |
|
delete |
Deleted copy assignment.