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// GetConfig with default value assumed to be Value{}
87template <typename Value>
89 ConfigurationType type, const RegistryPath & group,
90 const RegistryPath & key, Value &var)
91{
92 return GetConfig(ident, type, group, key, var, Value{});
93}
94
95MODULE_MANAGER_API bool SetConfigValue(const EffectDefinitionInterface &ident,
96 ConfigurationType type, const RegistryPath & group,
98
99template <typename Value>
101 ConfigurationType type, const RegistryPath & group,
102 const RegistryPath & key, const Value &value)
103{
104 return SetConfigValue(ident, type, group, key, std::cref(value));
105}
106
107MODULE_MANAGER_API bool RemoveConfigSubgroup( const EffectDefinitionInterface &ident,
108 ConfigurationType type, const RegistryPath & group);
109MODULE_MANAGER_API bool RemoveConfig( const EffectDefinitionInterface &ident,
110 ConfigurationType type, const RegistryPath & group,
111 const RegistryPath & key);
112
113}
114
115#endif // __AUDACITY_CONFIGINTERFACE_H__
static const AudacityProject::AttachedObjects::RegisteredFactory key
wxString RegistryPath
Definition: Identifier.h:218
std::vector< RegistryPath > RegistryPaths
Definition: Identifier.h:219
static CommandHandlerObject & ident(AudacityProject &project)
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)
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)
ConfigReferenceGenerator< false, ConfigValueTypes >::type ConfigReference
bool RemoveConfig(const EffectDefinitionInterface &ident, PluginSettings::ConfigurationType type, const RegistryPath &group, const RegistryPath &key)
ConfigReferenceGenerator< true, ConfigValueTypes >::type ConfigConstReference
bool SetConfigValue(const EffectDefinitionInterface &ident, PluginSettings::ConfigurationType type, const RegistryPath &group, const RegistryPath &key, ConfigConstReference value)
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)