FIFE 2008.0
|
#include <pool.h>
Public Member Functions | |
Pool (const std::string &name) | |
virtual | ~Pool () |
virtual void | addResourceLoader (ResourceLoader *loader) |
virtual void | clearResourceLoaders () |
virtual int | addResourceFromLocation (ResourceLocation *loc) |
virtual int | addResourceFromFile (const std::string &filename) |
virtual IResource & | get (unsigned int index, bool inc=false) |
virtual void | release (unsigned int index, bool dec=false) |
virtual int | purgeLoadedResources () |
virtual int | getResourceCount (int status) |
virtual void | printStatistics () |
void | sanityCheck () |
virtual void | reset () |
Static Public Attributes | |
static const int | INVALID_ID = -1 |
Pool is used to optimize memory usage for resources
Pool guarantees that there is minimal amount of resources used in cases when it is would possible that multiple instances of the same data would be loaded into the memory. Pool is the owner for resources taking care of their deletion.
FIFE::Pool::Pool | ( | const std::string & | name | ) |
FIFE::Pool::~Pool | ( | ) | [virtual] |
int FIFE::Pool::addResourceFromFile | ( | const std::string & | filename | ) | [virtual] |
This is a convenience version of addResourceFromLocation(). It converts the filename into a ResourceLocation and then calls addResourceFromLocation.
filename | The file to be loaded. |
Definition at line 109 of file pool.cpp.
References addResourceFromLocation().
Referenced by FIFE::SubImageFont::SubImageFont().
int FIFE::Pool::addResourceFromLocation | ( | ResourceLocation * | loc | ) | [virtual] |
Adds new resource into the pool using the given location.
Definition at line 95 of file pool.cpp.
References FIFE::ResourceLocation::clone().
Referenced by addResourceFromFile().
void FIFE::Pool::addResourceLoader | ( | ResourceLoader * | loader | ) | [virtual] |
Adds new resource provider. Transfers provider ownership to the pool
Definition at line 87 of file pool.cpp.
Referenced by FIFE::Engine::init().
void FIFE::Pool::clearResourceLoaders | ( | ) | [virtual] |
IResource & FIFE::Pool::get | ( | unsigned int | index, |
bool | inc = false |
||
) | [virtual] |
Gets resource from pool with given index
inc | Specifies weither this call will increase the ref counter |
Definition at line 114 of file pool.cpp.
Referenced by FIFE::SubImageFont::SubImageFont().
int FIFE::Pool::getResourceCount | ( | int | status | ) | [virtual] |
Gets amount of resources in the pool with given status
Definition at line 178 of file pool.cpp.
Referenced by printStatistics().
void FIFE::Pool::printStatistics | ( | ) | [virtual] |
Prints the cache statistics to the log
Definition at line 212 of file pool.cpp.
References getResourceCount().
Referenced by ~Pool().
int FIFE::Pool::purgeLoadedResources | ( | ) | [virtual] |
void FIFE::Pool::release | ( | unsigned int | index, |
bool | dec = false |
||
) | [virtual] |
Removes the resource from pool if reference counter is null
dec | Specifies weither the ref counter will be decreased before checking |
Definition at line 159 of file pool.cpp.
Referenced by FIFE::SoundEmitter::reset().
void FIFE::Pool::reset | ( | ) | [virtual] |
void FIFE::Pool::sanityCheck | ( | ) |
const int FIFE::Pool::INVALID_ID = -1 [static] |