El Octavio  1.0
This is a video game about adventures.
SoundFileFactory.inl
Go to the documentation of this file.
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
26// Headers
28
29
30namespace sf
31{
32namespace priv
33{
34 template <typename T> SoundFileReader* createReader() {return new T;}
35 template <typename T> SoundFileWriter* createWriter() {return new T;}
36}
37
39template <typename T>
41{
42 // Make sure the same class won't be registered twice
43 unregisterReader<T>();
44
45 // Create a new factory with the functions provided by the class
46 ReaderFactory factory;
47 factory.check = &T::check;
48 factory.create = &priv::createReader<T>;
49
50 // Add it
51 s_readers.push_back(factory);
52}
53
54
56template <typename T>
58{
59 // Remove the instance(s) of the reader from the array of factories
60 for (ReaderFactoryArray::iterator it = s_readers.begin(); it != s_readers.end(); )
61 {
62 if (it->create == &priv::createReader<T>)
63 it = s_readers.erase(it);
64 else
65 ++it;
66 }
67}
68
70template <typename T>
72{
73 // Make sure the same class won't be registered twice
74 unregisterWriter<T>();
75
76 // Create a new factory with the functions provided by the class
77 WriterFactory factory;
78 factory.check = &T::check;
79 factory.create = &priv::createWriter<T>;
80
81 // Add it
82 s_writers.push_back(factory);
83}
84
85
87template <typename T>
89{
90 // Remove the instance(s) of the writer from the array of factories
91 for (WriterFactoryArray::iterator it = s_writers.begin(); it != s_writers.end(); )
92 {
93 if (it->create == &priv::createWriter<T>)
94 it = s_writers.erase(it);
95 else
96 ++it;
97 }
98}
99
100} // namespace sf
static void unregisterWriter()
Unregister a writer.
static void registerWriter()
Register a new writer.
static void unregisterReader()
Unregister a reader.
static void registerReader()
Register a new reader.
Abstract base class for sound file decoding.
Abstract base class for sound file encoding.
Definition: Thread.inl:26
SoundFileWriter * createWriter()
SoundFileReader * createReader()