#include <pool.h>
Public Member Functions | |
Pool (const std::string &name) | |
virtual | ~Pool () |
virtual void | addResourceLoader (ResourceLoader *loader) |
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.
Definition at line 61 of file pool.h.
FIFE::Pool::Pool | ( | const std::string & | name | ) |
FIFE::Pool::~Pool | ( | ) | [virtual] |
Destructor.
Definition at line 45 of file pool.cpp.
References printStatistics(), reset(), and sanityCheck().
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 103 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 89 of file pool.cpp.
References FIFE::ResourceLocation::clone().
Referenced by addResourceFromFile().
void FIFE::Pool::addResourceLoader | ( | ResourceLoader * | loader | ) | [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 108 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 172 of file pool.cpp.
Referenced by printStatistics().
void FIFE::Pool::printStatistics | ( | ) | [virtual] |
Prints the cache statistics to the log
Definition at line 206 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 153 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] |