# 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_anim_manager.h

Go to the documentation of this file.
00001 
00008 /* Copyright, 2000 Nevrax Ltd.
00009  *
00010  * This file is part of NEVRAX NEL.
00011  * NEVRAX NEL is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2, or (at your option)
00014  * any later version.
00015 
00016  * NEVRAX NEL is distributed in the hope that it will be useful, but
00017  * WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00019  * General Public License for more details.
00020 
00021  * You should have received a copy of the GNU General Public License
00022  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00023  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00024  * MA 02111-1307, USA.
00025  */
00026 
00027 #ifndef NL_SOUND_ANIM_MANAGER_H
00028 #define NL_SOUND_ANIM_MANAGER_H
00029 
00030 
00031 #include "nel/misc/vector.h"
00032 #include "nel/sound/u_source.h"
00033 #include <hash_map>
00034 
00035         
00036 namespace NLSOUND {
00037 
00038 
00039 //class CSoundAnimPlayer;
00040 class CSoundAnimation;
00041 class UAudioMixer;
00042 
00043 /*// Comparision for const char*
00044 struct eqsndanim
00045 {
00046   bool operator()(const char* s1, const char* s2) const
00047   {
00048     return strcmp(s1, s2) == 0;
00049   }
00050 };
00051 */
00052 
00054 typedef sint32 TSoundAnimId;
00055 
00056 const TSoundAnimId CSoundAnimationNoId = -1;
00057 
00059 typedef sint32 TSoundAnimPlayId;
00060 
00062 typedef std::hash_map<std::string, TSoundAnimId> TSoundAnimMap;
00063 
00065 typedef std::vector<CSoundAnimation*> TSoundAnimVector;
00066 
00068 //typedef std::set<CSoundAnimPlayer*> TPlayerSet;
00069 
00070 
00071 
00072 class CSoundAnimManager
00073 {
00074 public:
00075 
00076         static CSoundAnimManager* instance() { return _Instance; }
00077 
00078         CSoundAnimManager(UAudioMixer* mixer);
00079         virtual ~CSoundAnimManager();
00080 
00086         virtual TSoundAnimId                    loadAnimation(std::string& name);
00087 
00092         virtual TSoundAnimId                    createAnimation(std::string& name);
00093 
00097         virtual void                                    saveAnimation(CSoundAnimation* anim, std::string& filname);
00098 
00103         virtual TSoundAnimId                    getAnimationFromName(std::string& name);
00104 
00108         virtual CSoundAnimation*                findAnimation(std::string& name);
00109 
00114         virtual TSoundAnimPlayId                playAnimation(TSoundAnimId id, float time, CSoundContext &context);
00115 
00120         virtual TSoundAnimPlayId                playAnimation(std::string& name, float time, CSoundContext &context);
00121 
00125         virtual void                                    stopAnimation(TSoundAnimPlayId playbackId);
00126 
00130         virtual bool                                    isPlaying(TSoundAnimPlayId playbackId);
00131 
00134         virtual void                                    update(float lastTime, float curTime);
00135 
00140         virtual void                                    playAnimation(TSoundAnimId id, float lastTime, float curTime, CSoundContext &context);
00141 
00144         virtual std::string                             idToName(TSoundAnimId id);
00145 
00146 protected:
00147 
00149         static CSoundAnimManager*               _Instance;
00150 
00152         UAudioMixer                                             *_Mixer;
00153 
00155         TSoundAnimMap                                   _IdMap;
00156 
00158         TSoundAnimVector                                _Animations;
00159 
00161         //TPlayerSet                                            _Players;
00162 
00164         //TSoundAnimPlayId                              _PlayerId;
00165 
00167         //std::vector<CSoundAnimPlayer*>        _Garbage;
00168 
00169 };
00170 
00174 /*
00175 class ESoundAnimationNotFound : public NLMISC::Exception
00176 {
00177 public:
00178         ESoundAnimationNotFound( const std::string filename ) :
00179           NLMISC::Exception( (std::string("Sound animation not found: ")+filename).c_str() ) {}
00180 };
00181 */
00182 
00183 } // namespace NLSOUND
00184 
00185 #endif // NL_SOUND_ANIM_MANAGER_H