Audacity  3.0.3
Public Member Functions | List of all members
BoolSetting Class Referencefinal

This specialization of Setting for bool adds a Toggle method to negate the saved value. More...

#include <Prefs.h>

Inheritance diagram for BoolSetting:
[legend]
Collaboration diagram for BoolSetting:
[legend]

Public Member Functions

bool Toggle ()
 Write the negation of the previous value, and then return the current value. More...
 
 Setting (const SettingBase &path, const T &defaultValue)
 Usual overload supplies a default value. More...
 
 Setting (const SettingBase &path, DefaultValueFunction function)
 This overload causes recomputation of the default each time it is needed. More...
 
- Public Member Functions inherited from Setting< bool >
 Setting (const SettingBase &path, const bool &defaultValue)
 Usual overload supplies a default value. More...
 
 Setting (const SettingBase &path, DefaultValueFunction function)
 This overload causes recomputation of the default each time it is needed. More...
 
const bool & GetDefault () const
 
bool Read (bool *pVar) const
 overload of Read returning a boolean that is true if the value was previously defined *‍/ More...
 
bool Read () const
 overload of Read, always returning a value More...
 
bool ReadWithDefault (bool *pVar, const bool &defaultValue) const
 overload of ReadWithDefault returning a boolean that is true if the value was previously defined *‍/ More...
 
bool ReadWithDefault (const bool &defaultValue) const
 new direct use is discouraged but it may be needed in legacy code More...
 
bool Write (const bool &value)
 Write value to config and return true if successful. More...
 
bool Reset ()
 Reset to the default value. More...
 
- Public Member Functions inherited from CachingSettingBase< bool >
 CachingSettingBase (const SettingBase &path)
 
- Public Member Functions inherited from SettingBase
 SettingBase (const char *path)
 
 SettingBase (const wxChar *path)
 
 SettingBase (const wxString &path)
 
wxConfigBase * GetConfig () const
 
const wxString & GetPath () const
 
bool Delete ()
 Delete the key if present, and return true iff it was. More...
 

Additional Inherited Members

- Public Types inherited from Setting< bool >
using DefaultValueFunction = std::function< bool() >
 
- Protected Member Functions inherited from Setting< bool >
bool DoWrite ()
 Write cached value to config and return true if successful. More...
 
- Protected Member Functions inherited from CachingSettingBase< bool >
 CachingSettingBase (const CachingSettingBase &)=default
 
- Protected Member Functions inherited from SettingBase
 SettingBase (const SettingBase &)=default
 
- Protected Attributes inherited from Setting< bool >
bool mDefaultValue
 
const DefaultValueFunction mFunction
 
- Protected Attributes inherited from CachingSettingBase< bool >
bool mCurrentValue
 
bool mValid
 
- Protected Attributes inherited from SettingBase
const RegistryPath mPath
 

Detailed Description

This specialization of Setting for bool adds a Toggle method to negate the saved value.

Definition at line 199 of file Prefs.h.

Member Function Documentation

◆ Setting() [1/2]

Setting< T >::Setting
inline

Usual overload supplies a default value.

Definition at line 104 of file Prefs.h.

105  : CachingSettingBase< T >{ path }
106  , mDefaultValue{ defaultValue }
107  {}

◆ Setting() [2/2]

Setting< T >::Setting
inline

This overload causes recomputation of the default each time it is needed.

Definition at line 110 of file Prefs.h.

111  : CachingSettingBase< T >{ path }
112  , mFunction{ function }
113  {}

◆ Toggle()

bool BoolSetting::Toggle ( )

Write the negation of the previous value, and then return the current value.

Definition at line 414 of file Prefs.cpp.

415 {
416  bool value = Read();
417  if ( Write( !value ) )
418  return !value;
419  else
420  return value;
421 }

References Setting< bool >::Read(), and Setting< bool >::Write().

Here is the call graph for this function:

The documentation for this class was generated from the following files:
Setting< bool >::Write
bool Write(const bool &value)
Write value to config and return true if successful.
Definition: Prefs.h:168
Setting< bool >::Read
bool Read() const
overload of Read, always returning a value
Definition: Prefs.h:150
Setting< bool >::mDefaultValue
bool mDefaultValue
Definition: Prefs.h:194
Setting< bool >::mFunction
const DefaultValueFunction mFunction
Definition: Prefs.h:195
CachingSettingBase
Class template adds an in-memory cache of a value to SettingBase.
Definition: Prefs.h:84