FIFE  be64c707dea6b3250bd4355bf5c825d25920087d
FIFE::SoundClipManager Class Reference

SoundClipManager. More...

#include <soundclipmanager.h>

+ Inheritance diagram for FIFE::SoundClipManager:
+ Collaboration diagram for FIFE::SoundClipManager:

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, SoundClipPtrSoundClipHandleMap
 
typedef std::map< ResourceHandle, SoundClipPtr >::iterator SoundClipHandleMapIterator
 
typedef std::map< ResourceHandle, SoundClipPtr >::const_iterator SoundClipHandleMapConstIterator
 
typedef std::pair< ResourceHandle, SoundClipPtrSoundClipHandleMapPair
 
typedef std::map< std::string, SoundClipPtrSoundClipNameMap
 
typedef std::map< std::string, SoundClipPtr >::iterator SoundClipNameMapIterator
 
typedef std::map< std::string, SoundClipPtr >::const_iterator SoundClipNameMapConstIterator
 
typedef std::pair< std::string, SoundClipPtrSoundClipNameMapPair
 

Private Attributes

SoundClipHandleMap m_sclipHandleMap
 
SoundClipNameMap m_sclipNameMap
 

Additional Inherited Members

- Static Public Member Functions inherited from FIFE::DynamicSingleton< SoundClipManager >
static SoundClipManagerinstance ()
 

Detailed Description

SoundClipManager.

An interface for managing images.

See also
IResource
IResourceLoader
IResourceManager

Definition at line 54 of file soundclipmanager.h.

Member Typedef Documentation

◆ SoundClipHandleMap

Definition at line 356 of file soundclipmanager.h.

◆ SoundClipHandleMapConstIterator

Definition at line 358 of file soundclipmanager.h.

◆ SoundClipHandleMapIterator

Definition at line 357 of file soundclipmanager.h.

◆ SoundClipHandleMapPair

Definition at line 359 of file soundclipmanager.h.

◆ SoundClipNameMap

typedef std::map< std::string, SoundClipPtr > FIFE::SoundClipManager::SoundClipNameMap
private

Definition at line 361 of file soundclipmanager.h.

◆ SoundClipNameMapConstIterator

typedef std::map< std::string, SoundClipPtr >::const_iterator FIFE::SoundClipManager::SoundClipNameMapConstIterator
private

Definition at line 363 of file soundclipmanager.h.

◆ SoundClipNameMapIterator

typedef std::map< std::string, SoundClipPtr >::iterator FIFE::SoundClipManager::SoundClipNameMapIterator
private

Definition at line 362 of file soundclipmanager.h.

◆ SoundClipNameMapPair

typedef std::pair< std::string, SoundClipPtr > FIFE::SoundClipManager::SoundClipNameMapPair
private

Definition at line 364 of file soundclipmanager.h.

Constructor & Destructor Documentation

◆ SoundClipManager()

◆ ~SoundClipManager()

FIFE::SoundClipManager::~SoundClipManager ( )
virtual

Destructor.

Definition at line 40 of file soundclipmanager.cpp.

Referenced by SoundClipManager().

+ Here is the caller graph for this function:

Member Function Documentation

◆ add()

SoundClipPtr FIFE::SoundClipManager::add ( SoundClip res)
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.

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

+ Here is the caller graph for this function:

◆ create() [1/2]

SoundClipPtr FIFE::SoundClipManager::create ( IResourceLoader loader = 0)
virtual

Creates a blank SoundClip 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
A SoundClipPtr to the newly created SoundClip
See also
SoundClip
OggLoader
IResourceLoader

Definition at line 89 of file soundclipmanager.cpp.

References add().

Referenced by load(), and SoundClipManager().

+ Here is the caller graph for this function:

◆ create() [2/2]

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

Creates a blank SoundClip 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
A SoundClipPtr to the newly created SoundClip
See also
SoundClip
OggLoader
IResourceLoader

Definition at line 94 of file soundclipmanager.cpp.

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

◆ exists() [1/2]

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

Checks to see if a SoundClip exists.

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

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

Definition at line 146 of file soundclipmanager.cpp.

References m_sclipNameMap.

Referenced by add(), create(), and SoundClipManager().

+ Here is the caller graph for this function:

◆ exists() [2/2]

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

Checks to see if a SoundClip exists.

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

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

Definition at line 155 of file soundclipmanager.cpp.

References m_sclipHandleMap.

◆ free() [1/2]

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

Parameters
nameThe name of the SoundClip
See also
SoundClip

Definition at line 219 of file soundclipmanager.cpp.

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

