Audacity 3.2.0
Public Member Functions | Public Attributes | List of all members
Shuttle Class Reference

Moves data from one place to another, converting it as required. More...

#include <Shuttle.h>

Inheritance diagram for Shuttle:
[legend]

Public Member Functions

 Shuttle ()
 
virtual ~Shuttle ()
 
virtual bool TransferBool (const wxString &Name, bool &bValue, const bool &bDefault)
 
virtual bool TransferFloat (const wxString &Name, float &fValue, const float &fDefault)
 
virtual bool TransferDouble (const wxString &Name, double &dValue, const double &dDefault)
 
virtual bool TransferInt (const wxString &Name, int &iValue, const int &iDefault)
 
virtual bool TransferInt (const wxString &Name, wxLongLong_t &iValue, const wxLongLong_t &iDefault)
 
virtual bool TransferLongLong (const wxString &Name, wxLongLong_t &iValue, const wxLongLong_t &iDefault)
 
virtual bool TransferString (const wxString &Name, wxString &strValue, const wxString &strDefault)
 
virtual bool TransferEnum (const wxString &Name, int &iValue, const int nChoices, const wxString *pFirstStr)
 
virtual bool TransferWrappedType (const wxString &Name, WrappedType &W)
 
virtual bool ExchangeWithMaster (const wxString &Name)
 

Public Attributes

bool mbStoreInClient
 
wxString mValueString
 

Detailed Description

Moves data from one place to another, converting it as required.

Shuttle provides a base class for transferring parameter data into and out of classes into some other structure. This is a common requirement and is needed for:

The 'Master' is the string side of the shuttle transfer, the 'Client' is the binary data side of the transfer.

See also
ShuttleBase
ShuttleGui

Definition at line 70 of file Shuttle.h.

Constructor & Destructor Documentation

◆ Shuttle()

Shuttle::Shuttle ( )

Definition at line 68 of file Shuttle.cpp.

69{
70}

◆ ~Shuttle()

virtual Shuttle::~Shuttle ( )
inlinevirtual

Definition at line 74 of file Shuttle.h.

74{}

Member Function Documentation

◆ ExchangeWithMaster()

bool Shuttle::ExchangeWithMaster ( const wxString &  Name)
virtual

Reimplemented in ShuttleCli, and ShuttlePrefs.

Definition at line 252 of file Shuttle.cpp.

253{
254 // ExchangeWithMaster() will usually be over-ridden
255 // in derived classes. We could have made it an
256 // abstract function.
257 wxASSERT( false );
258 return true;
259}

Referenced by TransferBool(), TransferDouble(), TransferEnum(), TransferFloat(), TransferInt(), TransferLongLong(), TransferString(), and TransferWrappedType().

Here is the caller graph for this function:

◆ TransferBool()

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

Reimplemented in ShuttlePrefs.

Definition at line 72 of file Shuttle.cpp.

73{
74 if( mbStoreInClient )
75 {
76 bValue = bDefault;
77 if( ExchangeWithMaster( Name ))
78 {
79 if( !mValueString.empty() )
80 bValue = mValueString.GetChar(0) == wxT('y');
81 }
82 }
83 else
84 {
85 mValueString = (bValue==0) ? wxT("no"):wxT("yes");
86 return ExchangeWithMaster( Name );
87 }
88 return true;
89}
wxT("CloseDown"))
bool mbStoreInClient
Definition: Shuttle.h:77
virtual bool ExchangeWithMaster(const wxString &Name)
Definition: Shuttle.cpp:252
wxString mValueString
Definition: Shuttle.h:78

References ExchangeWithMaster(), mbStoreInClient, mValueString, and wxT().

Here is the call graph for this function:

◆ TransferDouble()

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

Reimplemented in ShuttlePrefs.

Definition at line 110 of file Shuttle.cpp.

111{
112 if( mbStoreInClient )
113 {
114 dValue = dDefault;
115 if( ExchangeWithMaster( Name ))
116 {
117 if( !mValueString.empty() )
118 dValue = wxAtof( mValueString );
119 }
120 }
121 else
122 {
123 //%f is format string for double
124 mValueString = wxString::Format(wxT("%f"),dValue);
125 return ExchangeWithMaster( Name );
126 }
127 return true;
128}

References ExchangeWithMaster(), mbStoreInClient, mValueString, and wxT().

Here is the call graph for this function:

◆ TransferEnum()

bool Shuttle::TransferEnum ( const wxString &  Name,
int &  iValue,
const int  nChoices,
const wxString *  pFirstStr 
)
virtual

Definition at line 174 of file Shuttle.cpp.

