Gamedev Framework (gf)  0.1.0
A C++11 framework for 2D games
Public Types | Public Member Functions | List of all members
gf::ResourceCache< T > Class Template Reference

A generic cache for ressources. More...

#include <gf/ResourceManager.h>

Public Types

typedef std::function
< std::unique_ptr< T >const
Path &)> 
 A ressource loader. More...

Public Member Functions

 ResourceCache (Loader loader)
 Constructor. More...
 ResourceCache (const ResourceCache &)=delete
 Deleted copy constructor. More...
ResourceCacheoperator= (const ResourceCache &)=delete
 Deleted copy assignment. More...
TgetResource (AssetManager &assetManager, const Path &filename)
 Get a ressource. More...

Detailed Description

template<typename T>
class gf::ResourceCache< T >

A generic cache for ressources.

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.

See also

Member Typedef Documentation

template<typename T>
typedef std::function<std::unique_ptr<T>const Path&)> gf::ResourceCache< T >::Loader

A ressource loader.

Constructor & Destructor Documentation

template<typename T>
gf::ResourceCache< T >::ResourceCache ( Loader  loader)


loaderA ressource loader
template<typename T>
gf::ResourceCache< T >::ResourceCache ( const ResourceCache< T > &  )

Deleted copy constructor.

Member Function Documentation

template<typename T>
T* gf::ResourceCache< T >::getResource ( AssetManager assetManager,
const Path filename 

Get a ressource.

If the ressource exists in the cache, it is returned immediately. Otherwise, it is searched thanks to an asset manager and put in the cache.

assetManagerAn asset manager
filenameThe filename of the ressource
The ressource or nullptr if it has not been found
template<typename T>
ResourceCache& gf::ResourceCache< T >::operator= ( const ResourceCache< T > &  )

Deleted copy assignment.