zenilib: zenilib/jni/external/zenilib/zeni_audio/Sounds.cpp Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Sounds.cpp
Go to the documentation of this file.
1 /* This file is part of the Zenipex Library (zenilib).
2 * Copyright (C) 2011 Mitchell Keith Bloch (bazald).
3 *
4 * zenilib is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * zenilib is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with zenilib. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include <zeni_audio.h>
19
20 #include <iostream>
21 #include <fstream>
22
23 #if defined(_DEBUG) && defined(_WINDOWS)
24 #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
25 #define new DEBUG_NEW
26 #endif
27
28 #include <Zeni/Database.hxx>
29 #include <Zeni/Singleton.hxx>
30
31 namespace Zeni {
32
33 template class Singleton<Sounds>;
34 template class Database<Sound_Buffer>;
35
36 Sounds * Sounds::create() {
37 return new Sounds;
38 }
39
40 Singleton<Sounds>::Uninit Sounds::g_uninit;
41 Singleton<Sounds>::Reinit Sounds::g_reinit;
42
43 Sounds::Sounds()
44 : Database<Sound_Buffer>("config/sounds.xml", "Sounds")
45 {
46 Sound::remove_post_reinit(&g_reinit);
47
48 Sound &sr = get_Sound();
49
50 init();
51
52 sr.lend_pre_uninit(&g_uninit);
53 sr.lend_post_reinit(&g_reinit);
54 }
55
56 Sounds::~Sounds() {
57 Sound::remove_pre_uninit(&g_uninit);
58
59 Database<Sound_Buffer>::uninit();
60 }
61
62 Sounds & get_Sounds() {
63 return Sounds::get();
64 }
65
66 Sound_Buffer * Sounds::load(XML_Element_c &xml_element, const String &/*name*/, const String &/*filename*/) {
67 const String filepath = xml_element["filepath"].to_string();
68
69 return new Sound_Buffer(filepath);
70 }
71
72 }
Zeni::get_Sounds
Sounds & get_Sounds()
Get access to the singleton.
Definition: Sounds.cpp:62
Database.hxx
init
static void init(struct bs2b *bs2b)
Definition: bs2b.c:46
Zeni::Sounds
A Sound_Buffer Database Singleton.
Definition: Sounds.h:48
Zeni::Singleton< Sound >::remove_post_reinit
static void remove_post_reinit(Event::Handler *const &handler)
Zeni::get_Sound
Sound & get_Sound()
Get access to the singleton.
Definition: Sound.cpp:220
Singleton.hxx
zeni_audio.h
Zeni::Database< Sound_Buffer >::uninit
void uninit()