FIFE
be64c707dea6b3250bd4355bf5c825d25920087d
|
#include <animationmanager.h>
Public Member Functions | |
AnimationManager () | |
Default constructor. More... | |
virtual | ~AnimationManager () |
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 AnimationPtr | create (IResourceLoader *loader=0) |
Creates a blank Animation but does not load it immediately. More... | |
virtual AnimationPtr | create (const std::string &name, IResourceLoader *loader=0) |
Creates a blank Animation but does not load it immediately. More... | |
virtual AnimationPtr | load (const std::string &name, IResourceLoader *loader=0) |
Creates a blank resource and loads it from disk. More... | |
virtual AnimationPtr | add (Animation *res) |
Add an Animation to the manager. More... | |
virtual bool | exists (const std::string &name) |
Checks to see if an Animation exists. More... | |
virtual bool | exists (ResourceHandle handle) |
Checks to see if an Animation exists. More... | |
virtual void | reload (const std::string &name) |
Reloads an Animation. More... | |
virtual void | reload (ResourceHandle handle) |
Reloads a resource. More... | |
virtual void | reloadAll () |
Reloads all Animations. More... | |
virtual void | loadUnreferenced () |
Loads all unreferenced Animations. More... | |
virtual void | free (const std::string &name) |
Frees an Animation from memory. More... | |
virtual void | free (ResourceHandle handle) |
Frees an Animation from memory. More... | |
virtual void | freeAll () |
Frees all Animations. More... | |
virtual void | freeUnreferenced () |
Frees all unreferenced Animation. More... | |
virtual void | remove (AnimationPtr &resource) |
Removes an Animation from the manager. More... | |
virtual void | remove (const std::string &name) |
Removes an Animation from the manager. More... | |
virtual void | remove (ResourceHandle handle) |
Removes an Animation from the manager. More... | |
virtual void | removeAll () |
Removes all Animations from the manager. More... | |
virtual void | removeUnreferenced () |
Removes all unreferenced Animations. More... | |
virtual AnimationPtr | get (const std::string &name) |
Gets a shared pointer to the Animation. More... | |
virtual AnimationPtr | get (ResourceHandle handle) |
Gets a shared pointer to the Animation. More... | |
virtual AnimationPtr | getPtr (const std::string &name) |
virtual AnimationPtr | getPtr (ResourceHandle handle) |
virtual ResourceHandle | getResourceHandle (const std::string &name) |
Gets an Animation 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< AnimationManager > | |
DynamicSingleton () | |
virtual | ~DynamicSingleton () |
Private Types | |
typedef std::map< ResourceHandle, AnimationPtr > | AnimationHandleMap |
typedef std::map< ResourceHandle, AnimationPtr >::iterator | AnimationHandleMapIterator |
typedef std::map< ResourceHandle, AnimationPtr >::const_iterator | AnimationHandleMapConstIterator |
typedef std::pair< ResourceHandle, AnimationPtr > | AnimationHandleMapPair |
typedef std::map< std::string, AnimationPtr > | AnimationNameMap |
typedef std::map< std::string, AnimationPtr >::iterator | AnimationNameMapIterator |
typedef std::map< std::string, AnimationPtr >::const_iterator | AnimationNameMapConstIterator |
typedef std::pair< std::string, AnimationPtr > | AnimationNameMapPair |
Private Attributes | |
AnimationHandleMap | m_animHandleMap |
AnimationNameMap | m_animNameMap |
Additional Inherited Members | |
Static Public Member Functions inherited from FIFE::DynamicSingleton< AnimationManager > | |
static AnimationManager * | instance () |
An interface for managing animations.
Definition at line 54 of file animationmanager.h.
|
private |
Definition at line 363 of file animationmanager.h.
|
private |
Definition at line 365 of file animationmanager.h.
|
private |
Definition at line 364 of file animationmanager.h.
|
private |
Definition at line 366 of file animationmanager.h.
|
private |
Definition at line 368 of file animationmanager.h.
|
private |
Definition at line 370 of file animationmanager.h.
|
private |
Definition at line 369 of file animationmanager.h.
|
private |
Definition at line 371 of file animationmanager.h.
|
inline |
Default constructor.
Definition at line 59 of file animationmanager.h.
References add(), create(), exists(), free(), freeAll(), freeUnreferenced(), getMemoryUsed(), getPtr(), getResourceHandle(), getTotalResources(), getTotalResourcesCreated(), getTotalResourcesLoaded(), invalidate(), invalidateAll(), load(), loadUnreferenced(), reload(), reloadAll(), removeAll(), removeUnreferenced(), and ~AnimationManager().
|
virtual |
Destructor.
Definition at line 45 of file animationmanager.cpp.
Referenced by AnimationManager().
|
virtual |
Add an Animation to the manager.
This function will create a AnimationPtr and add the Animation to the manager. The manager assumes ownership of the Animation so DO NOT delete it.
res | A pointer to the Animation |
Definition at line 132 of file animationmanager.cpp.
References FIFE::_log, exists(), FL_WARN, FIFE::IResource::getHandle(), FIFE::IResource::getName(), m_animHandleMap, and m_animNameMap.
Referenced by AnimationManager(), and create().
|
virtual |
Creates a blank Animation 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 94 of file animationmanager.cpp.
References add().
Referenced by AnimationManager(), FIFE::ObjectLoader::load(), load(), and FIFE::AnimationLoader::loadAnimation().
|
virtual |
Creates a blank Animation 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 99 of file animationmanager.cpp.
References FIFE::_log, add(), exists(), FL_WARN, and getPtr().
|
virtual |
Checks to see if an Animation exists.
This function will search the manager for Animations that match the parameter
name | The name of the Animation |
Definition at line 151 of file animationmanager.cpp.
References m_animNameMap.
Referenced by add(), AnimationManager(), create(), and FIFE::AnimationLoader::loadAnimation().
|
virtual |
Checks to see if an Animation exists.
This function will search the manager for Animations that match the parameter
handle | The handle of the Animation |
Definition at line 160 of file animationmanager.cpp.
References m_animHandleMap.
|
virtual |
Frees an Animation from memory.
The Animation is not deleted but it's data is freed. This calls the Animation::free() function and it is up to the resource to properly free it's memory. The manager keeps a reference to the Animation in case its required in the future.
name | The name of the Animation |
Definition at line 224 of file animationmanager.cpp.
References FIFE::_log, FL_WARN, m_animNameMap, and FIFE::IResource::RES_LOADED.
Referenced by AnimationManager().
|
virtual |
Frees an Animation from memory.
The Animation is not deleted but it's data is freed. This calls the Animation::free() function and it is up to the resource to properly free it's memory. The manager keeps a reference to the Animation in case its required in the future.
handle | The handle of the Animation |
Definition at line 237 of file animationmanager.cpp.
References FIFE::_log, FL_WARN, m_animHandleMap, and FIFE::IResource::RES_LOADED.
|
virtual |
Frees all Animations.
This calls the Animation::free() function for every Animation the manager is managing. It does not remove them from the manager.
Definition at line 249 of file animationmanager.cpp.
References FIFE::_log, FL_DBG, m_animHandleMap, and FIFE::IResource::RES_LOADED.
Referenced by AnimationManager().
|
virtual |
Frees all unreferenced Animation.
This calls the IResource::free() function for Animations that have no external references to them. It does not remove them from the manager.
Definition at line 265 of file animationmanager.cpp.
References FIFE::_log, FL_DBG, m_animHandleMap, and FIFE::IResource::RES_LOADED.
Referenced by AnimationManager().
|
virtual |
Gets a shared pointer to the Animation.
If the Animation is not defined it will attempt to create and load the Animation based on the name (it assumes the name is a filename)
name | The name of the Animation |
Definition at line 375 of file animationmanager.cpp.
References load(), m_animNameMap, and FIFE::IResource::RES_LOADED.
|
virtual |
Gets a shared pointer to the Animation.
If the resource is not defined it returns an empty (or invalid) AnimationPtr and makes an entry in the log.
handle | The handle of the resource |
Definition at line 391 of file animationmanager.cpp.
References FIFE::_log, FL_WARN, m_animHandleMap, 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 49 of file animationmanager.cpp.
References m_animHandleMap.
Referenced by AnimationManager().
|
virtual |
Definition at line 406 of file animationmanager.cpp.
References FIFE::_log, FL_WARN, and m_animNameMap.
Referenced by AnimationManager(), create(), FIFE::ObjectLoader::load(), and FIFE::AnimationLoader::loadAnimation().
|
virtual |
Definition at line 418 of file animationmanager.cpp.
References FIFE::_log, FL_WARN, and m_animHandleMap.
|
virtual |
Gets an Animation handle by name.
Returns the Animation handle associated with the name
name | The name of the Animation |
Definition at line 429 of file animationmanager.cpp.
References FIFE::_log, FL_WARN, and m_animNameMap.
Referenced by AnimationManager().
|
virtual |
Returns the number of defined resources.
Gets the total number of resources managed by the manager.
Implements FIFE::IResourceManager.
Definition at line 90 of file animationmanager.cpp.
References m_animHandleMap.
Referenced by AnimationManager().
|
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 62 of file animationmanager.cpp.
References m_animHandleMap, and FIFE::IResource::RES_NOT_LOADED.
Referenced by AnimationManager().
|
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 76 of file animationmanager.cpp.
References m_animHandleMap, and FIFE::IResource::RES_LOADED.
Referenced by AnimationManager().
|
virtual |
Definition at line 440 of file animationmanager.cpp.
References m_animNameMap, and FIFE::IResource::RES_LOADED.
Referenced by AnimationManager().
|
virtual |
Definition at line 449 of file animationmanager.cpp.
References m_animHandleMap, and FIFE::IResource::RES_LOADED.
|
virtual |
Definition at line 458 of file animationmanager.cpp.
References m_animHandleMap, and FIFE::IResource::RES_LOADED.
Referenced by AnimationManager().
|
virtual |
Creates a blank resource and loads it from disk.
This function will create the Animation if necessary and load the Animation from disk. If the Animation is not defined it will call AnimationManager::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 109 of file animationmanager.cpp.
References FIFE::_log, create(), FL_WARN, FIFE::IResource::getState(), FIFE::Animation::load(), m_animNameMap, and FIFE::IResource::RES_NOT_LOADED.
Referenced by AnimationManager(), and get().
|
virtual |
Loads all unreferenced Animations.
All Animations that have no external references will be loaded into memory.
Definition at line 210 of file animationmanager.cpp.
References FIFE::_log, FL_DBG, m_animHandleMap, and FIFE::IResource::RES_LOADED.
Referenced by AnimationManager().
|
virtual |
Reloads an Animation.
This function will reload an Animation if it is managed by the manager. If not it creates an entry in the log specifying that the Animation could not be found. It will load the Animation if it is not already loaded.
name | The name of the resource |
Definition at line 169 of file animationmanager.cpp.
References FIFE::_log, FL_WARN, m_animNameMap, and FIFE::IResource::RES_LOADED.
Referenced by AnimationManager().
|
virtual |
Reloads a resource.
This function will reload an Animation if it is managed by the manager. If not it creates an entry in the log specifying that the Animation could not be found. It will load the Animation if it is not already loaded.
handle | The handle of the resource |
Definition at line 183 of file animationmanager.cpp.
References FIFE::_log, FL_WARN, m_animHandleMap, and FIFE::IResource::RES_LOADED.
|
virtual |
Reloads all Animations.
This function will reload all Animations managed by the manager. It will load an Animation if it is not already loaded.
Definition at line 198 of file animationmanager.cpp.
References m_animHandleMap, and FIFE::IResource::RES_LOADED.
Referenced by AnimationManager().
|
virtual |
Removes an Animation from the manager.
This removes all references to the Animation 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 AnimationPtr to the Animation to be removed from the manager |
Definition at line 280 of file animationmanager.cpp.
References FIFE::_log, FL_WARN, FIFE::IResource::getHandle(), FIFE::IResource::getName(), m_animHandleMap, and m_animNameMap.
|
virtual |
Removes an Animation from the manager.
This removes all references to the Animation 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 Animation |
Definition at line 297 of file animationmanager.cpp.
References FIFE::_log, FL_WARN, m_animHandleMap, and m_animNameMap.
|
virtual |
Removes an Animation from the manager.
This removes all references to the Animation 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 Animation |
Definition at line 319 of file animationmanager.cpp.
References FIFE::_log, FL_WARN, m_animHandleMap, and m_animNameMap.
|
virtual |
Removes all Animations from the manager.
This effectively removes all references to all Animations from the manager. If there are left over shared pointers to any resources they will not be deleted.
Definition at line 342 of file animationmanager.cpp.
References FIFE::_log, FL_DBG, m_animHandleMap, and m_animNameMap.
Referenced by AnimationManager().
|
virtual |
Removes all unreferenced Animations.
This effectively removes all Animations that dont have an external reference. The resources will be deleted.
Definition at line 354 of file animationmanager.cpp.
References FIFE::_log, FL_DBG, and m_animHandleMap.
Referenced by AnimationManager().
|
private |
Definition at line 373 of file animationmanager.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 375 of file animationmanager.h.
Referenced by add(), exists(), free(), get(), getPtr(), getResourceHandle(), invalidate(), load(), reload(), remove(), and removeAll().