Audacity 3.2.0
ConfigInterface.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 ConfigInterface.h
6
7 Leland Lucius
8
9 Copyright (c) 2014, Audacity Team
10 All rights reserved.
11
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions
14 are met:
15
16 1. Redistributions of source code must retain the above copyright
17 notice, this list of conditions and the following disclaimer.
18
19 2. Redistributions in binary form must reproduce the above copyright
20 notice, this list of conditions and the following disclaimer in the
21 documentation and/or other materials provided with the distribution.
22
23 3. Neither the name of the copyright holder nor the names of its
24 contributors may be used to endorse or promote products derived from
25 this software without specific prior written permission.
26
27 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
30 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
31 COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
32 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
34 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
35 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
37 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 POSSIBILITY OF SUCH DAMAGE.
39
40**********************************************************************/
41
42#ifndef __AUDACITY_CONFIGINTERFACE_H__
43#define __AUDACITY_CONFIGINTERFACE_H__
44
45#include "Identifier.h"
46#include <functional>
47#include <tuple>
48#include <type_traits>
49#include <vector>
50
52
53#include "PluginInterface.h"
54
55namespace PluginSettings {
56
57MODULE_MANAGER_API bool HasConfigGroup( const EffectDefinitionInterface &ident,
58 ConfigurationType type, const RegistryPath & group);
59MODULE_MANAGER_API bool GetConfigSubgroups( const EffectDefinitionInterface &ident,
60 ConfigurationType type, const RegistryPath & group,
61 RegistryPaths & subgroups);
62
63MODULE_MANAGER_API bool GetConfigValue(const EffectDefinitionInterface &ident,
64 ConfigurationType type, const RegistryPath & group,
66
67MODULE_MANAGER_API bool HasConfigValue( const EffectDefinitionInterface &ident,
69 const RegistryPath & group, const RegistryPath & key);
70
71// GetConfig with default value
72template<typename Value>
74 ConfigurationType type, const RegistryPath & group,
75 const RegistryPath & key, Value &var, const Value &defval)
76{ return GetConfigValue(ident, type, group, key,
77 std::ref(var), std::cref(defval)); }
78
79// GetConfig with implicitly converted default value
80template<typename Value, typename ConvertibleToValue>
82 ConfigurationType type, const RegistryPath & group,
83 const RegistryPath & key, Value &var, ConvertibleToValue defval)
84{ return GetConfig(ident, type, group, key, var, static_cast<Value>(defval)); }
85
86// Deleted overloads for const Value as destination
87template<typename Value>
89 ConfigurationType type, const RegistryPath & group,
90 const RegistryPath & key, const Value &var, const Value &defval) = delete;
91template<typename Value, typename ConvertibleToValue>
93 ConfigurationType type, const RegistryPath & group,
94 const RegistryPath & key, const Value &var, ConvertibleToValue defval)
95 = delete;
96
97// GetConfig with default value assumed to be Value{}
98template <typename Value>
100 ConfigurationType type, const RegistryPath & group,
101 const RegistryPath & key, Value &var)
102{
103 return GetConfig(ident, type, group, key, var, Value{});
104}
105
106MODULE_MANAGER_API bool SetConfigValue(const EffectDefinitionInterface &ident,
107 ConfigurationType type, const RegistryPath & group,
108 const RegistryPath & key, ConfigConstReference value);
109
110template <typename Value>
112 ConfigurationType type, const RegistryPath & group,
113 const RegistryPath & key, const Value &value)
114{
115 return SetConfigValue(ident, type, group, key, std::cref(value));
116}
117
118MODULE_MANAGER_API bool RemoveConfigSubgroup( const EffectDefinitionInterface &ident,
119 ConfigurationType type, const RegistryPath & group);
120MODULE_MANAGER_API bool RemoveConfig( const EffectDefinitionInterface &ident,
121 ConfigurationType type, const RegistryPath & group,
122 const RegistryPath & key);
123
124}
125
126#endif // __AUDACITY_CONFIGINTERFACE_H__
wxString RegistryPath
Definition: Identifier.h:218
std::vector< RegistryPath > RegistryPaths
Definition: Identifier.h:219
static CommandHandlerObject & ident(AudacityProject &project)
static const AudacityProject::AttachedObjects::RegisteredFactory key
EffectDefinitionInterface is a ComponentInterface that adds some basic read-only information about ef...
bool RemoveConfigSubgroup(const EffectDefinitionInterface &ident, PluginSettings::ConfigurationType type, const RegistryPath &group)
bool GetConfigSubgroups(const EffectDefinitionInterface &ident, PluginSettings::ConfigurationType type, const RegistryPath &group, RegistryPaths &subgroups)
bool HasConfigValue(const EffectDefinitionInterface &ident, PluginSettings::ConfigurationType type, const RegistryPath &group, const RegistryPath &key)
TypeListVisitor::VariantOfReferences_t< false, ConfigValueTypes > ConfigReference
Define a reference to a variable of one of the types in ConfigValueTypes.
bool GetConfigValue(const EffectDefinitionInterface &ident, PluginSettings::ConfigurationType type, const RegistryPath &group, const RegistryPath &key, ConfigReference var, ConfigConstReference defval)
bool SetConfig(const EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, const Value &value)
bool RemoveConfig(const EffectDefinitionInterface &ident, PluginSettings::ConfigurationType type, const RegistryPath &group, const RegistryPath &key)
bool SetConfigValue(const EffectDefinitionInterface &ident, PluginSettings::ConfigurationType type, const RegistryPath &group, const RegistryPath &key, ConfigConstReference value)
TypeListVisitor::VariantOfReferences_t< true, ConfigValueTypes > ConfigConstReference
bool HasConfigGroup(const EffectDefinitionInterface &ident, PluginSettings::ConfigurationType type, const RegistryPath &group)
bool GetConfig(const EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, Value &var, const Value &defval)