Audacity 3.2.0
Public Member Functions | Private Member Functions | List of all members
EnumSetting< Enum > Class Template Reference

Adapts EnumSettingBase to a particular enumeration type. More...

#include <Prefs.h>

Inheritance diagram for EnumSetting< Enum >:
[legend]
Collaboration diagram for EnumSetting< Enum >:
[legend]

Public Member Functions

template<typename Key >
 EnumSetting (Key &&key, EnumValueSymbols symbols, long defaultSymbol, std::vector< Enum > values, const wxString &oldKey={})
 
Enum ReadEnum () const
 
Enum ReadEnumWithDefault (Enum defaultValue) const
 
bool WriteEnum (Enum value)
 
- Public Member Functions inherited from EnumSettingBase
template<typename Key >
 EnumSettingBase (Key &&key, EnumValueSymbols symbols, long defaultSymbol, std::vector< int > intValues, const wxString &oldKey={})
 
- Public Member Functions inherited from ChoiceSetting
 ChoiceSetting (const SettingPath &, EnumValueSymbols, long=-1)=delete
 
 ChoiceSetting (TransactionalSettingBase &key, EnumValueSymbols symbols, long defaultSymbol=-1)
 
 ChoiceSetting (const SettingBase &key, EnumValueSymbols symbols, long defaultSymbol=-1)
 
const wxString & Key () const
 
const EnumValueSymbolDefault () const
 
const EnumValueSymbolsGetSymbols () const
 
wxString Read () const
 
wxString ReadWithDefault (const wxString &) const
 
bool Write (const wxString &value)
 
void SetDefault (long value)
 

Private Member Functions

std::vector< int > ConvertValues (const std::vector< Enum > &values)
 

Additional Inherited Members

- Protected Member Functions inherited from EnumSettingBase
int ReadInt () const
 
int ReadIntWithDefault (int defaultValue) const
 
bool WriteInt (int code)
 
size_t FindInt (int code) const
 
void Migrate (wxString &) override
 
- Protected Member Functions inherited from ChoiceSetting
size_t Find (const wxString &value) const
 
virtual void Migrate (wxString &)
 
- Protected Attributes inherited from ChoiceSetting
const wxString mKey
 
const EnumValueSymbols mSymbols
 
TransactionalSettingBase *const mpOtherSettings {}
 
bool mMigrated { false }
 
long mDefaultSymbol
 

Detailed Description

template<typename Enum>
class EnumSetting< Enum >

Adapts EnumSettingBase to a particular enumeration type.

Definition at line 513 of file Prefs.h.

Constructor & Destructor Documentation

◆ EnumSetting()

template<typename Enum >
template<typename Key >
EnumSetting< Enum >::EnumSetting ( Key &&  key,
EnumValueSymbols  symbols,
long  defaultSymbol,
std::vector< Enum >  values,
const wxString &  oldKey = {} 
)
inline
Precondition
intValues.size() == symbols.size()

Definition at line 519 of file Prefs.h.

525 {}
526 )
528 std::forward<Key>(key), move(symbols), defaultSymbol,
529 ConvertValues(values), oldKey
530 }
531 {}
const wxChar * values
static const AudacityProject::AttachedObjects::RegisteredFactory key
std::vector< int > ConvertValues(const std::vector< Enum > &values)
Definition: Prefs.h:550

Member Function Documentation

◆ ConvertValues()

template<typename Enum >
std::vector< int > EnumSetting< Enum >::ConvertValues ( const std::vector< Enum > &  values)
inlineprivate

Definition at line 550 of file Prefs.h.

551 {
552 // To convert scoped enums. This would be easier with std::ranges
553 std::vector<int> result;
554 result.reserve(values.size());
555 for (auto value : values)
556 result.push_back(static_cast<int>(value));
557 return result;
558 }

References values.

◆ ReadEnum()

template<typename Enum >
Enum EnumSetting< Enum >::ReadEnum ( ) const
inline

◆ ReadEnumWithDefault()

template<typename Enum >
Enum EnumSetting< Enum >::ReadEnumWithDefault ( Enum  defaultValue) const
inline

Definition at line 540 of file Prefs.h.

541 {
542 auto integer = static_cast<int>(defaultValue);
543 return static_cast<Enum>( ReadIntWithDefault( integer ) );
544 }
int ReadIntWithDefault(int defaultValue) const
Definition: Prefs.cpp:452

◆ WriteEnum()

template<typename Enum >
bool EnumSetting< Enum >::WriteEnum ( Enum  value)
inline

Definition at line 546 of file Prefs.h.

547 { return WriteInt( static_cast<int>( value ) ); }
bool WriteInt(int code)
Definition: Prefs.cpp:502

References anonymous_namespace{ProjectSerializer.cpp}::WriteInt.

Referenced by anonymous_namespace{AudioComPrefsPanel.cpp}::AudioComPrefsPanel::Cancel(), anonymous_namespace{AudioComPrefsPanel.cpp}::AudioComPrefsPanel::PopulateOrExchange(), SpectrogramSettings::SavePrefs(), and TimeDisplayModeSetting::WriteEnum().

Here is the caller graph for this function:

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