FIFE  6e1afdbeda11afe9ac53e6023a4be96ef88f1dc6
FIFE::AnimationManager Class Reference

AnimationManager. More...

#include <animationmanager.h>

+ Inheritance diagram for FIFE::AnimationManager:
+ Collaboration diagram for FIFE::AnimationManager:

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, AnimationPtrAnimationHandleMap
 
typedef std::map< ResourceHandle, AnimationPtr >::iterator AnimationHandleMapIterator
 
typedef std::map< ResourceHandle, AnimationPtr >::const_iterator AnimationHandleMapConstIterator
 
typedef std::pair< ResourceHandle, AnimationPtrAnimationHandleMapPair
 
typedef std::map< std::string, AnimationPtrAnimationNameMap
 
typedef std::map< std::string, AnimationPtr >::iterator AnimationNameMapIterator
 
typedef std::map< std::string, AnimationPtr >::const_iterator AnimationNameMapConstIterator
 
typedef std::pair< std::string, AnimationPtrAnimationNameMapPair
 

Private Attributes

AnimationHandleMap m_animHandleMap
 
AnimationNameMap m_animNameMap
 

Additional Inherited Members

- Static Public Member Functions inherited from FIFE::DynamicSingleton< AnimationManager >
static AnimationManagerinstance ()
 

Detailed Description

AnimationManager.

An interface for managing animations.

See also
IResource
IResourceLoader
IResourceManager

Definition at line 54 of file animationmanager.h.

Member Typedef Documentation

Definition at line 363 of file animationmanager.h.

Definition at line 365 of file animationmanager.h.

Definition at line 364 of file animationmanager.h.

Definition at line 366 of file animationmanager.h.

typedef std::map< std::string, AnimationPtr > FIFE::AnimationManager::AnimationNameMap
private

Definition at line 368 of file animationmanager.h.

typedef std::map< std::string, AnimationPtr >::const_iterator FIFE::AnimationManager::AnimationNameMapConstIterator
private

Definition at line 370 of file animationmanager.h.

typedef std::map< std::string, AnimationPtr >::iterator FIFE::AnimationManager::AnimationNameMapIterator
private

Definition at line 369 of file animationmanager.h.

typedef std::pair< std::string, AnimationPtr > FIFE::AnimationManager::AnimationNameMapPair
private

Definition at line 371 of file animationmanager.h.

Constructor & Destructor Documentation

FIFE::AnimationManager::~AnimationManager ( )
virtual

Destructor.

Definition at line 45 of file animationmanager.cpp.

Referenced by AnimationManager().

+ Here is the caller graph for this function:

Member Function Documentation

AnimationPtr FIFE::AnimationManager::add ( Animation res)
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.

Parameters
resA pointer to the Animation
Returns
A AnimationPtr to the added resource
See also
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().

+ Here is the caller graph for this function:

AnimationPtr FIFE::AnimationManager::create ( IResourceLoader loader = 0)
virtual

Creates a blank Animation but does not load it immediately.

Parameters
loaderA 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 AnimationPtr to the newly created Animation
See also
Animation
AnimationLoader
IResourceLoader

Definition at line 94 of file animationmanager.cpp.

References add().

Referenced by AnimationManager(), FIFE::ObjectLoader::load(), load(), and FIFE::AnimationLoader::loadAnimation().

+ Here is the caller graph for this function:

AnimationPtr FIFE::AnimationManager::create ( const std::string &  name,
IResourceLoader loader = 0 
)
virtual

Creates a blank Animation but does not load it immediately.

Parameters
nameThe resource name. Typically a filename.
loaderA 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 AnimationPtr to the newly created Animation
See also
Animation
AnimationLoader
IResourceLoader

Definition at line 99 of file animationmanager.cpp.

References FIFE::_log, add(), exists(), FL_WARN, and getPtr().

bool FIFE::AnimationManager::exists ( const std::string &  name)
virtual

Checks to see if an Animation exists.

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

Parameters
nameThe name of the Animation
Returns
True if the Animation exists. False otherwise.

