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 72 of file Shuttle.cpp.

73{
74}

◆ ~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 256 of file Shuttle.cpp.

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

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 76 of file Shuttle.cpp.

77{
78 if( mbStoreInClient )
79 {
80 bValue = bDefault;
81 if( ExchangeWithMaster( Name ))
82 {
83 if( !mValueString.empty() )
84 bValue = mValueString.GetChar(0) == wxT('y');
85 }
86 }
87 else
88 {
89 mValueString = (bValue==0) ? wxT("no"):wxT("yes");
90 return ExchangeWithMaster( Name );
91 }
92 return true;
93}
wxT("CloseDown"))
bool mbStoreInClient
Definition: Shuttle.h:77
virtual bool ExchangeWithMaster(const wxString &Name)
Definition: Shuttle.cpp:256
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 114 of file Shuttle.cpp.

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

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 178 of file Shuttle.cpp.

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

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

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 134 of file Shuttle.cpp.

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

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 153 of file Shuttle.cpp.

154{
155 return TransferLongLong(Name, iValue, iDefault);
156}
virtual bool TransferLongLong(const wxString &Name, wxLongLong_t &iValue, const wxLongLong_t &iDefault)
Definition: Shuttle.cpp:158

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 158 of file Shuttle.cpp.

159{
160 if( mbStoreInClient )
161 {
162 iValue = iDefault;
163 if( ExchangeWithMaster( Name ))
164 {
165 iValue = wxAtoi( mValueString );
166 }
167 }
168 else
169 {
171 mValueString = wxString::Format(wxT("%lld"), (long long) iValue);
172 return ExchangeWithMaster( Name );
173 }
174 return true;
175}

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 219 of file Shuttle.cpp.

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

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 238 of file Shuttle.cpp.

239{
240 if( mbStoreInClient )
241 {
242 if( ExchangeWithMaster( Name ))
243 {
244 W.WriteToAsString( mValueString );
245 }
246 }
247 else
248 {
249 mValueString = W.ReadAsString();
250 return ExchangeWithMaster( Name );
251 }
252 return true;
253}
#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: