soundclipmanager.h

00001 /***************************************************************************
00002  *   Copyright (C) 2005-2008 by the FIFE team                              *
00003  *   http://www.fifengine.de                                               *
00004  *   This file is part of FIFE.                                            *
00005  *                                                                         *
00006  *   FIFE is free software; you can redistribute it and/or                 *
00007  *   modify it under the terms of the GNU Lesser General Public            *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2.1 of the License, or (at your option) any later version.    *
00010  *                                                                         *
00011  *   This library is distributed in the hope that it will be useful,       *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00014  *   Lesser General Public License for more details.                       *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Lesser General Public      *
00017  *   License along with this library; if not, write to the                 *
00018  *   Free Software Foundation, Inc.,                                       *
00019  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
00020  ***************************************************************************/
00021 
00022 #ifndef FIFE_SOUNDCLIP_MANAGER_H
00023 #define FIFE_SOUNDCLIP_MANAGER_H
00024 
00025 // Standard C++ library includes
00026 #include <map>
00027 #include <string>
00028 #include <vector>
00029 
00030 // 3rd party library includes
00031 
00032 // FIFE includes
00033 // These includes are split up in two parts, separated by one empty line
00034 // First block: files included from the FIFE root src directory
00035 // Second block: files included from the same folder
00036 #include "util/base/singleton.h"
00037 #include "util/resource/resource.h"
00038 #include "util/resource/resourcemanager.h"
00039 
00040 #include "soundclip.h"
00041 
00042 namespace FIFE {
00043 
00054     class SoundClipManager : public IResourceManager, public DynamicSingleton<SoundClipManager> {
00055     public:
00056 
00059         SoundClipManager() : IResourceManager() { }
00060 
00063         virtual ~SoundClipManager();
00064 
00065         virtual size_t getMemoryUsed() const;
00066         virtual size_t getTotalResourcesCreated() const;
00067         virtual size_t getTotalResourcesLoaded() const;
00068         virtual size_t getTotalResources() const;
00069 
00083         virtual SoundClipPtr create(IResourceLoader* loader = 0);
00084 
00099         virtual SoundClipPtr create(const std::string& name, IResourceLoader* loader = 0);
00100 
00119         virtual SoundClipPtr load(const std::string& name, IResourceLoader* loader = 0);
00120 
00133         virtual SoundClipPtr add(SoundClip* res);
00134 
00144         virtual bool exists(const std::string& name);
00145 
00155         virtual bool exists(ResourceHandle handle);
00156 
00167         virtual void reload(const std::string& name);
00168 
00179         virtual void reload(ResourceHandle handle);
00180 
00190         virtual void reloadAll();
00191 
00198         virtual void loadUnreferenced();
00199 
00213         virtual void free(const std::string& name);
00214 
00228         virtual void free(ResourceHandle handle);
00229 
00239         virtual void freeAll();
00240 
00250         virtual void freeUnreferenced();
00251 
00268         virtual void remove(SoundClipPtr& resource);
00269 
00282         virtual void remove(const std::string& name);
00283 
00296         virtual void remove(ResourceHandle handle);
00297 
00307         virtual void removeAll();
00308 
00317         virtual void removeUnreferenced();
00318 
00329         virtual SoundClipPtr get(const std::string& name);
00330 
00343         virtual SoundClipPtr get(ResourceHandle handle);
00344 
00353         virtual ResourceHandle getResourceHandle(const std::string& name);
00354 
00355     private:
00356         typedef std::map< ResourceHandle, SoundClipPtr > SoundClipHandleMap;
00357         typedef std::map< ResourceHandle, SoundClipPtr >::iterator SoundClipHandleMapIterator;
00358         typedef std::map< ResourceHandle, SoundClipPtr >::const_iterator SoundClipHandleMapConstIterator;
00359         typedef std::pair< ResourceHandle, SoundClipPtr > SoundClipHandleMapPair;
00360 
00361         typedef std::map< std::string, SoundClipPtr > SoundClipNameMap;
00362         typedef std::map< std::string, SoundClipPtr >::iterator SoundClipNameMapIterator;
00363         typedef std::map< std::string, SoundClipPtr >::const_iterator SoundClipNameMapConstIterator;
00364         typedef std::pair< std::string, SoundClipPtr > SoundClipNameMapPair;
00365 
00366         SoundClipHandleMap m_sclipHandleMap;
00367 
00368         SoundClipNameMap m_sclipNameMap;
00369     };
00370 
00371 } //FIFE
00372 
00373 #endif //FIFE_SOUNDCLIP_MANAGER_H