Definition at line 151 of file animationmanager.cpp.

References m_animNameMap.

Referenced by add(), AnimationManager(), create(), and FIFE::AnimationLoader::loadAnimation().

+ Here is the caller graph for this function:

bool FIFE::AnimationManager::exists ( ResourceHandle  handle)
virtual

Checks to see if an Animation exists.

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

Parameters
handleThe handle of the Animation
Returns
True if the Animation exists. False otherwise.

Definition at line 160 of file animationmanager.cpp.

References m_animHandleMap.

void FIFE::AnimationManager::free ( const std::string &  name)
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.

Parameters
nameThe name of the Animation
See also
Animation

Definition at line 224 of file animationmanager.cpp.

References FIFE::_log, FL_WARN, m_animNameMap, and FIFE::IResource::RES_LOADED.

Referenced by AnimationManager().

+ Here is the caller graph for this function:

void FIFE::AnimationManager::free ( ResourceHandle  handle)
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.

Parameters
handleThe handle of the Animation
See also
Animation

Definition at line 237 of file animationmanager.cpp.

References FIFE::_log, FL_WARN, m_animHandleMap, and FIFE::IResource::RES_LOADED.

void FIFE::AnimationManager::freeAll ( )
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.

See also
Animation

Definition at line 249 of file animationmanager.cpp.

References FIFE::_log, FL_DBG, m_animHandleMap, and FIFE::IResource::RES_LOADED.

Referenced by AnimationManager().

+ Here is the caller graph for this function:

void FIFE::AnimationManager::freeUnreferenced ( )
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.

See also
IResource

Definition at line 265 of file animationmanager.cpp.

References FIFE::_log, FL_DBG, m_animHandleMap, and FIFE::IResource::RES_LOADED.

Referenced by AnimationManager().

+ Here is the caller graph for this function:

AnimationPtr FIFE::AnimationManager::get ( const std::string &  name)
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)

Parameters
nameThe name of the Animation
Returns
An AnimationPtr to the Animation

Definition at line 375 of file animationmanager.cpp.

References load(), m_animNameMap, and FIFE::IResource::RES_LOADED.

AnimationPtr FIFE::AnimationManager::get ( ResourceHandle  handle)
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.

Parameters
handleThe handle of the resource
Returns
A AnimationPtr to the resource

Definition at line 391 of file animationmanager.cpp.

References FIFE::_log, FL_WARN, m_animHandleMap, and FIFE::IResource::RES_LOADED.

size_t FIFE::AnimationManager::getMemoryUsed ( ) const
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.

Returns
Total memory used

Implements FIFE::IResourceManager.

Definition at line 49 of file animationmanager.cpp.

References m_animHandleMap.

Referenced by AnimationManager().

+ Here is the caller graph for this function:

AnimationPtr FIFE::AnimationManager::getPtr ( const std::string &  name)
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().

+ Here is the caller graph for this function:

AnimationPtr FIFE::AnimationManager::getPtr ( ResourceHandle  handle)
virtual

Definition at line 418 of file animationmanager.cpp.

References FIFE::_log, FL_WARN, and m_animHandleMap.

ResourceHandle FIFE::AnimationManager::getResourceHandle ( const std::string &  name)
virtual

Gets an Animation handle by name.

Returns the Animation handle associated with the name

Parameters
nameThe name of the Animation
Returns
0 if the resource name is invalid

Definition at line 429 of file animationmanager.cpp.

References FIFE::_log, FL_WARN, and m_animNameMap.

Referenced by AnimationManager().

+ Here is the caller graph for this function:

size_t FIFE::AnimationManager::getTotalResources ( ) const
virtual

Returns the number of defined resources.

Gets the total number of resources managed by the manager.

Returns
Total resources managed

Implements FIFE::IResourceManager.

Definition at line 90 of file animationmanager.cpp.

References m_animHandleMap.

Referenced by AnimationManager().

+ Here is the caller graph for this function:

size_t FIFE::AnimationManager::getTotalResourcesCreated ( ) const
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.

Returns
Total resources created

