Audacity 3.2.0
ExportPluginRegistry.cpp
Go to the documentation of this file.
2
3#include "ExportPlugin.h"
4
5namespace {
6 const auto PathStart = L"Exporters";
7}
8
11{
12 static Registry::GroupItem<Traits> registry{ PathStart };
13 return registry;
14}
15
17 const Identifier &id, Factory factory )
18 : SingleItem{ id }
19 , mFactory{ std::move(factory) }
20{}
21
23
25{
26 ++mFormatIndex;
27 if(mFormatIndex >= (*mPluginIt)->GetFormatCount())
28 {
29 mFormatIndex = 0;
30 ++mPluginIt;
31 }
32 return *this;
33}
34
36
38 const Identifier &id,
39 const Factory &factory,
40 const Registry::Placement &placement )
41 : RegisteredItem{
42 factory ? std::make_unique< ExportPluginRegistryItem >( id, factory ) : nullptr,
43 placement
44 }
45{
46}
47
49{
50 static ExportPluginRegistry registry;
51 return registry;
52}
53
55{
56 using namespace Registry;
59 { {wxT(""), wxT("PCM,MP3,OGG,Opus,FLAC,WavPack,FFmpeg,MP2,CommandLine") } },
60 };
61
62 // visit the registry to collect the plug-ins properly
63 // sorted
66 [&](const ExportPluginRegistryItem &item, auto&){
67 mPlugins.emplace_back(item.mFactory()); },
69}
70
71std::tuple<ExportPlugin*, int>
72ExportPluginRegistry::FindFormat(const wxString& format, bool compareWithCase) const
73{
74 for(auto t: *this)
75 {
76 const auto [plugin, formatIndex] = t;
77 if(plugin->GetFormatInfo(formatIndex).format.IsSameAs(format, compareWithCase))
78 return t;
79 }
80 return {};
81}
wxT("CloseDown"))
static RegisteredToolbarFactory factory
int id
std::function< std::unique_ptr< ExportPlugin >() > Factory
std::tuple< ExportPlugin *, int > FindFormat(const wxString &format, bool compareWithCase=false) const
Returns first pair of [exportPlugin, formatIndex], such that: exportPlugin->GetFormatInfo(formatIndex...
static ExportPluginRegistry & Get()
An explicitly nonlocalized string, not meant for the user to see.
Definition: Identifier.h:22
void Visit(const Visitors &visitors, const GroupItem< RegistryTraits > *pTopItem, const GroupItem< RegistryTraits > *pRegistry={}, typename RegistryTraits::ComputedItemContextType &computedItemContext=RegistryTraits::ComputedItemContextType::Instance)
Definition: Registry.h:609
STL namespace.
static Registry::GroupItem< Traits > & Registry()
ExportPluginRegistryItem(const Identifier &id, Factory factory)
RegisteredPlugin(const Identifier &id, const Factory &, const Registry::Placement &placement={ wxEmptyString, {} })