Audacity  3.0.3
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 19 of file Shuttle.h.

Constructor & Destructor Documentation

◆ Shuttle()

Shuttle::Shuttle ( )

Definition at line 74 of file Shuttle.cpp.

75 {
76 }

◆ ~Shuttle()

virtual Shuttle::~Shuttle ( )
inlinevirtual

Definition at line 23 of file Shuttle.h.

23 {}

Member Function Documentation

◆ ExchangeWithMaster()

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

Reimplemented in ShuttlePrefs, and ShuttleCli.

Definition at line 258 of file Shuttle.cpp.

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

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

79 {
80  if( mbStoreInClient )
81  {
82  bValue = bDefault;
83  if( ExchangeWithMaster( Name ))
84  {
85  if( !mValueString.empty() )
86  bValue = mValueString.GetChar(0) == wxT('y');
87  }
88  }
89  else
90  {
91  mValueString = (bValue==0) ? wxT("no"):wxT("yes");
92  return ExchangeWithMaster( Name );
93  }
94  return true;
95 }

References ExchangeWithMaster(), mbStoreInClient, and mValueString.

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

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

References ExchangeWithMaster(), mbStoreInClient, and mValueString.

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

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

References ExchangeWithMaster(), mbStoreInClient, and mValueString.

Here is the call graph for this function:

◆ TransferFloat()

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

Definition at line 97 of file Shuttle.cpp.

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

References ExchangeWithMaster(), mbStoreInClient, and mValueString.

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

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

References ExchangeWithMaster(), mbStoreInClient, and mValueString.

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

156 {
157  return TransferLongLong(Name, iValue, iDefault);
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 160 of file Shuttle.cpp.

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

References ExchangeWithMaster(), mbStoreInClient, and mValueString.

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

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

References ExchangeWithMaster(), mbStoreInClient, and mValueString.

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

241 {
242  if( mbStoreInClient )
243  {
244  if( ExchangeWithMaster( Name ))
245  {
247  }
248  }
249  else
250  {
252  return ExchangeWithMaster( Name );
253  }
254  return true;
255 }

References ExchangeWithMaster(), mbStoreInClient, mValueString, WrappedType::ReadAsString(), and WrappedType::WriteToAsString().

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:
WrappedType::ReadAsString
wxString ReadAsString()
Definition: WrappedType.cpp:42
Shuttle::TransferLongLong
virtual bool TransferLongLong(const wxString &Name, wxLongLong_t &iValue, const wxLongLong_t &iDefault)
Definition: Shuttle.cpp:160
Shuttle::ExchangeWithMaster
virtual bool ExchangeWithMaster(const wxString &Name)
Definition: Shuttle.cpp:258
Shuttle::mValueString
wxString mValueString
Definition: Shuttle.h:27
Shuttle::mbStoreInClient
bool mbStoreInClient
Definition: Shuttle.h:26
WrappedType::WriteToAsString
void WriteToAsString(const wxString &InStr)
Definition: WrappedType.cpp:152