Audacity 3.2.0
Public Member Functions | Private Types | Private Attributes | List of all members
ModuleSettingsResetHandler Class Referencefinal
Inheritance diagram for ModuleSettingsResetHandler:
[legend]
Collaboration diagram for ModuleSettingsResetHandler:
[legend]

Public Member Functions

 ~ModuleSettingsResetHandler () override
 
void OnSettingResetBegin () override
 Happens before preferences reset. More...
 
void OnSettingResetEnd () override
 Happens after preferences reset. More...
 
- Public Member Functions inherited from PreferencesResetHandler
virtual ~PreferencesResetHandler ()
 
virtual void OnSettingResetBegin ()=0
 Happens before preferences reset. More...
 
virtual void OnSettingResetEnd ()=0
 Happens after preferences reset. More...
 

Private Types

using KeyValueStorage = std::vector< std::pair< wxString, wxString > >
 

Private Attributes

std::optional< KeyValueStoragemStorage
 

Detailed Description

Definition at line 20 of file ModuleSettings.cpp.

Member Typedef Documentation

◆ KeyValueStorage

using ModuleSettingsResetHandler::KeyValueStorage = std::vector<std::pair<wxString, wxString> >
private

Definition at line 22 of file ModuleSettings.cpp.

Constructor & Destructor Documentation

◆ ~ModuleSettingsResetHandler()

ModuleSettingsResetHandler::~ModuleSettingsResetHandler ( )
inlineoverride

Definition at line 26 of file ModuleSettings.cpp.

27 {
28 assert(!mStorage.has_value());
29 }
std::optional< KeyValueStorage > mStorage

References mStorage.

Member Function Documentation

◆ OnSettingResetBegin()

void ModuleSettingsResetHandler::OnSettingResetBegin ( )
inlineoverridevirtual

Happens before preferences reset.

Implements PreferencesResetHandler.

Definition at line 31 of file ModuleSettings.cpp.

32 {
33 assert(!mStorage.has_value());
34
35 static const wxString modulePrefsGroups[] = {
36 "/ModulePath/",
37 "/Module/",
38 "/ModuleDateTime/"
39 };
40 KeyValueStorage storage;
41 for(const auto& group : modulePrefsGroups)
42 {
43 if(!gPrefs->HasGroup(group))
44 continue;
45
46 const auto groupScope = gPrefs->BeginGroup(group);
47 for(const auto& key : gPrefs->GetChildKeys())
48 {
49 wxString value;
50 if(gPrefs->Read(key, &value))
51 storage.emplace_back(group + key, value);
52 }
53 }
54 mStorage = std::move(storage);
55 }
static const AudacityProject::AttachedObjects::RegisteredFactory key
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
std::vector< std::pair< wxString, wxString > > KeyValueStorage
virtual bool HasGroup(const wxString &key) const =0
Checks whether specified group exists relative to the current group.
GroupScope BeginGroup(const wxString &prefix)
Appends a prefix to the current group or sets a new absolute path. Group that was set as current befo...
virtual wxArrayString GetChildKeys() const =0
Returns all child keys within the current group.
virtual bool Read(const wxString &key, bool *value) const =0

References audacity::BasicSettings::BeginGroup(), audacity::BasicSettings::GetChildKeys(), gPrefs, audacity::BasicSettings::HasGroup(), key, mStorage, and audacity::BasicSettings::Read().

Here is the call graph for this function:

◆ OnSettingResetEnd()

void ModuleSettingsResetHandler::OnSettingResetEnd ( )
inlineoverridevirtual

Happens after preferences reset.

Implements PreferencesResetHandler.

Definition at line 57 of file ModuleSettings.cpp.

58 {
59 if(!mStorage.has_value())
60 return;
61 const auto Do = finally([=]{ mStorage = std::nullopt; });
62 for(const auto& [key, value] : *mStorage)
63 gPrefs->Write(key, value);
64 }
virtual bool Write(const wxString &key, bool value)=0

References gPrefs, key, mStorage, and audacity::BasicSettings::Write().

Here is the call graph for this function:

Member Data Documentation

◆ mStorage

std::optional<KeyValueStorage> ModuleSettingsResetHandler::mStorage
private

The documentation for this class was generated from the following file: