sftools
2.0 dev
Bunch of tools for SFML application development
|
A generic resource manager ready to be customized. More...
#include <GenericManager.hpp>
Public Member Functions | |
GenericManager () | |
Constructor. | |
bool | load (Id const &id, bool forceReload=false) |
Load a new resource. | |
void | unload (Id const &id) |
Unload a resource. | |
void | unloadAll () |
Unload all resources. | |
Resource const & | operator[] (Id const &id) const |
Fetch a resource. | |
Resource & | operator[] (Id const &id) |
Fetch a resource. | |
A generic resource manager ready to be customized.
Resource objects are stored in a std::map<Id, Resource*>
.
OnLoad
type must have an operator ()
taking an Id
as unique parameter and returning a pointer to Resource
(or 0 if loading failed).
Resource | Type of the resource to manage |
Id | Type of resources' identifiers |
OnLoad | Procedure type to load resources |
Definition at line 59 of file GenericManager.hpp.
sftools::GenericManager< Resource, Id, OnLoad >::GenericManager | ( | ) |
Constructor.
Definition at line 39 of file GenericManager.tpp.
bool sftools::GenericManager< Resource, Id, OnLoad >::load | ( | Id const & | id, |
bool | forceReload = false |
||
) |
Load a new resource.
id | id of the resource to load |
forceReload | ensure the resource is (re)loaded |
Definition at line 45 of file GenericManager.tpp.
Resource const & sftools::GenericManager< Resource, Id, OnLoad >::operator[] | ( | Id const & | id | ) | const |
Fetch a resource.
A std::invalid_argument
exception is thrown if id
doesn't exist.
id | the id of the resource to be fetched |
id
std::invalid_argument |
Definition at line 95 of file GenericManager.tpp.
Resource & sftools::GenericManager< Resource, Id, OnLoad >::operator[] | ( | Id const & | id | ) |
Fetch a resource.
A std::invalid_argument
exception is thrown if id
doesn't exist.
id | the id of the resource to be fetched |
id
std::invalid_argument |
Definition at line 110 of file GenericManager.tpp.
void sftools::GenericManager< Resource, Id, OnLoad >::unload | ( | Id const & | id | ) |
Unload a resource.
id | id of the resource to unload |
Definition at line 78 of file GenericManager.tpp.
void sftools::GenericManager< Resource, Id, OnLoad >::unloadAll | ( | ) |
Unload all resources.
Definition at line 85 of file GenericManager.tpp.