FIFE 2008.0
FIFE::Pool Class Reference

#include <pool.h>

Inheritance diagram for FIFE::Pool:

List of all members.

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 IResourceget (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

Detailed Description

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.


Constructor & Destructor Documentation

FIFE::Pool::Pool ( const std::string &  name)

Default constructor.

Parameters:
nameThe name used in debug output.

Definition at line 38 of file pool.cpp.

FIFE::Pool::~Pool ( ) [virtual]

Destructor.

Definition at line 46 of file pool.cpp.

References printStatistics(), and reset().


Member Function Documentation

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.

Parameters:
filenameThe file to be loaded.
Returns:
The index of the resource in the pool.

Definition at line 109 of file pool.cpp.

References addResourceFromLocation().

Referenced by FIFE::SubImageFont::SubImageFont().

Here is the caller graph for this function:

int FIFE::Pool::addResourceFromLocation ( ResourceLocation loc) [virtual]

Adds new resource into the pool using the given location.

Returns:
The index of the resource in the pool.

Definition at line 95 of file pool.cpp.

References FIFE::ResourceLocation::clone().

Referenced by addResourceFromFile().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

void FIFE::Pool::clearResourceLoaders ( ) [virtual]

Clear the resource loaders

Definition at line 91 of file pool.cpp.

IResource & FIFE::Pool::get ( unsigned int  index,
bool  inc = false 
) [virtual]

Gets resource from pool with given index

Parameters:
incSpecifies weither this call will increase the ref counter

Definition at line 114 of file pool.cpp.

Referenced by FIFE::SubImageFont::SubImageFont().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

int FIFE::Pool::purgeLoadedResources ( ) [virtual]

Purge all loaded resources. This will purge all loaded resources with a ref count of zero. Indices remain valid, though.

Returns:
Number of resources deleted.

Definition at line 73 of file pool.cpp.

void FIFE::Pool::release ( unsigned int  index,
bool  dec = false 
) [virtual]

Removes the resource from pool if reference counter is null

Parameters:
decSpecifies weither the ref counter will be decreased before checking

Definition at line 159 of file pool.cpp.

Referenced by FIFE::SoundEmitter::reset().

Here is the caller graph for this function:

void FIFE::Pool::reset ( ) [virtual]

Resets the pool. This will purge all loaded resources with a ref count of zero. The location and loader information for the locations is lost. Only the resource loaders are retained.

Definition at line 58 of file pool.cpp.

Referenced by ~Pool().

Here is the caller graph for this function:

void FIFE::Pool::sanityCheck ( )

Performs a sanity check for the location map.

Definition at line 228 of file pool.cpp.


Member Data Documentation

const int FIFE::Pool::INVALID_ID = -1 [static]

Indicates invalid index for pool

Definition at line 65 of file pool.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Enumerations Enumerator