FIFE::Pool Class Reference

#include <pool.h>

Inheritance diagram for FIFE::Pool:
Inheritance graph
[legend]

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:
name The name used in debug output.

Definition at line 37 of file pool.cpp.

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

Destructor.

Definition at line 45 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:
filename The file to be loaded.
Returns:
The index of the resource in the pool.

Definition at line 108 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 94 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 86 of file pool.cpp.

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

Clear the resource loaders

Definition at line 90 of file pool.cpp.

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

Gets resource from pool with given index

Parameters:
inc Specifies weither this call will increase the ref counter

Definition at line 113 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 177 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 211 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 72 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:
dec Specifies weither the ref counter will be decreased before checking

Definition at line 158 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 57 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 227 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:
Generated on Wed Nov 23 13:05:05 2011 for FIFE by  doxygen 1.6.3