Audacity 3.2.0
CloudExportersRegistry.cpp
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*!********************************************************************
3
4 Audacity: A Digital Audio Editor
5
6 CloudExportersRegistry.cpp
7
8 Dmitry Vedenko
9
10**********************************************************************/
11#pragma once
12
14
15#include <unordered_map>
16
17#include "CloudExporterPlugin.h"
18
19namespace cloud
20{
21namespace
22{
23std::unordered_map<MimeType, CloudExporterPluginFactory> Exporters;
24}
25
28{
29 if (Exporters.end() == Exporters.find(mimeType))
30 {
31 Exporters.emplace(std::move(mimeType), std::move(factory));
32 return true;
33 }
34
35 return false;
36}
37
38std::unique_ptr<cloud::CloudExporterPlugin> CreatePreferredExporter(
39 const MimeTypesList& mimeTypes, const AudacityProject& project)
40{
41 for (const auto& mimeType : mimeTypes)
42 {
43 auto it = Exporters.find(mimeType);
44
45 if (Exporters.end() != it)
46 return it->second(project);
47 }
48
49 return {};
50}
51
52} // namespace cloud
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
std::unordered_map< MimeType, CloudExporterPluginFactory > Exporters
static RegisteredToolbarFactory factory
std::unique_ptr< cloud::CloudExporterPlugin > CreatePreferredExporter(const MimeTypesList &mimeTypes, const AudacityProject &project)
std::function< std::unique_ptr< CloudExporterPlugin >(const AudacityProject &)> CloudExporterPluginFactory
std::string MimeType
Definition: MimeTypesList.h:18
std::vector< std::string > MimeTypesList
Ordered list of mime types.
Definition: MimeTypesList.h:20
bool RegisterCloudExporter(MimeType mimeType, CloudExporterPluginFactory factory)
Registers a factory for a specific mime type.