176{
177 if( mbStoreInClient )
178 {
179 iValue = 0;// default index if none other selected.
180 if( ExchangeWithMaster( Name ))
181 {
182 wxString str = mValueString;
183 if( str.Left( 1 ) == wxT('"') && str.Right( 1 ) == wxT('"') )
184 {
185 str = str.Mid( 2, str.length() - 2 );
186 }
187
188 for( int i = 0; i < nChoices; i++ )
189 {
190 if( str == pFirstStr[i] )
191 {
192 iValue = i;
193 break;
194 }
195 }
196 }
197 }
198 else
199 {
200 //TIDY-ME: Out of range configuration values are silently discarded...
201 if( iValue > nChoices )
202 iValue = 0;
203 if( iValue < 0 )
204 iValue = 0;
205 mValueString = pFirstStr[iValue];
206 if( mValueString.Find( wxT(' ') ) != wxNOT_FOUND )
207 {
208 mValueString = wxT('"') + pFirstStr[iValue] + wxT('"'); //strings have quotes around them
209 }
210 return ExchangeWithMaster( Name );
211 }
212 return true;
213}
#define str(a)

References ExchangeWithMaster(), mbStoreInClient, mValueString, str, and wxT().

Here is the call graph for this function:

◆ TransferFloat()

bool Shuttle::TransferFloat ( const wxString &  Name,
float &  fValue,
const float &  fDefault 
)
virtual

Definition at line 91 of file Shuttle.cpp.

92{
93 if( mbStoreInClient )
94 {
95 fValue = fDefault;
96 if( ExchangeWithMaster( Name ))
97 {
98 if( !mValueString.empty() )
99 fValue = wxAtof( mValueString );
100 }
101 }
102 else
103 {
104 mValueString = wxString::Format(wxT("%f"),fValue);
105 return ExchangeWithMaster( Name );
106 }
107 return true;
108}

References ExchangeWithMaster(), mbStoreInClient, mValueString, and wxT().

Here is the call graph for this function:

◆ TransferInt() [1/2]

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

Reimplemented in ShuttlePrefs.

Definition at line 130 of file Shuttle.cpp.

131{
132 if( mbStoreInClient )
133 {
134 iValue = iDefault;
135 if( ExchangeWithMaster( Name ))
136 {
137 iValue = wxAtoi( mValueString );
138 }
139 }
140 else
141 {
142 mValueString = wxString::Format(wxT("%i"),iValue);
143 return ExchangeWithMaster( Name );
144 }
145 return true;
146}

References ExchangeWithMaster(), mbStoreInClient, mValueString, and wxT().

Here is the call graph for this function:

◆ TransferInt() [2/2]

bool Shuttle::TransferInt ( const wxString &  Name,
wxLongLong_t &  iValue,
const wxLongLong_t &  iDefault 
)
virtual

Definition at line 149 of file Shuttle.cpp.

150{
151 return TransferLongLong(Name, iValue, iDefault);
152}
virtual bool TransferLongLong(const wxString &Name, wxLongLong_t &iValue, const wxLongLong_t &iDefault)
Definition: Shuttle.cpp:154

References TransferLongLong().

Here is the call graph for this function:

◆ TransferLongLong()

bool Shuttle::TransferLongLong ( const wxString &  Name,
wxLongLong_t &  iValue,
const wxLongLong_t &  iDefault 
)
virtual
Todo:
Fix for long long values.

Definition at line 154 of file Shuttle.cpp.

155{
156 if( mbStoreInClient )
157 {
158 iValue = iDefault;
159 if( ExchangeWithMaster( Name ))
160 {
161 iValue = wxAtoi( mValueString );
162 }
163 }
164 else
165 {
167 mValueString = wxString::Format(wxT("%lld"), (long long) iValue);
168 return ExchangeWithMaster( Name );
169 }
170 return true;
171}

References ExchangeWithMaster(), mbStoreInClient, mValueString, and wxT().

Referenced by TransferInt().

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

◆ TransferString()

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

Reimplemented in ShuttlePrefs.

Definition at line 215 of file Shuttle.cpp.

216{
217 if( mbStoreInClient )
218 {
219 if( ExchangeWithMaster( Name ))
220 {
221 strValue = mValueString;
222 }
223 else
224 return false;
225 }
226 else
227 {
228 mValueString = wxT('"') + strValue + wxT('"'); //strings have quotes around them
229 return ExchangeWithMaster( Name );
230 }
231 return true;
232}

References ExchangeWithMaster(), mbStoreInClient, mValueString, and wxT().

Referenced by CommandBuilder::BuildCommand().

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

◆ TransferWrappedType()

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

Reimplemented in ShuttlePrefs.

Definition at line 234 of file Shuttle.cpp.

235{
236 if( mbStoreInClient )
237 {
238 if( ExchangeWithMaster( Name ))
239 {
240 W.WriteToAsString( mValueString );
241 }
242 }
243 else
244 {
245 mValueString = W.ReadAsString();
246 return ExchangeWithMaster( Name );
247 }
248 return true;
249}
#define W(N, I)
Definition: ToChars.cpp:60

References ExchangeWithMaster(), mbStoreInClient, mValueString, and W.

Here is the call graph for this function:

Member Data Documentation

◆ mbStoreInClient

bool Shuttle::mbStoreInClient

◆ mValueString

wxString Shuttle::mValueString

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