Audacity 3.2.0
NumericConverterRegistry.h
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 @file NumericConverterRegistry.h
7
8 Dmitry Vedenko
9
10 **********************************************************************/
11#pragma once
12
13#include <functional>
14#include <memory>
15#include <optional>
16
17#include "Callable.h"
18#include "Registry.h"
20
23
25{
26public:
28
29 virtual std::unique_ptr<NumericConverterFormatter>
30 Create(const FormatterContext& context) const = 0;
31
32 virtual bool IsAcceptableInContext(const FormatterContext& context) const = 0;
33};
34
36 std::unique_ptr<NumericConverterFormatterFactory>;
37
41
44 using NodeTypes =
46};
47
51 : type{ std::move(type) }
52 {}
53};
54
55struct NUMERIC_FORMATS_API NumericConverterRegistryGroup final
57 Registry::GroupItem<NumericConverterRegistryTraits>,
58 NumericConverterRegistryGroupData,
59 const Identifier &
60 >
61{
64
65 const auto &GetType() const { return type; }
66};
67
68struct NUMERIC_FORMATS_API NumericConverterRegistryItem : public Registry::SingleItem
69{
71 const Identifier& internalName, const NumericFormatSymbol& symbol,
73
75 const Identifier& internalName, const NumericFormatSymbol& symbol,
76 const TranslatableString& fractionLabel,
78
80
83
85};
86
87struct NUMERIC_FORMATS_API NumericConverterRegistry final
88{
90
91 using Visitor = std::function<void(const NumericConverterRegistryItem&)>;
92
93 static void Visit(
94 const FormatterContext& context, const NumericConverterType& type,
95 Visitor visitor);
96
98 const FormatterContext& context, const NumericConverterType& type,
99 const NumericFormatID& symbol);
100};
101
103 Callable::UniqueMaker<NumericConverterRegistryItem>();
104
108
111
113 Registry::GroupItem<NumericConverterRegistryTraits>,
114 void, const Identifier&
115> {
116 using Extension::Extension;
117};
118
119constexpr auto NumericConverterItems =
120 Callable::UniqueMaker<NumericConverterRegistrySuperGroup>();
static RegisteredToolbarFactory factory
Functions and classes that generate callable objects.
std::unique_ptr< NumericConverterFormatterFactory > NumericConverterFormatterFactoryPtr
constexpr auto NumericConverterItems
constexpr auto NumericConverterFormatterGroup
constexpr auto NumericConverterFormatterItem
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
A context in which formatter operates.
An explicitly nonlocalized string, not meant for the user to see.
Definition: Identifier.h:22
virtual std::unique_ptr< NumericConverterFormatter > Create(const FormatterContext &context) const =0
virtual ~NumericConverterFormatterFactory()=default
virtual bool IsAcceptableInContext(const FormatterContext &context) const =0
Generates classes whose instances register items at construction.
Definition: Registry.h:388
Holds a msgid for the translation catalog; may also bind format arguments.
PROJECT_FILE_IO_API wxString Find(const FilePath &path)
constexpr auto UniqueMaker()
Generate variadic factory functions.
Definition: Callable.h:122
MENUS_API void Visit(Visitor< Traits > &visitor, AudacityProject &project)
STL namespace.
Extend Base with extra fields, in a second, protected base class.
Definition: Composite.h:177
Extension(RequiredBaseArgs... args, Base2 arg2, OtherBaseArgs &&...otherArgs)
Definition: Composite.h:179
NumericConverterRegistryGroupData(NumericConverterType type)
std::function< void(const NumericConverterRegistryItem &)> Visitor
const NumericConverterFormatterFactoryPtr factory
const NumericFormatSymbol symbol
const TranslatableString fractionLabel
Common abstract base class for items that are not groups.
Definition: Registry.h:224
Primary template for a list of arbitrary types.
Definition: TypeList.h:61