FIFE
be64c707dea6b3250bd4355bf5c825d25920087d
|
#include <imagemanager.h>
Public Member Functions | |
ImageManager () | |
Default constructor. More... | |
virtual | ~ImageManager () |
Destructor. More... | |
virtual size_t | getMemoryUsed () const |
Gets the total amount of memory used by resources. More... | |
virtual size_t | getTotalResourcesCreated () const |
Returns the number of unloaded resources. More... | |
virtual size_t | getTotalResourcesLoaded () const |
Returns the number of loaded resources. More... | |
virtual size_t | getTotalResources () const |
Returns the number of defined resources. More... | |
virtual ImagePtr | create (IResourceLoader *loader=0) |
Creates a blank Image but does not load it immediately. More... | |
virtual ImagePtr | create (const std::string &name, IResourceLoader *loader=0) |
Creates a blank Image but does not load it immediately. More... | |
virtual ImagePtr | load (const std::string &name, IResourceLoader *loader=0) |
Creates a blank resource and loads it from disk. More... | |
virtual ImagePtr | loadBlank (uint32_t width, uint32_t height) |
Loads a blank resource. More... | |
virtual ImagePtr | loadBlank (const std::string &name, uint32_t width, uint32_t height) |
Loads a blank resource. More... | |
virtual ImagePtr | add (Image *res) |
Add an Image to the manager. More... | |
virtual bool | exists (const std::string &name) |
Checks to see if an Image exists. More... | |
virtual bool | exists (ResourceHandle handle) |
Checks to see if an Image exists. More... | |
virtual void | reload (const std::string &name) |
Reloads an Image. More... | |
virtual void | reload (ResourceHandle handle) |
Reloads a resource. More... | |
virtual void | reloadAll () |
Reloads all Images. More... | |
virtual void | loadUnreferenced () |
Loads all unreferenced Images. More... | |
virtual void | free (const std::string &name) |
Frees an Image from memory. More... | |
virtual void | free (ResourceHandle handle) |
Frees an Image from memory. More... | |
virtual void | freeAll () |
Frees all Images. More... | |
virtual void | freeUnreferenced () |
Frees all unreferenced Image. More... | |
virtual void | remove (ImagePtr &resource) |
Removes an Image from the manager. More... | |
virtual void | remove (const std::string &name) |
Removes an Image from the manager. More... | |
virtual void | remove (ResourceHandle handle) |
Removes an Image from the manager. More... | |
virtual void | removeAll () |
Removes all Images from the manager. More... | |
virtual void | removeUnreferenced () |
Removes all unreferenced Images. More... | |
virtual ImagePtr | get (const std::string &name) |
Gets a shared pointer to the Image. More... | |
virtual ImagePtr | get (ResourceHandle handle) |
Gets a shared pointer to the Image. More... | |
virtual ImagePtr | getPtr (const std::string &name) |
virtual ImagePtr | getPtr (ResourceHandle handle) |
virtual ResourceHandle | getResourceHandle (const std::string &name) |
Gets an Image handle by name. More... | |
virtual void | invalidate (const std::string &name) |
virtual void | invalidate (ResourceHandle handle) |
virtual void | invalidateAll () |
Public Member Functions inherited from FIFE::IResourceManager | |
IResourceManager () | |
Default constructor. More... | |
virtual | ~IResourceManager () |
destructor More... | |
Public Member Functions inherited from FIFE::DynamicSingleton< ImageManager > | |
DynamicSingleton () | |
virtual | ~DynamicSingleton () |
Private Types | |
typedef std::map< ResourceHandle, ImagePtr > | ImageHandleMap |
typedef std::map< ResourceHandle, ImagePtr >::iterator | ImageHandleMapIterator |
typedef std::map< ResourceHandle, ImagePtr >::const_iterator | ImageHandleMapConstIterator |
typedef std::pair< ResourceHandle, ImagePtr > | ImageHandleMapPair |
typedef std::map< std::string, ImagePtr > | ImageNameMap |
typedef std::map< std::string, ImagePtr >::iterator | ImageNameMapIterator |
typedef std::map< std::string, ImagePtr >::const_iterator | ImageNameMapConstIterator |
typedef std::pair< std::string, ImagePtr > | ImageNameMapPair |
Private Attributes | |
ImageHandleMap | m_imgHandleMap |
ImageNameMap | m_imgNameMap |
Additional Inherited Members | |
Static Public Member Functions inherited from FIFE::DynamicSingleton< ImageManager > | |
static ImageManager * | instance () |
An interface for managing images.
Definition at line 54 of file imagemanager.h.
|
private |
Definition at line 380 of file imagemanager.h.
|
private |
Definition at line 382 of file imagemanager.h.
|
private |
Definition at line 381 of file imagemanager.h.
|
private |
Definition at line 383 of file imagemanager.h.
|
private |
Definition at line 385 of file imagemanager.h.
|
private |
Definition at line 387 of file imagemanager.h.
|
private |
Definition at line 386 of file imagemanager.h.
|
private |
Definition at line 388 of file imagemanager.h.
|
inline |
Default constructor.
Definition at line 59 of file imagemanager.h.
References add(), create(), exists(), free(), freeAll(), freeUnreferenced(), getMemoryUsed(), getPtr(), getResourceHandle(), getTotalResources(), getTotalResourcesCreated(), getTotalResourcesLoaded(), invalidate(), invalidateAll(), load(), loadBlank(), loadUnreferenced(), reload(), reloadAll(), removeAll(), removeUnreferenced(), and ~ImageManager().
|
virtual |
Destructor.
Definition at line 46 of file imagemanager.cpp.
Referenced by ImageManager().
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.
res | A pointer to the Image |
Definition at line 155 of file imagemanager.cpp.
References FIFE::_log, exists(), FL_WARN, FIFE::IResource::getHandle(), FIFE::IResource::getName(), m_imgHandleMap, and m_imgNameMap.
Referenced by FIFE::InstanceRenderer::bindColoring(), FIFE::InstanceRenderer::bindMultiOutline(), FIFE::InstanceRenderer::bindOutline(), create(), FIFE::LibRocketRenderInterface::GenerateTexture(), FIFE::InstanceRenderer::getMultiColorOverlay(), ImageManager(), and loadBlank().
|
virtual |
Creates a blank Image but does not load it immediately.
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. |
Definition at line 95 of file imagemanager.cpp.
References add(), FIFE::RenderBackend::createImage(), and FIFE::DynamicSingleton< RenderBackend >::instance().
Referenced by ImageManager(), FIFE::GuiImageLoader::load(), FIFE::SDLImage::load(), FIFE::GLImage::load(), FIFE::ObjectLoader::load(), load(), FIFE::AnimationLoader::loadAnimation(), FIFE::AtlasLoader::loadAtlas(), and FIFE::Cursor::setNativeImageCursor().
|
virtual |
Creates a blank Image but does not load it immediately.
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. |
Definition at line 100 of file imagemanager.cpp.
References FIFE::_log, add(), FIFE::RenderBackend::createImage(), exists(), FL_WARN, getPtr(), and FIFE::DynamicSingleton< RenderBackend >::instance().
|
virtual |
Checks to see if an Image exists.
This function will search the manager for Images that match the parameter
name | The name of the Image |
Definition at line 174 of file imagemanager.cpp.
References m_imgNameMap.
Referenced by add(), FIFE::InstanceRenderer::bindColoring(), FIFE::InstanceRenderer::bindMultiOutline(), FIFE::InstanceRenderer::bindOutline(), create(), ImageManager(), FIFE::GuiImageLoader::load(), FIFE::SDLImage::load(), FIFE::ObjectLoader::load(), FIFE::AnimationLoader::loadAnimation(), FIFE::AtlasLoader::loadAtlas(), and FIFE::LibRocketRenderInterface::LoadTexture().
|
virtual |
Checks to see if an Image exists.
This function will search the manager for Images that match the parameter
handle | The handle of the Image |
Definition at line 183 of file imagemanager.cpp.
References m_imgHandleMap.
|
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.
name | The name of the Image |
Definition at line 247 of file imagemanager.cpp.
References FIFE::_log, FL_WARN, m_imgNameMap, and FIFE::IResource::RES_LOADED.
Referenced by FIFE::InstanceRenderer::check(), FIFE::GuiImage::free(), and ImageManager().
|
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.
handle | The handle of the Image |
Definition at line 260 of file imagemanager.cpp.
References FIFE::_log, FL_WARN, m_imgHandleMap, and FIFE::IResource::RES_LOADED.
|
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.
Definition at line 272 of file imagemanager.cpp.
References FIFE::_log, FL_DBG, m_imgHandleMap, and FIFE::IResource::RES_LOADED.
Referenced by ImageManager().
|
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.
Definition at line 288 of file imagemanager.cpp.
References FIFE::_log, FL_DBG, m_imgHandleMap, and FIFE::IResource::RES_LOADED.
Referenced by ImageManager().
|
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)
name | The name of the Image |
Definition at line 398 of file imagemanager.cpp.
References load(), m_imgNameMap, and FIFE::IResource::RES_LOADED.
Referenced by FIFE::LibRocketRenderInterface::freeTextures(), FIFE::GuiImageLoader::load(), FIFE::LibRocketRenderInterface::LoadTexture(), FIFE::LibRocketRenderInterface::render(), FIFE::Camera::renderOverlay(), and FIFE::LayerCache::updateVisual().
|
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.
handle | The handle of the resource |
Definition at line 414 of file imagemanager.cpp.
References FIFE::_log, FL_WARN, m_imgHandleMap, and FIFE::IResource::RES_LOADED.
|
virtual |
Gets the total amount of memory used by resources.
This function uses the IResource's getSize() function to calculate the total memory used. It does not include memory used by the internal resource manager book keeping structures. This value is only accurate if the resources getSize() function returns an accurate result.
Implements FIFE::IResourceManager.
Definition at line 50 of file imagemanager.cpp.
References m_imgHandleMap.
Referenced by ImageManager().
|
virtual |
Definition at line 429 of file imagemanager.cpp.
References FIFE::_log, FL_WARN, and m_imgNameMap.
Referenced by FIFE::InstanceRenderer::bindColoring(), FIFE::InstanceRenderer::bindMultiOutline(), FIFE::InstanceRenderer::bindOutline(), create(), FIFE::InstanceRenderer::getMultiColorOverlay(), ImageManager(), FIFE::ObjectLoader::load(), FIFE::AnimationLoader::loadAnimation(), and FIFE::AtlasLoader::loadAtlas().
|
virtual |
Definition at line 441 of file imagemanager.cpp.
References FIFE::_log, FL_WARN, and m_imgHandleMap.
|
virtual |
Gets an Image handle by name.
Returns the Image handle associated with the name
name | The name of the Image |
Definition at line 452 of file imagemanager.cpp.
References FIFE::_log, FL_WARN, and m_imgNameMap.
Referenced by ImageManager().
|
virtual |
Returns the number of defined resources.
Gets the total number of resources managed by the manager.
Implements FIFE::IResourceManager.
Definition at line 91 of file imagemanager.cpp.
References m_imgHandleMap.
Referenced by ImageManager().
|
virtual |
Returns the number of unloaded resources.
Gets the total number of resources created but not loaded. These resources have been defined in the resource manager but have yet to be loaded from disk.
Implements FIFE::IResourceManager.
Definition at line 63 of file imagemanager.cpp.
References m_imgHandleMap, and FIFE::IResource::RES_NOT_LOADED.
Referenced by ImageManager().
|
virtual |
Returns the number of loaded resources.
Gets the total number of resources created and loaded. These resources have been defined in the resource manager have been loaded from disk.
Implements FIFE::IResourceManager.
Definition at line 77 of file imagemanager.cpp.
References m_imgHandleMap, and FIFE::IResource::RES_LOADED.
Referenced by ImageManager().
|
virtual |
Definition at line 463 of file imagemanager.cpp.
References m_imgNameMap, and FIFE::IResource::RES_LOADED.
Referenced by ImageManager().
|
virtual |
Definition at line 472 of file imagemanager.cpp.
References m_imgHandleMap, and FIFE::IResource::RES_LOADED.
|
virtual |
Definition at line 481 of file imagemanager.cpp.
References m_imgHandleMap, and FIFE::IResource::RES_LOADED.
Referenced by FIFE::Engine::changeScreenMode(), and ImageManager().
|
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.
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. |
Definition at line 110 of file imagemanager.cpp.
References FIFE::_log, create(), FL_WARN, FIFE::IResource::getState(), FIFE::Image::load(), m_imgNameMap, and FIFE::IResource::RES_NOT_LOADED.
Referenced by get(), ImageManager(), FIFE::GuiImageLoader::load(), FIFE::LibRocketRenderInterface::LoadTexture(), and FIFE::SubImageFont::SubImageFont().
|
virtual |
Loads a blank resource.
width | |
height |
Definition at line 133 of file imagemanager.cpp.
References add(), FIFE::RenderBackend::createImage(), FIFE::DynamicSingleton< RenderBackend >::instance(), FIFE::IResource::RES_LOADED, and FIFE::IResource::setState().
Referenced by ImageManager(), FIFE::GuiImageLoader::load(), FIFE::Camera::renderStaticLayer(), and FIFE::RenderTarget::RenderTarget().
|
virtual |
Loads a blank resource.
name | |
width | |
height |
Definition at line 142 of file imagemanager.cpp.
References add(), FIFE::RenderBackend::createImage(), FIFE::DynamicSingleton< RenderBackend >::instance(), m_imgNameMap, FIFE::IResource::RES_LOADED, and FIFE::IResource::setState().
|
virtual |
Loads all unreferenced Images.
All Images that have no external references will be loaded into memory.
Definition at line 233 of file imagemanager.cpp.
References FIFE::_log, FL_DBG, m_imgHandleMap, and FIFE::IResource::RES_LOADED.
Referenced by ImageManager().
|
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.
name | The name of the resource |
Definition at line 192 of file imagemanager.cpp.
References FIFE::_log, FL_WARN, m_imgNameMap, and FIFE::IResource::RES_LOADED.
Referenced by ImageManager().
|
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.
handle | The handle of the resource |
Definition at line 206 of file imagemanager.cpp.
References FIFE::_log, FL_WARN, m_imgHandleMap, and FIFE::IResource::RES_LOADED.
|
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.
Definition at line 221 of file imagemanager.cpp.
References m_imgHandleMap, and FIFE::IResource::RES_LOADED.
Referenced by ImageManager().
|
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.
resource | A ImagePtr to the image to be removed from the manager |
Definition at line 303 of file imagemanager.cpp.
References FIFE::_log, FL_WARN, FIFE::IResource::getHandle(), FIFE::IResource::getName(), m_imgHandleMap, and m_imgNameMap.
Referenced by FIFE::GuiImageLoader::load(), and FIFE::Cursor::setNativeImageCursor().
|
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.
name | The name of the Image |
Definition at line 320 of file imagemanager.cpp.
References FIFE::_log, FL_WARN, m_imgHandleMap, and m_imgNameMap.
|
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.
handle | The handle of the Image |
Definition at line 342 of file imagemanager.cpp.
References FIFE::_log, FL_WARN, m_imgHandleMap, and m_imgNameMap.
|
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.
Definition at line 365 of file imagemanager.cpp.
References FIFE::_log, FL_DBG, m_imgHandleMap, and m_imgNameMap.
Referenced by ImageManager().
|
virtual |
Removes all unreferenced Images.
This effectively removes all Images that dont have an external reference. The resources will be deleted.
Definition at line 377 of file imagemanager.cpp.
References FIFE::_log, FL_DBG, and m_imgHandleMap.
Referenced by ImageManager().
|
private |
Definition at line 390 of file imagemanager.h.
Referenced by add(), exists(), free(), freeAll(), freeUnreferenced(), get(), getMemoryUsed(), getPtr(), getTotalResources(), getTotalResourcesCreated(), getTotalResourcesLoaded(), invalidate(), invalidateAll(), loadUnreferenced(), reload(), reloadAll(), remove(), removeAll(), and removeUnreferenced().
|
private |
Definition at line 392 of file imagemanager.h.
Referenced by add(), exists(), free(), get(), getPtr(), getResourceHandle(), invalidate(), load(), loadBlank(), reload(), remove(), and removeAll().