Public Member Functions

FIFE::ImageManager Class Reference

#include <imagemanager.h>

Inheritance diagram for FIFE::ImageManager:
Inheritance graph
[legend]
Collaboration diagram for FIFE::ImageManager:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ImageManager ()
virtual ~ImageManager ()
virtual ImagePtr create (IResourceLoader *loader=0)
virtual ImagePtr create (const std::string &name, IResourceLoader *loader=0)
virtual ImagePtr load (const std::string &name, IResourceLoader *loader=0)
virtual ImagePtr loadBlank (uint32_t width, uint32_t height)
virtual ImagePtr loadBlank (const std::string &name, uint32_t width, uint32_t height)
virtual ImagePtr add (Image *res)
virtual bool exists (const std::string &name)
virtual bool exists (ResourceHandle handle)
virtual void reload (const std::string &name)
virtual void reload (ResourceHandle handle)
virtual void reloadAll ()
virtual void loadUnreferenced ()
virtual void free (const std::string &name)
virtual void free (ResourceHandle handle)
virtual void freeAll ()
virtual void freeUnreferenced ()
virtual void remove (ImagePtr &resource)
virtual void remove (const std::string &name)
virtual void remove (ResourceHandle handle)
virtual void removeAll ()
virtual void removeUnreferenced ()
virtual ImagePtr get (const std::string &name)
virtual ImagePtr get (ResourceHandle handle)
virtual ResourceHandle getResourceHandle (const std::string &name)

Detailed Description

ImageManager

An interface for managing images.

See also:
IResource
IResourceLoader
IResourceManager

Definition at line 54 of file imagemanager.h.


Constructor & Destructor Documentation

FIFE::ImageManager::ImageManager (  )  [inline]

Default constructor.

Definition at line 59 of file imagemanager.h.

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

Destructor.

Definition at line 42 of file imagemanager.cpp.


Member Function Documentation

ImagePtr FIFE::ImageManager::add ( Image res  )  [virtual]

Add an Image to the manager

This function will create a ImagePtr and add the Image to the manager. The manager assumes ownership of the Image so DO NOT delete it.

Parameters:
res A pointer to the Image
Returns:
A ImagePtr to the added resource
See also:
Image

Definition at line 151 of file imagemanager.cpp.

References exists().

Referenced by create(), and loadBlank().

Here is the caller graph for this function:

ImagePtr FIFE::ImageManager::create ( IResourceLoader *  loader = 0  )  [virtual]

Creates a blank Image but does not load it immediately

Parameters:
loader A pointer to the custom resource loader. The default is NULL. If this parameter is present the resource will use the loader to load instead of the default built in functions.
Returns:
An ImagePtr to the newly created Image
See also:
Image
ImageLoader
IResourceLoader

Definition at line 91 of file imagemanager.cpp.

References add().

Referenced by load().

Here is the caller graph for this function:

ImagePtr FIFE::ImageManager::create ( const std::string &  name,
IResourceLoader *  loader = 0 
) [virtual]

Creates a blank Image but does not load it immediately

Parameters:
name The resource name. Typically a filename.
loader A pointer to the custom resource loader. The default is NULL. If this parameter is present the resource will use the loader to load instead of the default built in functions.
Returns:
An ImagePtr to the newly created Image
See also:
Image
ImageLoader
IResourceLoader

Definition at line 96 of file imagemanager.cpp.

References add(), and exists().

bool FIFE::ImageManager::exists ( const std::string &  name  )  [virtual]

Checks to see if an Image exists

This function will search the manager for Images that match the parameter

Parameters:
name The name of the Image
Returns:
True if the Image exists. False otherwise.

Definition at line 170 of file imagemanager.cpp.

Referenced by add(), and create().

Here is the caller graph for this function:

bool FIFE::ImageManager::exists ( ResourceHandle  handle  )  [virtual]

Checks to see if an Image exists

This function will search the manager for Images that match the parameter

Parameters:
handle The handle of the Image
Returns:
True if the Image exists. False otherwise.

Definition at line 179 of file imagemanager.cpp.

void FIFE::ImageManager::free ( const std::string &  name  )  [virtual]

Frees an Image from memory

The Image is not deleted but it's data is freed. This calls the Image::free() function and it is up to the resource to properly free it's memory. The manager keeps a reference to the Image in case its required in the future.

Parameters:
name The name of the Image
See also:
Image

Definition at line 243 of file imagemanager.cpp.

void FIFE::ImageManager::free ( ResourceHandle  handle  )  [virtual]

Frees an Image from memory

The Image is not deleted but it's data is freed. This calls the Image::free() function and it is up to the resource to properly free it's memory. The manager keeps a reference to the Image in case its required in the future.

Parameters:
handle The handle of the Image
See also:
Image

Definition at line 256 of file imagemanager.cpp.

void FIFE::ImageManager::freeAll (  )  [virtual]

Frees all Images

This calls the Image::free() function for every Image the manager is managing. It does not remove them from the manager.

See also:
Image

Definition at line 268 of file imagemanager.cpp.

void FIFE::ImageManager::freeUnreferenced (  )  [virtual]

Frees all unreferenced Image

This calls the IResource::free() function for Images that have no external references to them. It does not remove them from the manager.

See also:
IResource

Definition at line 284 of file imagemanager.cpp.

