Audacity 3.2.0
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
PlainExportOptionsEditor Class Referencefinal

#include <PlainExportOptionsEditor.h>

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

Classes

struct  OptionDesc
 

Public Member Functions

 PlainExportOptionsEditor (std::initializer_list< OptionDesc > options, Listener *listener=nullptr)
 
 PlainExportOptionsEditor (std::initializer_list< OptionDesc > options, SampleRateList samplerates, Listener *listener=nullptr)
 
int GetOptionsCount () const override
 
bool GetOption (int index, ExportOption &option) const override
 
bool GetValue (int id, ExportValue &value) const override
 
bool SetValue (int id, const ExportValue &value) override
 
void Load (const audacity::BasicSettings &config) override
 
void Store (audacity::BasicSettings &) const override
 
SampleRateList GetSampleRateList () const override
 
void SetSampleRateList (SampleRateList rates)
 
- Public Member Functions inherited from ExportOptionsEditor
virtual ~ExportOptionsEditor ()
 
virtual int GetOptionsCount () const =0
 
virtual bool GetOption (int index, ExportOption &option) const =0
 
virtual bool GetValue (ExportOptionID id, ExportValue &value) const =0
 
virtual bool SetValue (ExportOptionID id, const ExportValue &value)=0
 
virtual SampleRateList GetSampleRateList () const =0
 
virtual void Store (audacity::BasicSettings &settings) const =0
 
virtual void Load (const audacity::BasicSettings &config)=0
 

Private Member Functions

void InitOptions (std::initializer_list< OptionDesc > options)
 

Private Attributes

std::vector< ExportOptionmOptions
 
wxArrayString mConfigKeys
 
std::unordered_map< int, ExportValuemValues
 
SampleRateList mRates
 
ListenermOptionsListener {}
 

Additional Inherited Members

- Public Types inherited from ExportOptionsEditor
using SampleRateList = std::vector< int >
 

Detailed Description

Definition at line 19 of file PlainExportOptionsEditor.h.

Constructor & Destructor Documentation

◆ PlainExportOptionsEditor() [1/2]

PlainExportOptionsEditor::PlainExportOptionsEditor ( std::initializer_list< OptionDesc options,
Listener listener = nullptr 
)
explicit

Definition at line 16 of file PlainExportOptionsEditor.cpp.

18 : mOptionsListener(listener)
19{
20 InitOptions(options);
21}
void InitOptions(std::initializer_list< OptionDesc > options)

References InitOptions().

Here is the call graph for this function:

◆ PlainExportOptionsEditor() [2/2]

PlainExportOptionsEditor::PlainExportOptionsEditor ( std::initializer_list< OptionDesc options,
SampleRateList  samplerates,
Listener listener = nullptr 
)
explicit

Definition at line 23 of file PlainExportOptionsEditor.cpp.

26 : mRates(std::move(sampleRates))
27 , mOptionsListener(listener)
28{
29 InitOptions(options);
30}

References InitOptions().

Here is the call graph for this function:

Member Function Documentation

◆ GetOption()

bool PlainExportOptionsEditor::GetOption ( int  index,
ExportOption option 
) const
overridevirtual

Implements ExportOptionsEditor.

Definition at line 37 of file PlainExportOptionsEditor.cpp.

38{
39 if(index >= 0 && index < static_cast<int>(mOptions.size()))
40 {
41 option = mOptions[index];
42 return true;
43 }
44 return false;
45}
std::vector< ExportOption > mOptions

References mOptions.

◆ GetOptionsCount()

int PlainExportOptionsEditor::GetOptionsCount ( ) const
overridevirtual

Implements ExportOptionsEditor.

Definition at line 32 of file PlainExportOptionsEditor.cpp.

33{
34 return static_cast<int>(mOptions.size());
35}

References mOptions.

◆ GetSampleRateList()

ExportOptionsEditor::SampleRateList PlainExportOptionsEditor::GetSampleRateList ( ) const
overridevirtual

Implements ExportOptionsEditor.

Definition at line 112 of file PlainExportOptionsEditor.cpp.

113{
114 return mRates;
115}

References mRates.

◆ GetValue()

bool PlainExportOptionsEditor::GetValue ( int  id,
ExportValue value 
) const
override

Definition at line 47 of file PlainExportOptionsEditor.cpp.

48{
49 const auto it = mValues.find(id);
50 if(it != mValues.end())
51 {
52 value = it->second;
53 return true;
54 }
55 return false;
56}
std::unordered_map< int, ExportValue > mValues

References mValues.

◆ InitOptions()

void PlainExportOptionsEditor::InitOptions ( std::initializer_list< OptionDesc options)
private

Definition at line 124 of file PlainExportOptionsEditor.cpp.