Referenced by SoundClipManager().

+ Here is the caller graph for this function:

◆ free() [2/2]

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

Parameters
handleThe handle of the SoundClip
See also
SoundClip

Definition at line 232 of file soundclipmanager.cpp.

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

◆ freeAll()

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

See also
SoundClip

Definition at line 244 of file soundclipmanager.cpp.

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

Referenced by SoundClipManager().

+ Here is the caller graph for this function:

◆ freeUnreferenced()

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

See also
SoundClip

Definition at line 260 of file soundclipmanager.cpp.

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

Referenced by SoundClipManager().

+ Here is the caller graph for this function:

◆ get() [1/2]

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

Parameters
nameThe name of the SoundClip
Returns
A SoundClipPtr to the SoundClip

Definition at line 364 of file soundclipmanager.cpp.

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

Referenced by FIFE::SoundEmitter::setSoundClip().

+ Here is the caller graph for this function:

◆ get() [2/2]

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

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

Definition at line 380 of file soundclipmanager.cpp.

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

◆ getMemoryUsed()

size_t FIFE::SoundClipManager::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 44 of file soundclipmanager.cpp.

References m_sclipHandleMap.

Referenced by SoundClipManager().

+ Here is the caller graph for this function:

◆ getResourceHandle()

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

Gets a SoundClip handle by name.

Returns the SoundClip handle associated with the name

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

Definition at line 395 of file soundclipmanager.cpp.

References FIFE::_log, FL_WARN, and m_sclipNameMap.

Referenced by SoundClipManager().

+ Here is the caller graph for this function:

◆ getTotalResources()

size_t FIFE::SoundClipManager::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 85 of file soundclipmanager.cpp.

References m_sclipHandleMap.

Referenced by SoundClipManager().

+ Here is the caller graph for this function:

◆ getTotalResourcesCreated()

size_t FIFE::SoundClipManager::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 57 of file soundclipmanager.cpp.

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

Referenced by SoundClipManager().

+ Here is the caller graph for this function:

◆ getTotalResourcesLoaded()

size_t FIFE::SoundClipManager::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 71 of file soundclipmanager.cpp.

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

Referenced by SoundClipManager().

+ Here is the caller graph for this function:

◆ load()

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

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 SoundClipPtr to the loaded SoundClip
See also
SoundClip
OggLoader
IResourceLoader

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

+ Here is the caller graph for this function:

◆ loadUnreferenced()

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

+ Here is the caller graph for this function:

◆ reload() [1/2]

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

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

+ Here is the caller graph for this function:

◆ reload() [2/2]

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

Parameters
handleThe handle of the resource

Definition at line 178 of file soundclipmanager.cpp.

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

◆ reloadAll()

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

+ Here is the caller graph for this function:

◆ remove() [1/3]

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

Parameters
resourceA SoundClipPtr 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
SoundClip

Definition at line 275 of file soundclipmanager.cpp.

References FIFE::_log, FL_WARN, FIFE::IResource::getHandle(), FIFE::IResource::getName(), m_sclipHandleMap, and m_sclipNameMap.

◆ remove() [2/3]

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

Parameters
nameThe name of the SoundClip
See also
SoundClip

Definition at line 292 of file soundclipmanager.cpp.

References FIFE::_log, FL_WARN, m_sclipHandleMap, and m_sclipNameMap.

◆ remove() [3/3]

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

Parameters
handleThe handle of the SoundClip
See also
SoundClip

Definition at line 314 of file soundclipmanager.cpp.

References FIFE::_log, FL_WARN, m_sclipHandleMap, and m_sclipNameMap.

◆ removeAll()

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

See also
SoundClip

Definition at line 337 of file soundclipmanager.cpp.

References FIFE::_log, FL_DBG, m_sclipHandleMap, and m_sclipNameMap.

Referenced by SoundClipManager().

+ Here is the caller graph for this function:

◆ removeUnreferenced()

void FIFE::SoundClipManager::removeUnreferenced ( )
virtual

Removes all unreferenced SoundClips.

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

See also
SoundClip

Definition at line 349 of file soundclipmanager.cpp.

References FIFE::_log, FL_DBG, and m_sclipHandleMap.

Referenced by SoundClipManager().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_sclipHandleMap

◆ m_sclipNameMap

SoundClipNameMap FIFE::SoundClipManager::m_sclipNameMap
private

Definition at line 368 of file soundclipmanager.h.

Referenced by add(), exists(), free(), get(), getResourceHandle(), load(), reload(), remove(), and removeAll().


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