Audacity  3.0.3
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 
55 namespace PluginSettings {
56 
57 AUDACITY_DLL_API bool HasConfigGroup( EffectDefinitionInterface &ident,
58  ConfigurationType type, const RegistryPath & group);
59 AUDACITY_DLL_API bool GetConfigSubgroups( EffectDefinitionInterface &ident,
60  ConfigurationType type, const RegistryPath & group,
61  RegistryPaths & subgroups);
62 
63 AUDACITY_DLL_API bool GetConfigValue( EffectDefinitionInterface &ident,
64  ConfigurationType type, const RegistryPath & group,
66 
67 
68 // GetConfig with default value
69 template<typename Value>
71  ConfigurationType type, const RegistryPath & group,
72  const RegistryPath & key, Value &var, const Value &defval)
73 { return GetConfigValue(ident, type, group, key,
74  std::ref(var), std::cref(defval)); }
75 
76 // GetConfig with implicitly converted default value
77 template<typename Value, typename ConvertibleToValue>
79  ConfigurationType type, const RegistryPath & group,
80  const RegistryPath & key, Value &var, ConvertibleToValue defval)
81 { return GetConfig(ident, type, group, key, var, static_cast<Value>(defval)); }
82 
83 // GetConfig with default value assumed to be Value{}
84 template <typename Value>
86  ConfigurationType type, const RegistryPath & group,
87  const RegistryPath & key, Value &var)
88 {
89  return GetConfig(ident, type, group, key, var, Value{});
90 }
91 
92 AUDACITY_DLL_API bool SetConfigValue( EffectDefinitionInterface &ident,
93  ConfigurationType type, const RegistryPath & group,
94  const RegistryPath & key, ConfigConstReference value);
95 
96 template <typename Value>
98  ConfigurationType type, const RegistryPath & group,
99  const RegistryPath & key, const Value &value)
100 {
101  return SetConfigValue(ident, type, group, key, std::cref(value));
102 }
103 
105  ConfigurationType type, const RegistryPath & group);
106 AUDACITY_DLL_API bool RemoveConfig( EffectDefinitionInterface &ident,
107  ConfigurationType type, const RegistryPath & group,
108  const RegistryPath & key);
109 
110 }
111 
112 #endif // __AUDACITY_CONFIGINTERFACE_H__
ident
static CommandHandlerObject & ident(AudacityProject &project)
Definition: ModNullCallback.cpp:65
RegistryPaths
std::vector< RegistryPath > RegistryPaths
Definition: Identifier.h:219
PluginSettings::GetConfigSubgroups
bool GetConfigSubgroups(EffectDefinitionInterface &ident, PluginSettings::ConfigurationType type, const RegistryPath &group, RegistryPaths &subgroups)
Definition: ConfigInterface.cpp:23
PluginSettings::SetConfig
bool SetConfig(EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, const Value &value)
Definition: ConfigInterface.h:97
PluginSettings
Definition: ConfigInterface.cpp:12
Identifier.h
PluginSettings::GetConfig
bool GetConfig(EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, Value &var, const Value &defval)
Definition: ConfigInterface.h:70
RegistryPath
wxString RegistryPath
Definition: Identifier.h:218
PluginSettings::GetConfigValue
bool GetConfigValue(EffectDefinitionInterface &ident, PluginSettings::ConfigurationType type, const RegistryPath &group, const RegistryPath &key, ConfigReference var, ConfigConstReference defval)
Definition: ConfigInterface.cpp:33
PluginSettings::HasConfigGroup
bool HasConfigGroup(EffectDefinitionInterface &ident, PluginSettings::ConfigurationType type, const RegistryPath &group)
Definition: ConfigInterface.cpp:14
PluginSettings::ConfigConstReference
ConfigReferenceGenerator< true, ConfigValueTypes >::type ConfigConstReference
Definition: PluginInterface.h:79
EffectDefinitionInterface
EffectDefinitionInterface is a ComponentInterface that additionally tracks flag-functions for interac...
Definition: EffectInterface.h:73
key
static const AudacityProject::AttachedObjects::RegisteredFactory key
Definition: CommandManager.cpp:201
PluginInterface.h
PluginSettings::SetConfigValue
bool SetConfigValue(EffectDefinitionInterface &ident, PluginSettings::ConfigurationType type, const RegistryPath &group, const RegistryPath &key, ConfigConstReference value)
Definition: ConfigInterface.cpp:43
PluginSettings::RemoveConfig
bool RemoveConfig(EffectDefinitionInterface &ident, PluginSettings::ConfigurationType type, const RegistryPath &group, const RegistryPath &key)
Definition: ConfigInterface.cpp:62
PluginSettings::ConfigurationType
ConfigurationType
Definition: PluginInterface.h:55
PluginSettings::ConfigReference
ConfigReferenceGenerator< false, ConfigValueTypes >::type ConfigReference
Definition: PluginInterface.h:77
PluginSettings::RemoveConfigSubgroup
bool RemoveConfigSubgroup(EffectDefinitionInterface &ident, PluginSettings::ConfigurationType type, const RegistryPath &group)
Definition: ConfigInterface.cpp:53