FIFE
be64c707dea6b3250bd4355bf5c825d25920087d
|
#include <soundclipmanager.h>
Public Member Functions | |
SoundClipManager () | |
Default constructor. More... | |
virtual | ~SoundClipManager () |
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 SoundClipPtr | create (IResourceLoader *loader=0) |
Creates a blank SoundClip but does not load it immediately. More... | |
virtual SoundClipPtr | create (const std::string &name, IResourceLoader *loader=0) |
Creates a blank SoundClip but does not load it immediately. More... | |
virtual SoundClipPtr | load (const std::string &name, IResourceLoader *loader=0) |
Creates a blank resource and loads it from disk. More... | |
virtual SoundClipPtr | add (SoundClip *res) |
Add an Image to the manager. More... | |
virtual bool | exists (const std::string &name) |
Checks to see if a SoundClip exists. More... | |
virtual bool | exists (ResourceHandle handle) |
Checks to see if a SoundClip exists. More... | |
virtual void | reload (const std::string &name) |
Reloads a SoundClip. More... | |
virtual void | reload (ResourceHandle handle) |
Reloads a resource. More... | |
virtual void | reloadAll () |
Reloads all SoundClips. More... | |
virtual void | loadUnreferenced () |
Loads all unreferenced SoundClips. More... | |
virtual void | free (const std::string &name) |
Frees a SoundClip from memory. More... | |
virtual void | free (ResourceHandle handle) |
Frees a SoundClip from memory. More... | |
virtual void | freeAll () |
Frees all SoundClips. More... | |
virtual void | freeUnreferenced () |
Frees all unreferenced SoundClip. More... | |
virtual void | remove (SoundClipPtr &resource) |
Removes a SoundClip from the manager. More... | |
virtual void | remove (const std::string &name) |
Removes a SoundClip from the manager. More... | |
virtual void | remove (ResourceHandle handle) |
Removes a SoundClip from the manager. More... | |
virtual void | removeAll () |
Removes all SoundClips from the manager. More... | |
virtual void | removeUnreferenced () |
Removes all unreferenced SoundClips. More... | |
virtual SoundClipPtr | get (const std::string &name) |
Gets a shared pointer to the SoundClip. More... | |
virtual SoundClipPtr | get (ResourceHandle handle) |
Gets a shared pointer to the SoundClip. More... | |
virtual ResourceHandle | getResourceHandle (const std::string &name) |
Gets a SoundClip handle by name. More... | |
Public Member Functions inherited from FIFE::IResourceManager | |
IResourceManager () | |
Default constructor. More... | |
virtual | ~IResourceManager () |
destructor More... | |
Public Member Functions inherited from FIFE::DynamicSingleton< SoundClipManager > | |
DynamicSingleton () | |
virtual | ~DynamicSingleton () |
Private Types | |
typedef std::map< ResourceHandle, SoundClipPtr > | SoundClipHandleMap |
typedef std::map< ResourceHandle, SoundClipPtr >::iterator | SoundClipHandleMapIterator |
typedef std::map< ResourceHandle, SoundClipPtr >::const_iterator | SoundClipHandleMapConstIterator |
typedef std::pair< ResourceHandle, SoundClipPtr > | SoundClipHandleMapPair |
typedef std::map< std::string, SoundClipPtr > | SoundClipNameMap |
typedef std::map< std::string, SoundClipPtr >::iterator | SoundClipNameMapIterator |
typedef std::map< std::string, SoundClipPtr >::const_iterator | SoundClipNameMapConstIterator |
typedef std::pair< std::string, SoundClipPtr > | SoundClipNameMapPair |
Private Attributes | |
SoundClipHandleMap | m_sclipHandleMap |
SoundClipNameMap | m_sclipNameMap |
Additional Inherited Members | |
Static Public Member Functions inherited from FIFE::DynamicSingleton< SoundClipManager > | |
static SoundClipManager * | instance () |
An interface for managing images.
Definition at line 54 of file soundclipmanager.h.
|
private |
Definition at line 356 of file soundclipmanager.h.
|
private |
Definition at line 358 of file soundclipmanager.h.
|
private |
Definition at line 357 of file soundclipmanager.h.
|
private |
Definition at line 359 of file soundclipmanager.h.
|
private |
Definition at line 361 of file soundclipmanager.h.
|
private |
Definition at line 363 of file soundclipmanager.h.
|
private |
Definition at line 362 of file soundclipmanager.h.
|
private |
Definition at line 364 of file soundclipmanager.h.
|
inline |
Default constructor.
Definition at line 59 of file soundclipmanager.h.
References add(), create(), exists(), free(), freeAll(), freeUnreferenced(), getMemoryUsed(), getResourceHandle(), getTotalResources(), getTotalResourcesCreated(), getTotalResourcesLoaded(), load(), loadUnreferenced(), reload(), reloadAll(), removeAll(), removeUnreferenced(), and ~SoundClipManager().
|
virtual |
Destructor.
Definition at line 40 of file soundclipmanager.cpp.
Referenced by SoundClipManager().
|
virtual |
Add an Image to the manager.
This function will create a SoundClipPtr and add the SoundClip to the manager. The manager assumes ownership of the SoundClip so DO NOT delete it.
res | A pointer to the SoundClip |
Definition at line 127 of file soundclipmanager.cpp.
References FIFE::_log, exists(), FL_WARN, FIFE::IResource::getHandle(), FIFE::IResource::getName(), m_sclipHandleMap, and m_sclipNameMap.
Referenced by create(), and SoundClipManager().
|
virtual |
Creates a blank SoundClip 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 89 of file soundclipmanager.cpp.
References add().
Referenced by load(), and SoundClipManager().
|
virtual |
Creates a blank SoundClip 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 94 of file soundclipmanager.cpp.
References FIFE::_log, add(), exists(), and FL_WARN.
|
virtual |
Checks to see if a SoundClip exists.
This function will search the manager for SoundClips that match the parameter
name | The name of the SoundClip |
Definition at line 146 of file soundclipmanager.cpp.
References m_sclipNameMap.
Referenced by add(), create(), and SoundClipManager().
|
virtual |
Checks to see if a SoundClip exists.
This function will search the manager for SoundClips that match the parameter
handle | The handle of the SoundClip |
Definition at line 155 of file soundclipmanager.cpp.
References m_sclipHandleMap.
|
virtual |
Frees a SoundClip from memory.
The SoundClip is not deleted but it's data is freed. This calls the SoundClip::free() function and it is up to the resource to properly free it's memory. The manager keeps a reference to the SoundClip in case its required in the future.
name | The name of the SoundClip |
Definition at line 219 of file soundclipmanager.cpp.
References FIFE::_log, FL_WARN, m_sclipNameMap, and FIFE::IResource::RES_LOADED.
Referenced by SoundClipManager().
|
virtual |
Frees a SoundClip from memory.
The SoundClip is not deleted but it's data is freed. This calls the SoundClip::free() function and it is up to the resource to properly free it's memory. The manager keeps a reference to the SoundClip in case its required in the future.
handle | The handle of the SoundClip |
Definition at line 232 of file soundclipmanager.cpp.
References FIFE::_log, FL_WARN, m_sclipHandleMap, and FIFE::IResource::RES_LOADED.
|
virtual |
Frees all SoundClips.
This calls the SoundClip::free() function for every Image the manager is managing. It does not remove them from the manager.
Definition at line 244 of file soundclipmanager.cpp.
References FIFE::_log, FL_DBG, m_sclipHandleMap, and FIFE::IResource::RES_LOADED.
Referenced by SoundClipManager().
|
virtual |
Frees all unreferenced SoundClip.
This calls the SoundClip::free() function for SoundClips that have no external references to them. It does not remove them from the manager.
Definition at line 260 of file soundclipmanager.cpp.
References FIFE::_log, FL_DBG, m_sclipHandleMap, and FIFE::IResource::RES_LOADED.
Referenced by SoundClipManager().
|
virtual |
Gets a shared pointer to the SoundClip.
If the SoundClip is not defined it will attempt to create and load the SoundClip based on the name (it assumes the name is a filename)
name | The name of the SoundClip |
Definition at line 364 of file soundclipmanager.cpp.
References load(), m_sclipNameMap, and FIFE::IResource::RES_LOADED.
Referenced by FIFE::SoundEmitter::setSoundClip().
|
virtual |
Gets a shared pointer to the SoundClip.
If the resource is not defined it returns an empty (or invalid) SoundClipPtr and makes an entry in the log.
handle | The handle of the resource |
Definition at line 380 of file soundclipmanager.cpp.
References FIFE::_log, FL_WARN, m_sclipHandleMap, 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 44 of file soundclipmanager.cpp.
References m_sclipHandleMap.
Referenced by SoundClipManager().
|
virtual |
Gets a SoundClip handle by name.
Returns the SoundClip handle associated with the name
name | The name of the SoundClip |
Definition at line 395 of file soundclipmanager.cpp.
References FIFE::_log, FL_WARN, and m_sclipNameMap.
Referenced by SoundClipManager().
|
virtual |
Returns the number of defined resources.
Gets the total number of resources managed by the manager.
Implements FIFE::IResourceManager.
Definition at line 85 of file soundclipmanager.cpp.
References m_sclipHandleMap.
Referenced by SoundClipManager().
|
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 57 of file soundclipmanager.cpp.
References m_sclipHandleMap, and FIFE::IResource::RES_NOT_LOADED.
Referenced by SoundClipManager().
|
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 71 of file soundclipmanager.cpp.
References m_sclipHandleMap, and FIFE::IResource::RES_LOADED.
Referenced by SoundClipManager().
|
virtual |
Creates a blank resource and loads it from disk.
This function will create the SoundClip if necessary and load the clip from disk. If the SoundClip is not defined it will call SoundClipManager::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 104 of file soundclipmanager.cpp.
References FIFE::_log, create(), FL_WARN, FIFE::IResource::getState(), FIFE::SoundClip::load(), m_sclipNameMap, and FIFE::IResource::RES_NOT_LOADED.
Referenced by get(), and SoundClipManager().
|
virtual |
Loads all unreferenced SoundClips.
All SoundClips that have no external references will be loaded into memory.
Definition at line 205 of file soundclipmanager.cpp.
References FIFE::_log, FL_DBG, m_sclipHandleMap, and FIFE::IResource::RES_LOADED.
Referenced by SoundClipManager().
|
virtual |
Reloads a SoundClip.
This function will reload a SoundClip if it is managed by the manager. If not it creates an entry in the log specifying that the SoundClip could not be found. It will load the SoundClip if it is not already loaded.
name | The name of the resource |
Definition at line 164 of file soundclipmanager.cpp.
References FIFE::_log, FL_WARN, m_sclipNameMap, and FIFE::IResource::RES_LOADED.
Referenced by SoundClipManager().
|
virtual |
Reloads a resource.
This function will reload a SoundClip if it is managed by the manager. If not it creates an entry in the log specifying that the SoundClip could not be found. It will load the SoundClip if it is not already loaded.
handle | The handle of the resource |
Definition at line 178 of file soundclipmanager.cpp.
References FIFE::_log, FL_WARN, m_sclipHandleMap, and FIFE::IResource::RES_LOADED.
|
virtual |
Reloads all SoundClips.
This function will reload all SoundClips managed by the manager. It will load a SoundClip if it is not already loaded.
Definition at line 193 of file soundclipmanager.cpp.
References m_sclipHandleMap, and FIFE::IResource::RES_LOADED.
Referenced by SoundClipManager().
|
virtual |
Removes a SoundClip from the manager.
This removes all references to the SoundClip from the manager. It does not however guarantee that the resource's destructor is called. If the client has any left over references to the resource it will not be freed.
resource | A SoundClipPtr to the image to be removed from the manager |
Definition at line 275 of file soundclipmanager.cpp.
References FIFE::_log, FL_WARN, FIFE::IResource::getHandle(), FIFE::IResource::getName(), m_sclipHandleMap, and m_sclipNameMap.
|
virtual |
Removes a SoundClip from the manager.
This removes all references to the SoundClip from the manager. It does not however guarantee that the resource's destructor is called. If the client has any left over references to the resource it will not be freed.
name | The name of the SoundClip |
Definition at line 292 of file soundclipmanager.cpp.
References FIFE::_log, FL_WARN, m_sclipHandleMap, and m_sclipNameMap.
|
virtual |
Removes a SoundClip from the manager.
This removes all references to the SoundClip from the manager. It does not however guarantee that the resource's destructor is called. If the client has any left over references to the resource it will not be freed.
handle | The handle of the SoundClip |
Definition at line 314 of file soundclipmanager.cpp.
References FIFE::_log, FL_WARN, m_sclipHandleMap, and m_sclipNameMap.
|
virtual |
Removes all SoundClips from the manager.
This effectively removes all references to all SoundClips from the manager. If there are left over shared pointers to any resources they will not be deleted.
Definition at line 337 of file soundclipmanager.cpp.
References FIFE::_log, FL_DBG, m_sclipHandleMap, and m_sclipNameMap.
Referenced by SoundClipManager().
|
virtual |
Removes all unreferenced SoundClips.
This effectively removes all SoundClips that dont have an external reference. The resources will be deleted.
Definition at line 349 of file soundclipmanager.cpp.
References FIFE::_log, FL_DBG, and m_sclipHandleMap.
Referenced by SoundClipManager().
|
private |
Definition at line 366 of file soundclipmanager.h.
Referenced by add(), exists(), free(), freeAll(), freeUnreferenced(), get(), getMemoryUsed(), getTotalResources(), getTotalResourcesCreated(), getTotalResourcesLoaded(), loadUnreferenced(), reload(), reloadAll(), remove(), removeAll(), and removeUnreferenced().
|
private |
Definition at line 368 of file soundclipmanager.h.
Referenced by add(), exists(), free(), get(), getResourceHandle(), load(), reload(), remove(), and removeAll().