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 506 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 512 of file Prefs.h.

518 {}
519 )
521 std::forward<Key>(key), move(symbols), defaultSymbol,
522 ConvertValues(values), oldKey
523 }
524 {}
static const AudacityProject::AttachedObjects::RegisteredFactory key
const wxChar * values
std::vector< int > ConvertValues(const std::vector< Enum > &values)
Definition: Prefs.h:543

Member Function Documentation

◆ ConvertValues()

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

Definition at line 543 of file Prefs.h.

544 {
545 // To convert scoped enums. This would be easier with std::ranges
546 std::vector<int> result;
547 result.reserve(values.size());
548 for (auto value : values)
549 result.push_back(static_cast<int>(value));
550 return result;
551 }

References values.

◆ ReadEnum()

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

Definition at line 527 of file Prefs.h.

528 { return static_cast<Enum>( ReadInt() ); }
int ReadInt() const
Definition: Prefs.cpp:409

References anonymous_namespace{ProjectSerializer.cpp}::ReadInt.

Referenced by Dither::BestDitherChoice(), Exporter::CheckMix(), NoteTrack::ExportAllegro(), Dither::FastDitherChoice(), SpectrogramSettings::LoadPrefs(), Resample::SetMethod(), SpectrogramSettings::UpdatePrefs(), and TracksPrefs::ViewModeChoice().

Here is the caller graph for this function:

◆ ReadEnumWithDefault()

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

Definition at line 533 of file Prefs.h.

534 {
535 auto integer = static_cast<int>(defaultValue);
536 return static_cast<Enum>( ReadIntWithDefault( integer ) );
537 }
int ReadIntWithDefault(int defaultValue) const
Definition: Prefs.cpp:417

◆ WriteEnum()

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

Definition at line 539 of file Prefs.h.

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

References anonymous_namespace{ProjectSerializer.cpp}::WriteInt.

Referenced by SpectrogramSettings::SavePrefs().

Here is the caller graph for this function:

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