FIFE  2008.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
FIFE::SoundClipManager Class Reference

#include <soundclipmanager.h>

Inheritance diagram for FIFE::SoundClipManager:
Inheritance graph
Collaboration diagram for FIFE::SoundClipManager:
Collaboration graph

Public Member Functions

 SoundClipManager ()
 
virtual ~SoundClipManager ()
 
virtual size_t getMemoryUsed () const
 
virtual size_t getTotalResourcesCreated () const
 
virtual size_t getTotalResourcesLoaded () const
 
virtual size_t getTotalResources () const
 
virtual SoundClipPtr create (IResourceLoader *loader=0)
 
virtual SoundClipPtr create (const std::string &name, IResourceLoader *loader=0)
 
virtual SoundClipPtr load (const std::string &name, IResourceLoader *loader=0)
 
virtual SoundClipPtr add (SoundClip *res)
 
virtual bool exists (const std::string &name)
 
virtual bool exists (ResourceHandle handle)
 
virtual void reload (const std::string &name)
 
virtual void reload (ResourceHandle handle)
 
virtual void reloadAll ()
 
virtual void loadUnreferenced ()
 
virtual void free (const std::string &name)
 
virtual void free (ResourceHandle handle)
 
virtual void freeAll ()
 
virtual void freeUnreferenced ()
 
virtual void remove (SoundClipPtr &resource)
 
virtual void remove (const std::string &name)
 
virtual void remove (ResourceHandle handle)
 
virtual void removeAll ()
 
virtual void removeUnreferenced ()
 
virtual SoundClipPtr get (const std::string &name)
 
virtual SoundClipPtr get (ResourceHandle handle)
 
virtual ResourceHandle getResourceHandle (const std::string &name)
 
- Public Member Functions inherited from FIFE::IResourceManager
 IResourceManager ()
 

Detailed Description

SoundClipManager

An interface for managing images.

See also
IResource
IResourceLoader
IResourceManager

Definition at line 54 of file soundclipmanager.h.

Constructor & Destructor Documentation

FIFE::SoundClipManager::SoundClipManager ( )
inline

Default constructor.

Definition at line 59 of file soundclipmanager.h.

FIFE::SoundClipManager::~SoundClipManager ( )
virtual

Destructor.

Definition at line 40 of file soundclipmanager.cpp.

Member Function Documentation

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

Referenced by create().

Here is the caller graph for this function:

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

Definition at line 89 of file soundclipmanager.cpp.

References add().

Referenced by load().

Here is the caller graph for this function:

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

Definition at line 94 of file soundclipmanager.cpp.

References add(), and exists().

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.

Referenced by add(), and create().

Here is the caller graph for this function:

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

Checks to see if an 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.

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.

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.

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.

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.

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
An SoundClipPtr to the SoundClip

Definition at line 364 of file soundclipmanager.cpp.

References load().

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
Todo:
This should throw an exception instead of an empty SoundClipPtr

Definition at line 380 of file soundclipmanager.cpp.

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.

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.

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.

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.

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.

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

Referenced by get().

Here is the caller graph for this function:

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.

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.

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.

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.

Todo:
It might be beneficial to supply a parameter to only reload resources that are already loaded

Definition at line 193 of file soundclipmanager.cpp.

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.

void FIFE::SoundClipManager::remove ( const std::string &  name)
virtual

Removes an 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.

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.

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.

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.


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