FIFE  6e1afdbeda11afe9ac53e6023a4be96ef88f1dc6
soundclipmanager.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2017 by the FIFE team *
3  * http://www.fifengine.net *
4  * This file is part of FIFE. *
5  * *
6  * FIFE is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Lesser General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2.1 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20  ***************************************************************************/
21 
22 #ifndef FIFE_SOUNDCLIP_MANAGER_H
23 #define FIFE_SOUNDCLIP_MANAGER_H
24 
25 // Standard C++ library includes
26 #include <map>
27 #include <string>
28 #include <vector>
29 
30 // 3rd party library includes
31 
32 // FIFE includes
33 // These includes are split up in two parts, separated by one empty line
34 // First block: files included from the FIFE root src directory
35 // Second block: files included from the same folder
36 #include "util/base/singleton.h"
37 #include "util/resource/resource.h"
39 
40 #include "soundclip.h"
41 
42 namespace FIFE {
43 
54  class SoundClipManager : public IResourceManager, public DynamicSingleton<SoundClipManager> {
55  public:
56 
60 
63  virtual ~SoundClipManager();
64 
65  virtual size_t getMemoryUsed() const;
66  virtual size_t getTotalResourcesCreated() const;
67  virtual size_t getTotalResourcesLoaded() const;
68  virtual size_t getTotalResources() const;
69 
83  virtual SoundClipPtr create(IResourceLoader* loader = 0);
84 
99  virtual SoundClipPtr create(const std::string& name, IResourceLoader* loader = 0);
100 
119  virtual SoundClipPtr load(const std::string& name, IResourceLoader* loader = 0);
120 
133  virtual SoundClipPtr add(SoundClip* res);
134 
144  virtual bool exists(const std::string& name);
145 
155  virtual bool exists(ResourceHandle handle);
156 
167  virtual void reload(const std::string& name);
168 
179  virtual void reload(ResourceHandle handle);
180 
190  virtual void reloadAll();
191 
198  virtual void loadUnreferenced();
199 
213  virtual void free(const std::string& name);
214 
228  virtual void free(ResourceHandle handle);
229 
239  virtual void freeAll();
240 
250  virtual void freeUnreferenced();
251 
268  virtual void remove(SoundClipPtr& resource);
269 
282  virtual void remove(const std::string& name);
283 
296  virtual void remove(ResourceHandle handle);
297 
307  virtual void removeAll();
308 
317  virtual void removeUnreferenced();
318 
329  virtual SoundClipPtr get(const std::string& name);
330 
343  virtual SoundClipPtr get(ResourceHandle handle);
344 
353  virtual ResourceHandle getResourceHandle(const std::string& name);
354 
355  private:
356  typedef std::map< ResourceHandle, SoundClipPtr > SoundClipHandleMap;
357  typedef std::map< ResourceHandle, SoundClipPtr >::iterator SoundClipHandleMapIterator;
358  typedef std::map< ResourceHandle, SoundClipPtr >::const_iterator SoundClipHandleMapConstIterator;
359  typedef std::pair< ResourceHandle, SoundClipPtr > SoundClipHandleMapPair;
360 
361  typedef std::map< std::string, SoundClipPtr > SoundClipNameMap;
362  typedef std::map< std::string, SoundClipPtr >::iterator SoundClipNameMapIterator;
363  typedef std::map< std::string, SoundClipPtr >::const_iterator SoundClipNameMapConstIterator;
364  typedef std::pair< std::string, SoundClipPtr > SoundClipNameMapPair;
365 
366  SoundClipHandleMap m_sclipHandleMap;
367 
368  SoundClipNameMap m_sclipNameMap;
369  };
370 
371 } //FIFE
372 
373 #endif //FIFE_SOUNDCLIP_MANAGER_H
virtual ~SoundClipManager()
Destructor.
std::pair< ResourceHandle, SoundClipPtr > SoundClipHandleMapPair
virtual SoundClipPtr load(const std::string &name, IResourceLoader *loader=0)
Creates a blank resource and loads it from disk.
virtual void freeAll()
Frees all SoundClips.
virtual void free(const std::string &name)
Frees a SoundClip from memory.
std::map< std::string, SoundClipPtr > SoundClipNameMap
virtual size_t getTotalResourcesCreated() const
Returns the number of unloaded resources.
std::size_t ResourceHandle
Definition: resource.h:38
virtual size_t getTotalResources() const
Returns the number of defined resources.
SoundClipManager.
std::map< std::string, SoundClipPtr >::iterator SoundClipNameMapIterator
virtual ResourceHandle getResourceHandle(const std::string &name)
Gets a SoundClip handle by name.
SoundClipManager()
Default constructor.
std::map< ResourceHandle, SoundClipPtr >::iterator SoundClipHandleMapIterator
virtual void removeAll()
Removes all SoundClips from the manager.
virtual SoundClipPtr create(IResourceLoader *loader=0)
Creates a blank SoundClip but does not load it immediately.
Another Singleton.
Definition: singleton.h:82
virtual void loadUnreferenced()
Loads all unreferenced SoundClips.
SoundClipHandleMap m_sclipHandleMap
virtual void reload(const std::string &name)
Reloads a SoundClip.
virtual bool exists(const std::string &name)
Checks to see if a SoundClip exists.
virtual SoundClipPtr add(SoundClip *res)
Add an Image to the manager.
virtual size_t getMemoryUsed() const
Gets the total amount of memory used by resources.
std::map< ResourceHandle, SoundClipPtr >::const_iterator SoundClipHandleMapConstIterator
std::pair< std::string, SoundClipPtr > SoundClipNameMapPair
std::map< std::string, SoundClipPtr >::const_iterator SoundClipNameMapConstIterator
virtual void reloadAll()
Reloads all SoundClips.
SoundClipNameMap m_sclipNameMap
virtual size_t getTotalResourcesLoaded() const
Returns the number of loaded resources.
virtual void removeUnreferenced()
Removes all unreferenced SoundClips.
virtual void freeUnreferenced()
Frees all unreferenced SoundClip.
std::map< ResourceHandle, SoundClipPtr > SoundClipHandleMap
Class to handle the buffers of an audio file.
Definition: soundclip.h:58
IResourceManager.