Audacity  2.2.2
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:
ShuttleCli ShuttleParams ShuttlePrefs ShuttleDefaults ShuttleGetAutomation ShuttleGetDefinition ShuttleSetAutomation

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 transfering parameter data into and out of clasess 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 20 of file Shuttle.h.

Constructor & Destructor Documentation

Shuttle::Shuttle ( )

Definition at line 76 of file Shuttle.cpp.

77 {
78 }
virtual Shuttle::~Shuttle ( )
inlinevirtual

Definition at line 24 of file Shuttle.h.

24 {}

Member Function Documentation

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

Reimplemented in ShuttleParams, ShuttleCli, and ShuttlePrefs.

Definition at line 260 of file Shuttle.cpp.

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

261 {
262  // ExchangeWithMaster() will usually be over-ridden
263  // in derived classes. We could have made it an
264  // abstract function.
265  wxASSERT( false );
266  return true;
267 }
bool Shuttle::TransferBool ( const wxString &  Name,
bool &  bValue,
const bool &  bDefault 
)
virtual

Reimplemented in ShuttlePrefs.

Definition at line 80 of file Shuttle.cpp.

References ExchangeWithMaster(), mbStoreInClient, and mValueString.

81 {
82  if( mbStoreInClient )
83  {
84  bValue = bDefault;
85  if( ExchangeWithMaster( Name ))
86  {
87  if( !mValueString.IsEmpty() )
88  bValue = mValueString.GetChar(0) == wxT('y');
89  }
90  }
91  else
92  {
93  mValueString = (bValue==0) ? wxT("no"):wxT("yes");
94  return ExchangeWithMaster( Name );
95  }
96  return true;
97 }
virtual bool ExchangeWithMaster(const wxString &Name)
Definition: Shuttle.cpp:260
bool mbStoreInClient
Definition: Shuttle.h:27
wxString mValueString
Definition: Shuttle.h:28
bool Shuttle::TransferDouble ( const wxString &  Name,
double &  dValue,
const double &  dDefault 
)
virtual

Reimplemented in ShuttlePrefs.

Definition at line 118 of file Shuttle.cpp.

References ExchangeWithMaster(), mbStoreInClient, and mValueString.

119 {
120  if( mbStoreInClient )
121  {
122  dValue = dDefault;
123  if( ExchangeWithMaster( Name ))
124  {
125  if( !mValueString.IsEmpty() )
126  dValue = wxAtof( mValueString );
127  }
128  }
129  else
130  {
131  //%f is format string for double
132  mValueString = wxString::Format(wxT("%f"),dValue);
133  return ExchangeWithMaster( Name );
134  }
135  return true;
136 }
virtual bool ExchangeWithMaster(const wxString &Name)
Definition: Shuttle.cpp:260
bool mbStoreInClient
Definition: Shuttle.h:27
wxString mValueString
Definition: Shuttle.h:28
bool Shuttle::TransferEnum ( const wxString &  Name,
int &  iValue,
const int  nChoices,
const wxString *  pFirstStr 
)
virtual

Definition at line 182 of file Shuttle.cpp.

References ExchangeWithMaster(), mbStoreInClient, and mValueString.

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

Definition at line 99 of file Shuttle.cpp.

References ExchangeWithMaster(), mbStoreInClient, and mValueString.

100 {
101  if( mbStoreInClient )
102  {
103  fValue = fDefault;
104  if( ExchangeWithMaster( Name ))
105  {
106  if( !mValueString.IsEmpty() )
107  fValue = wxAtof( mValueString );
108  }
109  }
110  else
111  {
112  mValueString = wxString::Format(wxT("%f"),fValue);
113  return ExchangeWithMaster( Name );
114  }
115  return true;
116 }
virtual bool ExchangeWithMaster(const wxString &Name)
Definition: Shuttle.cpp:260
bool mbStoreInClient
Definition: Shuttle.h:27
wxString mValueString
Definition: Shuttle.h:28
bool Shuttle::TransferInt ( const wxString &  Name,
int &  iValue,
const int &  iDefault 
)
virtual

