# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

sound_bank.h

Go to the documentation of this file.
00001 
00007 /* Copyright, 2001 Nevrax Ltd.
00008  *
00009  * This file is part of NEVRAX NEL.
00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2, or (at your option)
00013  * any later version.
00014 
00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018  * General Public License for more details.
00019 
00020  * You should have received a copy of the GNU General Public License
00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00023  * MA 02111-1307, USA.
00024  */
00025 
00026 #ifndef NL_SOUND_BANK_H
00027 #define NL_SOUND_BANK_H
00028 
00029 #include "nel/misc/types_nl.h"
00030 #include <string>
00031 #include <hash_map>
00032 
00033 namespace NLSOUND {
00034 
00035 
00036 class CSound;
00037 class CSimpleSound;
00038 
00039 
00040 
00048 class CSoundBank
00049 {
00050 public:
00051 
00052         void registerBufferAssoc(CSimpleSound *sound, IBuffer *buffer);
00053         void unregisterBufferAssoc(CSimpleSound *sound, IBuffer *buffer);
00054 
00058         void    bufferUnloaded(const std::string bufferName);
00062         void    bufferLoaded(const std::string bufferName, IBuffer *buffer);
00063 
00065         virtual ~CSoundBank();
00066 
00068         void                            load();
00069 
00071         void                            unload();
00072 
00074         bool                            isLoaded();
00075 
00077         CSound                          *getSound(const std::string &name);
00078 
00080         void                            getNames( std::vector<std::string >& names );
00081 
00083         uint                            countSounds();
00084 
00086 //      static void                     releaseAll();
00087 
00088         static CSoundBank       *instance();
00089         static void                     release();
00090 
00091         void                            addSound(CSound *sound);
00092         void                            removeSound(const std::string &name);
00093 
00094 
00095 private:
00097         CSoundBank() : _Loaded(false) {};
00098 
00099 
00101         static CSoundBank               *_Instance;
00102 
00103         typedef std::hash_set<class CSimpleSound*, THashPtr<CSimpleSound*> >    TSimpleSoundContainer;
00104         typedef std::hash_map<std::string, TSimpleSoundContainer >                              TBufferAssocContainer;
00106         typedef std::hash_map<std::string, CSound*>                                                             TSoundTable;
00107 
00109         TBufferAssocContainer           _BufferAssoc;
00110 
00111         // Buffer
00112         TSoundTable                                     _Sounds;
00113 
00114         // Did we load the buffers.
00115         bool                            _Loaded;
00116 
00117 };
00118 
00119 
00124 class ESoundBankNotFound : public NLMISC::Exception
00125 {
00126 public:
00127         ESoundBankNotFound( const std::string filename ) :
00128           NLMISC::Exception( (std::string("Sound bank not found: ")+filename).c_str() ) {}
00129 };
00130 
00131 } // NLSOUND
00132 
00133 
00134 #endif // NL_SOUND_BANK_H
00135 
00136 /* End of sound.h */
00137