Audacity 3.2.0
Public Member Functions | Public Attributes | List of all members
ShuttlePrefs Class Referencefinal

A kind of Shuttle to exchange data with preferences e.g. the registry. More...

#include <ShuttlePrefs.h>

Public Member Functions

 ShuttlePrefs ()
 
 ~ShuttlePrefs ()
 
bool TransferBool (const wxString &Name, bool &bValue, const bool &bDefault)
 
bool TransferDouble (const wxString &Name, double &dValue, const double &dDefault)
 
bool TransferInt (const wxString &Name, int &iValue, const int &iDefault)
 
bool TransferString (const wxString &Name, wxString &strValue, const wxString &strDefault)
 
bool TransferWrappedType (const wxString &Name, WrappedType &W)
 
bool ExchangeWithMaster (const wxString &Name)
 

Public Attributes

bool mbStoreInClient {}
 
wxString mValueString
 

Detailed Description

A kind of Shuttle to exchange data with preferences e.g. the registry.

This class may be used by ShuttleGui to do the two step exchange,

     Gui -- Data -- Prefs

Definition at line 17 of file ShuttlePrefs.h.

Constructor & Destructor Documentation

◆ ShuttlePrefs()

ShuttlePrefs::ShuttlePrefs ( )
inline

Definition at line 24 of file ShuttlePrefs.h.

24{}

◆ ~ShuttlePrefs()

ShuttlePrefs::~ShuttlePrefs ( )
inline

Definition at line 25 of file ShuttlePrefs.h.

25{}

Member Function Documentation

◆ ExchangeWithMaster()

bool ShuttlePrefs::ExchangeWithMaster ( const wxString &  Name)

Definition at line 116 of file ShuttlePrefs.cpp.

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}

◆ TransferBool()

bool ShuttlePrefs::TransferBool ( const wxString &  Name,
bool &  bValue,
const bool &  bDefault 
)

Definition at line 34 of file ShuttlePrefs.cpp.

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}
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
bool mbStoreInClient
Definition: ShuttlePrefs.h:20
virtual bool Write(const wxString &key, bool value)=0
virtual bool Read(const wxString &key, bool *value) const =0

References gPrefs, mbStoreInClient, audacity::BasicSettings::Read(), and audacity::BasicSettings::Write().

Referenced by TransferWrappedType().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TransferDouble()

bool ShuttlePrefs::TransferDouble ( const wxString &  Name,
double &  dValue,
const double &  dDefault 
)

Definition at line 48 of file ShuttlePrefs.cpp.

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}

References gPrefs, mbStoreInClient, audacity::BasicSettings::Read(), and audacity::BasicSettings::Write().

Referenced by TransferWrappedType().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TransferInt()

bool ShuttlePrefs::TransferInt ( const wxString &  Name,
int &  iValue,
const int &  iDefault 
)

Definition at line 62 of file ShuttlePrefs.cpp.

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}

References gPrefs, mbStoreInClient, audacity::BasicSettings::Read(), and audacity::BasicSettings::Write().

Referenced by TransferWrappedType().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TransferString()

bool ShuttlePrefs::TransferString ( const wxString &  Name,
wxString &  strValue,
const wxString &  strDefault 
)

Definition at line 76 of file ShuttlePrefs.cpp.

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}

References gPrefs, mbStoreInClient, audacity::BasicSettings::Read(), and audacity::BasicSettings::Write().

Referenced by TransferWrappedType().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TransferWrappedType()

bool ShuttlePrefs::TransferWrappedType ( const wxString &  Name,
WrappedType W 
)

Definition at line 90 of file ShuttlePrefs.cpp.

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}
#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 TransferInt(const wxString &Name, int &iValue, const int &iDefault)
bool TransferString(const wxString &Name, wxString &strValue, const wxString &strDefault)

References eWrappedBool, eWrappedDouble, eWrappedEnum, eWrappedInt, eWrappedString, TransferBool(), TransferDouble(), TransferInt(), TransferString(), and W.

Here is the call graph for this function:

Member Data Documentation

◆ mbStoreInClient

bool ShuttlePrefs::mbStoreInClient {}

Definition at line 20 of file ShuttlePrefs.h.

Referenced by TransferBool(), TransferDouble(), TransferInt(), and TransferString().

◆ mValueString

wxString ShuttlePrefs::mValueString

Definition at line 21 of file ShuttlePrefs.h.


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