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