Audacity 3.2.0
ProjectFormatExtensionsRegistry.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 ProjectFormatExtensionRegistry.cpp
6
7 Dmitry Vedenko
8
9**********************************************************************/
10
11
13
14#include <algorithm>
15
16#include "Project.h"
17
19{
20 static ProjectFormatExtensionsRegistry instance;
21 return instance;
22}
23
25{
27}
28
30 ProjectVersionResolver formatExtension)
31{
32 mRegisteredExtensions.emplace_back(std::move(formatExtension));
33}
34
36 const AudacityProject& project) const
37{
39
40 for (auto formatExtension : mRegisteredExtensions)
41 {
42 if (!formatExtension)
43 continue;
44
45 const auto formatExtensionVersion = formatExtension(project);
46
47 if (minVersion < formatExtensionVersion)
48 minVersion = formatExtensionVersion;
49 }
50
51 return minVersion;
52}
53
56{
57 if (resolver)
58 GetProjectFormatExtensionsRegistry().Register(std::move(resolver));
59}
ProjectFormatExtensionsRegistry & GetProjectFormatExtensionsRegistry()
const ProjectFormatVersion BaseProjectFormatVersion
This is a helper constant for the "most compatible" project version with the value (3,...
const auto project
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
The class that allows evaluating the minimum version of Audacity required to support the project.
void Register(ProjectVersionResolver resolver)
ProjectFormatVersion GetRequiredVersion(const AudacityProject &project) const
Returns the minimum possible version that can be used to save the project.
ProjectFormatVersion(*)(const AudacityProject &) ProjectVersionResolver
static const ProjectFormatExtensionsRegistry & Get()
std::vector< ProjectVersionResolver > mRegisteredExtensions
A structure that holds the project version.