Audacity 3.2.0
ShuttlePrefs.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 ShuttlePrefs.cpp
6
7 Dominic Mazzoni
8 James Crook
9
10 Implements ShuttlePrefs
11
12********************************************************************//*******************************************************************/
26
27#include "ShuttlePrefs.h"
28
29#include <wx/defs.h>
30
31#include "WrappedType.h"
32#include "Prefs.h"
33
34bool ShuttlePrefs::TransferBool( const wxString & Name, bool & bValue, const bool & bDefault )
35{
36 if( mbStoreInClient )
37 {
38 bValue = bDefault;
39 gPrefs->Read( Name, &bValue );
40 }
41 else
42 {
43 return gPrefs->Write( Name, bValue );
44 }
45 return true;
46}
47
48bool ShuttlePrefs::TransferDouble( const wxString & Name, double & dValue, const double &dDefault )
49{
50 if( mbStoreInClient )
51 {
52 dValue = dDefault;
53 gPrefs->Read( Name, &dValue );
54 }
55 else
56 {
57 return gPrefs->Write( Name, dValue );
58 }
59 return true;
60}
61
62bool ShuttlePrefs::TransferInt( const wxString & Name, int & iValue, const int &iDefault )
63{
64 if( mbStoreInClient )
65 {
66 iValue = iDefault;
67 gPrefs->Read( Name, &iValue );
68 }
69 else
70 {
71 return gPrefs->Write( Name, iValue );
72 }
73 return true;
74}
75
76bool ShuttlePrefs::TransferString( const wxString & Name, wxString & strValue, const wxString &strDefault )
77{
78 if( mbStoreInClient )
79 {
80 strValue = strDefault;
81 gPrefs->Read( Name, &strValue );
82 }
83 else
84 {
85 return gPrefs->Write( Name, strValue );
86 }
87 return true;
88}
89
90bool ShuttlePrefs::TransferWrappedType( const wxString & Name, WrappedType & W )
91{
92 switch( W.eWrappedType )
93 {
94 case eWrappedString:
95 return TransferString( Name, *W.mpStr, *W.mpStr );
96 break;
97 case eWrappedInt:
98 return TransferInt( Name, *W.mpInt, *W.mpInt );
99 break;
100 case eWrappedDouble:
101 return TransferDouble( Name, *W.mpDouble, *W.mpDouble );
102 break;
103 case eWrappedBool:
104 return TransferBool( Name, *W.mpBool, *W.mpBool );
105 break;
106 case eWrappedEnum:
107 wxASSERT( false );
108 break;
109 default:
110 wxASSERT( false );
111 break;
112 }
113 return false;
114}
115
116bool ShuttlePrefs::ExchangeWithMaster(const wxString & WXUNUSED(Name))
117{
118 // ShuttlePrefs is unusual in that it overloads ALL the Transfer functions
119 // which it supports. It doesn't do any string conversion, because wxConv will
120 // do so if it is required.
121 // So, ExchangeWithMaster should never get called... Hence the ASSERT here.
122 wxASSERT( false );
123 return false;
124}
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
#define W(N, I)
Definition: ToChars.cpp:60
@ eWrappedDouble
Definition: WrappedType.h:20
@ eWrappedEnum
Definition: WrappedType.h:22
@ eWrappedInt
Definition: WrappedType.h:19
@ eWrappedBool
Definition: WrappedType.h:21
@ eWrappedString
Definition: WrappedType.h:18
bool TransferBool(const wxString &Name, bool &bValue, const bool &bDefault)
bool TransferDouble(const wxString &Name, double &dValue, const double &dDefault)
bool TransferWrappedType(const wxString &Name, WrappedType &W)
bool TransferInt(const wxString &Name, int &iValue, const int &iDefault)
bool ExchangeWithMaster(const wxString &Name)
bool mbStoreInClient
Definition: ShuttlePrefs.h:20
bool TransferString(const wxString &Name, wxString &strValue, const wxString &strDefault)
Used in type conversions, this wrapper for ints, strings, doubles and enums provides conversions betw...
Definition: WrappedType.h:28
virtual bool Write(const wxString &key, bool value)=0
virtual bool Read(const wxString &key, bool *value) const =0