blob: 37075fb92ba68f11447e508e94f02c41ec2e867a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
#ifndef MIXXX_SOUNDSOURCEPROVIDERREGISTRY_H
#define MIXXX_SOUNDSOURCEPROVIDERREGISTRY_H
#include <QMap>
#include "sources/soundsourceprovider.h"
namespace mixxx {
class SoundSourceProviderRegistration {
public:
const SoundSourceProviderPointer& getProvider() const {
return m_pProvider;
}
SoundSourceProviderPriority getProviderPriority() const {
return m_providerPriority;
}
private:
friend class SoundSourceProviderRegistry;
SoundSourceProviderRegistration(
SoundSourceProviderPointer pProvider,
SoundSourceProviderPriority providerPriority)
: m_pProvider(pProvider),
m_providerPriority(providerPriority) {
}
SoundSourceProviderPointer m_pProvider;
SoundSourceProviderPriority m_providerPriority;
};
// Registry for SoundSourceProviders
class SoundSourceProviderRegistry {
public:
// Registers a provider for all supported file extensions
// with their cooperative priority hint.
void registerProvider(
const SoundSourceProviderPointer& pProvider);
// Registers a provider for a single file extension with an
// explicitly specified priority. The provider must support
// the given file extension.
void registerProviderForFileExtension(
const QString& fileExtension,
const SoundSourceProviderPointer& pProvider,
SoundSourceProviderPriority providerPriority);
// Deregisters a provider for all supported file extensions.
void deregisterProvider(
const SoundSourceProviderPointer& pProvider);
// Deregisters a provider for a single file extension.
void deregisterProviderForFileExtension(
const QString& fileExtension,
const SoundSourceProviderPointer& pProvider);
QStringList getRegisteredFileExtensions() const {
return m_registry.keys();
}
// Returns all registrations for the given file extension.
// If no providers have been registered for this file extension
// an empty list will be returned.
QList<SoundSourceProviderRegistration> getRegistrationsForFileExtension(
const QString& fileExtension) const;
private:
void addRegistrationForFileExtension(
const QString& fileExtension,
SoundSourceProviderRegistration registration);
static void insertRegistration(
QList<SoundSourceProviderRegistration>* pRegistrations,
SoundSourceProviderRegistration registration);
typedef QMap<QString, QList<SoundSourceProviderRegistration>> FileExtension2RegistrationList;
FileExtension2RegistrationList m_registry;
};
} // namespace mixxx
#endif // MIXXX_SOUNDSOURCEPROVIDERREGISTRY_H
|