SFML 2.5.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

SoundFileFactory.hpp
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
25#ifndef SFML_SOUNDFILEFACTORY_HPP
26#define SFML_SOUNDFILEFACTORY_HPP
27
29// Headers
31#include <SFML/Audio/Export.hpp>
32#include <string>
33#include <vector>
34
35
36 namespace sf
37{
38 class InputStream;
39 class SoundFileReader;
40 class SoundFileWriter;
41
46 class SFML_AUDIO_API SoundFileFactory
47{
48 public:
49
56 template <typename T>
57 static void registerReader();
58
65 template <typename T>
66 static void unregisterReader();
67
74 template <typename T>
75 static void registerWriter();
76
83 template <typename T>
84 static void unregisterWriter();
85
98 static SoundFileReader* createReaderFromFilename(const std::string& filename);
99
113 static SoundFileReader* createReaderFromMemory(const void* data, std::size_t sizeInBytes);
114
127 static SoundFileReader* createReaderFromStream(InputStream& stream);
128
139 static SoundFileWriter* createWriterFromFilename(const std::string& filename);
140
141 private:
142
144 // Types
146 struct ReaderFactory
147 {
148 bool (*check)(InputStream&);
149 SoundFileReader* (*create)();
150 };
151 typedef std::vector<ReaderFactory> ReaderFactoryArray;
152
153 struct WriterFactory
154 {
155 bool (*check)(const std::string&);
156 SoundFileWriter* (*create)();
157 };
158 typedef std::vector<WriterFactory> WriterFactoryArray;
159
161 // Static member data
163 static ReaderFactoryArray s_readers;
164 static WriterFactoryArray s_writers;
165};
166
167} // namespace sf
168
169#include <SFML/Audio/SoundFileFactory.inl>
170
171#endif // SFML_SOUNDFILEFACTORY_HPP
172
173
sf::InputStream
Abstract class for custom file input streams.
Definition: InputStream.hpp:42
sf::SoundFileFactory
Manages and instantiates sound file readers and writers.
Definition: SoundFileFactory.hpp:47
sf::SoundFileFactory::unregisterWriter
static void unregisterWriter()
Unregister a writer.
sf::SoundFileFactory::createReaderFromMemory
static SoundFileReader * createReaderFromMemory(const void *data, std::size_t sizeInBytes)
Instantiate the right codec for the given file in memory.
sf::SoundFileFactory::createWriterFromFilename
static SoundFileWriter * createWriterFromFilename(const std::string &filename)
Instantiate the right writer for the given file on disk.
sf::SoundFileFactory::registerWriter
static void registerWriter()
Register a new writer.
sf::SoundFileFactory::unregisterReader
static void unregisterReader()
Unregister a reader.
sf::SoundFileFactory::createReaderFromFilename
static SoundFileReader * createReaderFromFilename(const std::string &filename)
Instantiate the right reader for the given file on disk.
sf::SoundFileFactory::registerReader
static void registerReader()
Register a new reader.
sf::SoundFileFactory::createReaderFromStream
static SoundFileReader * createReaderFromStream(InputStream &stream)
Instantiate the right codec for the given file in stream.
sf::SoundFileReader
Abstract base class for sound file decoding.
Definition: SoundFileReader.hpp:44
sf::SoundFileWriter
Abstract base class for sound file encoding.
Definition: SoundFileWriter.hpp:42