ImagePtr FIFE::ImageManager::get ( const std::string &  name  )  [virtual]

Gets a shared pointer to the Image

If the Image is not defined it will attempt to create and load the Image based on the name (it assumes the name is a filename)

Parameters:
name The name of the Image
Returns:
An ImagePtr to the Image

Definition at line 394 of file imagemanager.cpp.

References load().

ImagePtr FIFE::ImageManager::get ( ResourceHandle  handle  )  [virtual]

Gets a shared pointer to the Image

If the resource is not defined it returns an empty (or invalid) ImagePtr and makes an entry in the log.

Parameters:
handle The handle of the resource
Returns:
A ImagePtr to the resource
Todo:
This should throw an exception instead of an empty ImagePtr

Definition at line 410 of file imagemanager.cpp.

ResourceHandle FIFE::ImageManager::getResourceHandle ( const std::string &  name  )  [virtual]

Gets an Image handle by name

Returns the Image handle associated with the name

Parameters:
name The name of the Image
Returns:
0 if the resource name is invalid

Definition at line 448 of file imagemanager.cpp.

ImagePtr FIFE::ImageManager::load ( const std::string &  name,
IResourceLoader *  loader = 0 
) [virtual]

Creates a blank resource and loads it from disk

This function will create the Image if necessary and load the Image from disk. If the Image is not defined it will call ImageManager::create() before loading.

Parameters:
name The resource name. Typically a filename.
loader A pointer to the custom resource loader. The default is NULL. If this parameter is present the resource will use the loader to load instead of the default built in functions.
Returns:
A ImagePtr to the loaded Image
See also:
Image
ImageLoader
IResourceLoader

Definition at line 106 of file imagemanager.cpp.

References create().

Referenced by get().

Here is the caller graph for this function:

ImagePtr FIFE::ImageManager::loadBlank ( const std::string &  name,
uint32_t  width,
uint32_t  height 
) [virtual]

Loads a blank resource

Parameters:
name 
width 
height 
Returns:
An ImagePtr to the blank image (ready to be modified)

Definition at line 138 of file imagemanager.cpp.

References add().

ImagePtr FIFE::ImageManager::loadBlank ( uint32_t  width,
uint32_t  height 
) [virtual]

Loads a blank resource

Parameters:
width 
height 
Returns:
An ImagePtr to the blank image (ready to be modified)

Definition at line 129 of file imagemanager.cpp.

References add().

void FIFE::ImageManager::loadUnreferenced (  )  [virtual]

Loads all unreferenced Images

All Images that have no external references will be loaded into memory.

Definition at line 229 of file imagemanager.cpp.

void FIFE::ImageManager::reload ( ResourceHandle  handle  )  [virtual]

Reloads a resource

This function will reload an Image if it is managed by the manager. If not it creates an entry in the log specifying that the Image could not be found. It will load the Image if it is not already loaded.

Parameters:
handle The handle of the resource

Definition at line 202 of file imagemanager.cpp.

void FIFE::ImageManager::reload ( const std::string &  name  )  [virtual]

Reloads an Image

This function will reload an Image if it is managed by the manager. If not it creates an entry in the log specifying that the Image could not be found. It will load the Image if it is not already loaded.

Parameters:
name The name of the resource

Definition at line 188 of file imagemanager.cpp.

void FIFE::ImageManager::reloadAll (  )  [virtual]

Reloads all Images

This function will reload all Images managed by the manager. It will load an Image if it is not already loaded.

Todo:
It might be beneficial to supply a parameter to only reload resources that are already loaded

Definition at line 217 of file imagemanager.cpp.

void FIFE::ImageManager::remove ( const std::string &  name  )  [virtual]

Removes an Image from the manager

This removes all references to the Image from the manager. It does not however guarantee that the resources destructor is called. If the client has any left over references to the resource it will not be freed.

Parameters:
name The name of the Image
See also:
Image

Definition at line 316 of file imagemanager.cpp.

void FIFE::ImageManager::remove ( ResourceHandle  handle  )  [virtual]

Removes an Image from the manager

This removes all references to the Image from the manager. It does not however guarantee that the resources destructor is called. If the client has any left over references to the resource it will not be freed.

Parameters:
handle The handle of the Image
See also:
Image

Definition at line 338 of file imagemanager.cpp.

void FIFE::ImageManager::remove ( ImagePtr resource  )  [virtual]

Removes an Image from the manager

This removes all references to the Image from the manager. It does not however guarantee that the resources destructor is called. If the client has any left over references to the resource it will not be freed.

Parameters:
resource A ImagePtr to the image to be removed from the manager
Note:
This is useful if you want to remove ownership of a resource from the manager
See also:
Image

Definition at line 299 of file imagemanager.cpp.

void FIFE::ImageManager::removeAll (  )  [virtual]

Removes all Images from the manager

This effectively removes all references to all Images from the manager. If there are left over shared pointers to any resources they will not be deleted.

See also:
Image

Definition at line 361 of file imagemanager.cpp.

void FIFE::ImageManager::removeUnreferenced (  )  [virtual]

Removes all unreferenced Images

This effectively removes all Images that dont have an external reference. The resources will be deleted.

See also:
Image

Definition at line 373 of file imagemanager.cpp.


The documentation for this class was generated from the following files: