Planeshift
data.h
Go to the documentation of this file.
1 /*
2  * data.h
3  *
4  * Copyright (C) 2001-2010 Atomic Blue (info@planeshift.it, http://www.planeshift.it)
5  *
6  * Credits : Saul Leite <leite@engineer.com>
7  * Mathias 'AgY' Voeroes <agy@operswithoutlife.net>
8  * and all past and present planeshift coders
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation (version 2 of the License.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21  *
22  */
23 
24 #ifndef _SOUND_DATA_CACHE_H_
25 #define _SOUND_DATA_CACHE_H_
26 
27 
28 //====================================================================================
29 // Crystal Space Includes
30 //====================================================================================
31 #include <cssysdef.h>
32 #include <iutil/objreg.h>
33 #include <csutil/csstring.h>
34 #include <csutil/hash.h>
35 #include <iutil/vfs.h>
36 #include <isndsys/ss_data.h>
37 #include <isndsys/ss_loader.h>
38 
39 #define DEFAULT_SOUNDFILE_CACHETIME 300000
40 
41 
46 struct SoundFile
47 {
48 public:
49  csString name;
50  csString fileName;
51  csRef<iSndSysData> sndData;
52  csTicks lastTouch;
53 
59  SoundFile(const char* newName, const char* newFileName);
60 
65  SoundFile(SoundFile* const &copySoundFile);
66 
70  ~SoundFile();
71 };
72 
73 
74 //--------------------------------------------------
75 
76 
103 {
104 public:
105 
110  SoundDataCache();
111 
115  ~SoundDataCache();
116 
122  bool Initialize(iObjectRegistry* objectReg);
123 
130  bool LoadSoundLib(const char* fileName, iObjectRegistry* objectReg);
131 
135  void UnloadSoundLib();
136 
150  bool GetSoundData(const char* name, csRef<iSndSysData> &sndData);
151 
157  void UnloadSoundFile(const char* name);
158 
164  void Update();
165 
166 private:
167  uint cacheTime;
168  csRef<iVFS> vfs;
169  csRef<iSndSysLoader> sndLoader;
170  csHash<SoundFile*, csString> libSoundFiles;
171  csHash<SoundFile*, csString> loadedSoundFiles;
172 
182  SoundFile* LoadSoundFile(const char* name);
183 };
184 
185 #endif // _SOUND_DATA_CACHE_H_
~SoundFile()
Destructor.
Class that contains the most important informations about a soundfile It contains the name...
Definition: data.h:109
csTicks lastTouch
Last time when this SoundFile was used/touched.
Definition: data.h:52
csString name
name of this file/resource MUST be unique
Definition: data.h:112
SoundDataCache is the data-keeper of SoundSystemManager.
Definition: data.h:102
void void Initialize(iObjectRegistry *object_reg)
csString fileName
File&#39;s name in our vfs. It doesn&#39;t need to be unique.
Definition: data.h:50
SoundFile(const char *newname, const char *newfilename)
Constructs a SoundFile.
csRef< iSndSysData > sndData
Data in suitable format.
Definition: data.h:51