home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 February / maximum-cd-2009-02.iso / DiscContents / SMC_1.6_win32.exe / src / audio / sound_manager.h < prev   
Encoding:
C/C++ Source or Header  |  2008-08-25  |  2.3 KB  |  94 lines

  1. /***************************************************************************
  2.  * sound_manager.h  -  header for the corresponding cpp file
  3.  *
  4.  * Copyright (C) 2006 - 2008 Florian Richter
  5.  ***************************************************************************/
  6. /*
  7.    This program is free software; you can redistribute it and/or modify
  8.    it under the terms of the GNU General Public License as published by
  9.    the Free Software Foundation; either version 3 of the License, or
  10.    (at your option) any later version.
  11.    
  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  14. */
  15.  
  16. #ifndef SMC_SOUND_MANAGER_H
  17. #define SMC_SOUND_MANAGER_H
  18.  
  19. #include "../core/globals.h"
  20. #include "../core/obj_manager.h"
  21.  
  22. /* *** *** *** *** *** *** *** Sound object *** *** *** *** *** *** *** *** *** *** */
  23.  
  24. class cSound
  25. {
  26. public:
  27.     cSound( void );
  28.     virtual ~cSound( void );
  29.     
  30.     // Load the data
  31.     bool Load( string filename );
  32.     // Free the data
  33.     void Free( void );
  34.  
  35.     // filename
  36.     string m_filename;
  37.     // data if loaded else null
  38.     Mix_Chunk *m_chunk;
  39. };
  40.  
  41. typedef vector<cSound *> SoundList;
  42.  
  43. /* *** *** *** *** *** *** cSound_Manager *** *** *** *** *** *** *** *** *** *** *** */
  44.  
  45. /*  Keeps track of all sounds in memory
  46.  *
  47.  * Operators:
  48.  * - cSound_Manager [path]
  49.  * - cSound_Manager [ID]
  50. */
  51. class cSound_Manager : public cObject_Manager<cSound>
  52. {
  53. public:
  54.     cSound_Manager( void );
  55.     virtual ~cSound_Manager( void );
  56.  
  57.     // Return the Sound from Path
  58.     virtual cSound *Get_Pointer( string path );
  59.  
  60.     // Return the Sound Path as string
  61.     string Get_Path( unsigned int identifier );
  62.  
  63.     /* Add a Sound
  64.      * Should always have the path set
  65.      */
  66.     void Add( cSound *item );
  67.  
  68.     cSound *operator [] ( unsigned int identifier )
  69.     {
  70.         return cObject_Manager<cSound>::Get_Pointer( identifier );
  71.     }
  72.     
  73.     cSound *operator [] ( string path )
  74.     {
  75.         return Get_Pointer( path );
  76.     }
  77.  
  78.     // Delete all Sounds, but keep object vector entries
  79.     void Delete_Sounds( void );
  80.  
  81. private:
  82.     // sounds loaded since initialization
  83.     unsigned int load_count;
  84. };
  85.  
  86. /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
  87.  
  88. // Sound Manager
  89. extern cSound_Manager *pSound_Manager;
  90.  
  91. /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
  92.  
  93. #endif
  94.