125{
126 assert(mOptions.empty());
127
128 mOptions.reserve(options.size());
129 mValues.reserve(options.size());
130 for(auto& desc : options)
131 {
132 mValues[desc.option.id] = desc.option.defaultValue;
133 mOptions.emplace_back(desc.option);
134 mConfigKeys.push_back(desc.configKey);
135 }
136}
const TranslatableString desc
Definition: ExportPCM.cpp:51

References anonymous_namespace{ExportPCM.cpp}::desc, mConfigKeys, mOptions, and mValues.

Referenced by PlainExportOptionsEditor().

Here is the caller graph for this function:

◆ Load()

void PlainExportOptionsEditor::Load ( const audacity::BasicSettings config)
overridevirtual

Implements ExportOptionsEditor.

Definition at line 69 of file PlainExportOptionsEditor.cpp.

70{
71 auto index = 0;
72 for(const auto& option : mOptions)
73 {
74 auto it = mValues.find(option.id);
75 assert(it != mValues.end());
76 if(auto val = std::get_if<bool>(&it->second))
77 config.Read(mConfigKeys[index], val);
78 else if(auto val = std::get_if<int>(&it->second))
79 config.Read(mConfigKeys[index], val);
80 else if(auto val = std::get_if<double>(&it->second))
81 config.Read(mConfigKeys[index], val);
82 else if(auto val = std::get_if<std::string>(&it->second))
83 {
84 wxString wxstr;
85 if(config.Read(mConfigKeys[index], &wxstr))
86 *val = wxstr.ToStdString();
87 }
88 ++index;
89 }
90}
virtual bool Read(const wxString &key, bool *value) const =0

References mConfigKeys, mOptions, mValues, and audacity::BasicSettings::Read().

Here is the call graph for this function:

◆ SetSampleRateList()

void PlainExportOptionsEditor::SetSampleRateList ( SampleRateList  rates)

Definition at line 117 of file PlainExportOptionsEditor.cpp.

118{
119 mRates = std::move(rates);
122}
virtual void OnSampleRateListChange()=0

References mOptionsListener, mRates, and ExportOptionsEditor::Listener::OnSampleRateListChange().

Here is the call graph for this function:

◆ SetValue()

bool PlainExportOptionsEditor::SetValue ( int  id,
const ExportValue value 
)
override

Definition at line 58 of file PlainExportOptionsEditor.cpp.

59{
60 const auto it = mValues.find(id);
61 if(it != mValues.end() && it->second.index() == value.index())
62 {
63 it->second = value;
64 return true;
65 }
66 return false;
67}

References mValues.

◆ Store()

void PlainExportOptionsEditor::Store ( audacity::BasicSettings config) const
overridevirtual

Implements ExportOptionsEditor.

Definition at line 92 of file PlainExportOptionsEditor.cpp.

93{
94 auto index = 0;
95 for(const auto& option : mOptions)
96 {
97 auto it = mValues.find(option.id);
98 assert(it != mValues.end());
99 if(auto val = std::get_if<bool>(&it->second))
100 config.Write(mConfigKeys[index], *val);
101 else if(auto val = std::get_if<int>(&it->second))
102 config.Write(mConfigKeys[index], *val);
103 else if(auto val = std::get_if<double>(&it->second))
104 config.Write(mConfigKeys[index], *val);
105 else if(auto val = std::get_if<std::string>(&it->second))
106 config.Write(mConfigKeys[index], wxString(*val));
107
108 ++index;
109 }
110}
virtual bool Write(const wxString &key, bool value)=0

References mConfigKeys, mOptions, mValues, and audacity::BasicSettings::Write().

Here is the call graph for this function:

Member Data Documentation

◆ mConfigKeys

wxArrayString PlainExportOptionsEditor::mConfigKeys
private

Definition at line 22 of file PlainExportOptionsEditor.h.

Referenced by InitOptions(), Load(), and Store().

◆ mOptions

std::vector<ExportOption> PlainExportOptionsEditor::mOptions
private

Definition at line 21 of file PlainExportOptionsEditor.h.

Referenced by GetOption(), GetOptionsCount(), InitOptions(), Load(), and Store().

◆ mOptionsListener

Listener* PlainExportOptionsEditor::mOptionsListener {}
private

Definition at line 25 of file PlainExportOptionsEditor.h.

Referenced by SetSampleRateList().

◆ mRates

SampleRateList PlainExportOptionsEditor::mRates
private

Definition at line 24 of file PlainExportOptionsEditor.h.

Referenced by GetSampleRateList(), and SetSampleRateList().

◆ mValues

std::unordered_map<int, ExportValue> PlainExportOptionsEditor::mValues
private

Definition at line 23 of file PlainExportOptionsEditor.h.

Referenced by GetValue(), InitOptions(), Load(), SetValue(), and Store().


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