Documentation de SFML 2.6.1

Attention: cette page se réfère à une ancienne version de SFML. Cliquez ici pour passer à la dernière version.
Loading...
Searching...
No Matches
SoundFileFactory.hpp
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2023 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
36namespace sf
37{
38class InputStream;
39class SoundFileReader;
40class SoundFileWriter;
41
46class SFML_AUDIO_API SoundFileFactory
47{
48public:
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
128
139 static SoundFileWriter* createWriterFromFilename(const std::string& filename);
140
141private:
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
Abstract class for custom file input streams.
Manages and instantiates sound file readers and writers.
static void unregisterWriter()
Unregister a writer.
static SoundFileReader * createReaderFromMemory(const void *data, std::size_t sizeInBytes)
Instantiate the right codec for the given file in memory.
static SoundFileWriter * createWriterFromFilename(const std::string &filename)
Instantiate the right writer for the given file on disk.
static void registerWriter()
Register a new writer.
static void unregisterReader()
Unregister a reader.
static SoundFileReader * createReaderFromFilename(const std::string &filename)
Instantiate the right reader for the given file on disk.
static void registerReader()
Register a new reader.
static SoundFileReader * createReaderFromStream(InputStream &stream)
Instantiate the right codec for the given file in stream.
Abstract base class for sound file decoding.
Abstract base class for sound file encoding.