Implements FIFE::IResourceManager.

Definition at line 62 of file animationmanager.cpp.

References m_animHandleMap, and FIFE::IResource::RES_NOT_LOADED.

Referenced by AnimationManager().

+ Here is the caller graph for this function:

size_t FIFE::AnimationManager::getTotalResourcesLoaded ( ) const
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.

Returns
Total resources loaded

Implements FIFE::IResourceManager.

Definition at line 76 of file animationmanager.cpp.

References m_animHandleMap, and FIFE::IResource::RES_LOADED.

Referenced by AnimationManager().

+ Here is the caller graph for this function:

void FIFE::AnimationManager::invalidate ( const std::string &  name)
virtual

Definition at line 440 of file animationmanager.cpp.

References m_animNameMap, and FIFE::IResource::RES_LOADED.

Referenced by AnimationManager().

+ Here is the caller graph for this function:

void FIFE::AnimationManager::invalidate ( ResourceHandle  handle)
virtual

Definition at line 449 of file animationmanager.cpp.

References m_animHandleMap, and FIFE::IResource::RES_LOADED.

void FIFE::AnimationManager::invalidateAll ( )
virtual

Definition at line 458 of file animationmanager.cpp.

References m_animHandleMap, and FIFE::IResource::RES_LOADED.

Referenced by AnimationManager().

+ Here is the caller graph for this function:

AnimationPtr FIFE::AnimationManager::load ( const std::string &  name,
IResourceLoader loader = 0 
)
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.

Parameters
nameThe resource name. Typically a filename.
loaderA 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 AnimationPtr to the loaded Animation
See also
Animation
AnimationLoader
IResourceLoader

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

+ Here is the caller graph for this function:

void FIFE::AnimationManager::loadUnreferenced ( )
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().

+ Here is the caller graph for this function:

void FIFE::AnimationManager::reload ( const std::string &  name)
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.

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

+ Here is the caller graph for this function:

void FIFE::AnimationManager::reload ( ResourceHandle  handle)
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.

Parameters
handleThe handle of the resource

Definition at line 183 of file animationmanager.cpp.

References FIFE::_log, FL_WARN, m_animHandleMap, and FIFE::IResource::RES_LOADED.

void FIFE::AnimationManager::reloadAll ( )
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().

+ Here is the caller graph for this function:

void FIFE::AnimationManager::remove ( AnimationPtr resource)
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.

Parameters
resourceA AnimationPtr to the Animation to be removed from the manager
Note
This is useful if you want to remove ownership of a resource from the manager
See also
Animation

Definition at line 280 of file animationmanager.cpp.

References FIFE::_log, FL_WARN, FIFE::IResource::getHandle(), FIFE::IResource::getName(), m_animHandleMap, and m_animNameMap.

void FIFE::AnimationManager::remove ( const std::string &  name)
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.

Parameters
nameThe name of the Animation
See also
Animation

Definition at line 297 of file animationmanager.cpp.

References FIFE::_log, FL_WARN, m_animHandleMap, and m_animNameMap.

void FIFE::AnimationManager::remove ( ResourceHandle  handle)
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.

Parameters
handleThe handle of the Animation
See also
Animation

Definition at line 319 of file animationmanager.cpp.

References FIFE::_log, FL_WARN, m_animHandleMap, and m_animNameMap.

void FIFE::AnimationManager::removeAll ( )
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.

See also
Animation

Definition at line 342 of file animationmanager.cpp.

References FIFE::_log, FL_DBG, m_animHandleMap, and m_animNameMap.

Referenced by AnimationManager().

+ Here is the caller graph for this function:

void FIFE::AnimationManager::removeUnreferenced ( )
virtual

Removes all unreferenced Animations.

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

See also
Animation

Definition at line 354 of file animationmanager.cpp.

References FIFE::_log, FL_DBG, and m_animHandleMap.

Referenced by AnimationManager().

+ Here is the caller graph for this function:

Member Data Documentation

AnimationNameMap FIFE::AnimationManager::m_animNameMap
private

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