Reimplemented in ShuttlePrefs.

Definition at line 138 of file Shuttle.cpp.

References ExchangeWithMaster(), mbStoreInClient, and mValueString.

139 {
140  if( mbStoreInClient )
141  {
142  iValue = iDefault;
143  if( ExchangeWithMaster( Name ))
144  {
145  iValue = wxAtoi( mValueString );
146  }
147  }
148  else
149  {
150  mValueString = wxString::Format(wxT("%i"),iValue);
151  return ExchangeWithMaster( Name );
152  }
153  return true;
154 }
virtual bool ExchangeWithMaster(const wxString &Name)
Definition: Shuttle.cpp:260
bool mbStoreInClient
Definition: Shuttle.h:27
wxString mValueString
Definition: Shuttle.h:28
bool Shuttle::TransferInt ( const wxString &  Name,
wxLongLong_t &  iValue,
const wxLongLong_t &  iDefault 
)
virtual

Definition at line 157 of file Shuttle.cpp.

References TransferLongLong().

158 {
159  return TransferLongLong(Name, iValue, iDefault);
160 }
virtual bool TransferLongLong(const wxString &Name, wxLongLong_t &iValue, const wxLongLong_t &iDefault)
Definition: Shuttle.cpp:162
bool Shuttle::TransferLongLong ( const wxString &  Name,
wxLongLong_t &  iValue,
const wxLongLong_t &  iDefault 
)
virtual
Todo:
Fix for long long values.

Definition at line 162 of file Shuttle.cpp.

References ExchangeWithMaster(), mbStoreInClient, and mValueString.

Referenced by TransferInt().

163 {
164  if( mbStoreInClient )
165  {
166  iValue = iDefault;
167  if( ExchangeWithMaster( Name ))
168  {
169  iValue = wxAtoi( mValueString );
170  }
171  }
172  else
173  {
175  mValueString = wxString::Format(wxT("%lld"), (long long) iValue);
176  return ExchangeWithMaster( Name );
177  }
178  return true;
179 }
virtual bool ExchangeWithMaster(const wxString &Name)
Definition: Shuttle.cpp:260
bool mbStoreInClient
Definition: Shuttle.h:27
wxString mValueString
Definition: Shuttle.h:28
bool Shuttle::TransferString ( const wxString &  Name,
wxString &  strValue,
const wxString &  strDefault 
)
virtual

Reimplemented in ShuttlePrefs.

Definition at line 223 of file Shuttle.cpp.

References ExchangeWithMaster(), mbStoreInClient, and mValueString.

Referenced by CommandBuilder::BuildCommand().

224 {
225  if( mbStoreInClient )
226  {
227  if( ExchangeWithMaster( Name ))
228  {
229  strValue = mValueString;
230  }
231  else
232  return false;
233  }
234  else
235  {
236  mValueString = wxT('"') + strValue + wxT('"'); //strings have quotes around them
237  return ExchangeWithMaster( Name );
238  }
239  return true;
240 }
virtual bool ExchangeWithMaster(const wxString &Name)
Definition: Shuttle.cpp:260
bool mbStoreInClient
Definition: Shuttle.h:27
wxString mValueString
Definition: Shuttle.h:28
bool Shuttle::TransferWrappedType ( const wxString &  Name,
WrappedType W 
)
virtual

Reimplemented in ShuttlePrefs.

Definition at line 242 of file Shuttle.cpp.

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

243 {
244  if( mbStoreInClient )
245  {
246  if( ExchangeWithMaster( Name ))
247  {
249  }
250  }
251  else
252  {
254  return ExchangeWithMaster( Name );
255  }
256  return true;
257 }
virtual bool ExchangeWithMaster(const wxString &Name)
Definition: Shuttle.cpp:260
wxString ReadAsString()
void WriteToAsString(const wxString &InStr)
bool mbStoreInClient
Definition: Shuttle.h:27
wxString mValueString
Definition: Shuttle.h:28

Member Data Documentation

bool Shuttle::mbStoreInClient
wxString Shuttle::mValueString

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