Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
outputproducerregistry.cpp
Go to the documentation of this file.
1// Copyright (C) 2026 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
5
7
9
10/*!
11 \class OutputProducerRegistry
12 \internal
13 \brief Singleton registry for discovering output producers by format.
14
15 \sa IOutputProducer, Generator
16*/
17
18/*!
19 Returns the singleton registry instance.
20*/
22{
23 static OutputProducerRegistry registry;
24 return registry;
25}
26
27/*!
28 Registers \a producer with this registry.
29
30 The producer is indexed by its format() identifier, which is
31 case-sensitive (see IOutputProducer::format()). If a producer
32 with the same format is already registered, it will be replaced.
33
34 The format identifier must remain constant for the lifetime of
35 the producer; changing it after registration may prevent successful
36 unregistration.
37
38 \sa unregisterProducer()
39*/
40void OutputProducerRegistry::registerProducer(IOutputProducer *producer)
41{
42 if (!producer)
43 return;
44
45 m_producers.insert(producer->format(), producer);
46}
47
48/*!
49 Unregisters \a producer from this registry.
50
51 The producer is only removed if it is currently the registered
52 producer for its format. This prevents a replaced producer from
53 accidentally unregistering its replacement during destruction.
54
55 \sa registerProducer()
56*/
57void OutputProducerRegistry::unregisterProducer(IOutputProducer *producer)
58{
59 if (!producer)
60 return;
61
62 auto it = m_producers.find(producer->format());
63 if (it != m_producers.end() && it.value() == producer)
64 m_producers.erase(it);
65}
66
67/*!
68 Returns the producer registered for \a format, or nullptr if none.
69 The \a format comparison is case-sensitive.
70*/
71IOutputProducer *OutputProducerRegistry::producerForFormat(const QString &format) const
72{
73 return m_producers.value(format, nullptr);
74}
75
76/*!
77 Returns all registered producers in unspecified order.
78*/
80{
81 return m_producers.values();
82}
83
84QT_END_NAMESPACE
Singleton registry for discovering output producers by format.
void registerProducer(IOutputProducer *producer)
Registers producer with this registry.
QList< IOutputProducer * > allProducers() const
Returns all registered producers in unspecified order.
static OutputProducerRegistry & instance()
Returns the singleton registry instance.
void unregisterProducer(IOutputProducer *producer)
Unregisters producer from this registry.
Combined button and popup list for selecting options.