gehe zur Dokumentation dieser Datei00001
00072 #ifndef EDEVICE_H
00073 #define EDEVICE_H
00074
00075 #include <cstring>
00076 #include "wx/wx.h"
00077 #include "Global.h"
00078
00079 #include "wx/string.h"
00080 #include "wx/config.h"
00081 #include "Device.h"
00082 #include "DevGIS.h"
00083 #include "DevMidi.h"
00084 #include "DevMidF.h"
00085 #include "Runtime.h"
00086
00087 class EDevice;
00088
00090
00091 extern EDevice *InEDevices;
00092
00094 extern EDevice *OutEDevices;
00095
00096 #define INIT_BENDINGRANGE 2
00097
00098
00099
00101 #define NoBox -2
00102 #define GmnBox -1
00103
00105
00108 class ERoute
00109 {
00110
00111 public:
00113 ERoute *Next;
00115 char Id;
00117 RouteType Type;
00119 int IFrom;
00121 int ITo;
00123 int Box;
00125 bool Active;
00127 EDevice *Out;
00129 int OFrom;
00131 int OTo;
00133 bool ONoDrum;
00134
00136
00147 ERoute(RouteType type,
00148 int iFrom, int iTo,
00149 int box, bool active,
00150 EDevice *out, int oFrom = -1, int oTo = -1, bool oNoDrum = true)
00151 {
00152 Type = type;
00153 IFrom = iFrom;
00154 ITo = iTo;
00155 Box = box;
00156 Active = active;
00157 Out = out;
00158 OFrom = oFrom;
00159 OTo = oTo;
00160 ONoDrum = oNoDrum;
00161 Next = 0;
00162 }
00163
00165
00167 ~ERoute()
00168 {
00169 if ( Next ) delete Next;
00170 }
00171
00173
00175 Route * newRoute();
00176 };
00177
00179
00182 class EDevice
00183 {
00184
00185 public:
00187 EDevice *Next;
00189 wxString Name;
00191 DevType DT;
00193 ERoute *Routes;
00195 int DevId;
00197 int BendingRange;
00199 int Nr;
00201 MutaborModeType Mode;
00202
00204
00211 EDevice(DevType dt, const wxString& name = wxEmptyString, int devId = 0)
00212 {
00213 DT = dt;
00214 Name = name;
00215 Next = 0;
00216 Routes = 0;
00217 DevId = devId;
00218 BendingRange = INIT_BENDINGRANGE;
00219 Mode = MutaborDeviceUnregistered;
00220 Nr = -1;
00221 }
00222
00224
00228 ~EDevice()
00229 {
00230 if ( Routes )
00231 delete Routes;
00232
00233 if ( Next )
00234 delete Next;
00235 }
00236
00238
00241 ERoute *GetRoute(int nr);
00242
00244
00247 int nRoutes();
00248
00250
00253 void AddRoute(ERoute *route);
00254
00256
00260 wxString GetName();
00261
00263
00265 OutDevice * newOutDevice()
00266 {
00267 DEBUGLOG(other,_T("Device Type: %d"),DT);
00268 switch (DT) {
00269 case DTNotSet:
00270 wxLogError(_("Device type not set"));
00271 return NULL;
00272
00273 case DTUnknown:
00274 wxLogError(_("Unknown device."));
00275 return NULL;
00276 break;
00277
00278
00279 case DTGis:
00280 STUBC;
00281 return new OutGis(Name,0);
00282 break;
00283
00284 case DTMidiPort:
00285 return new OutMidiPort(Name, DevId, BendingRange);
00286 break;
00287
00288 case DTMidiFile:
00289 return new OutMidiFile(Name, DevId, BendingRange);
00290 break;
00291
00292 default:
00293 UNREACHABLEC;
00294 wxLogError(_("Unknown device type %d."), DT);
00295 return NULL;
00296 }
00297 }
00298
00300
00302 InDevice * newInDevice()
00303 {
00304 switch (DT) {
00305
00306 case DTNotSet:
00307 wxLogError(_("Device type not set"));
00308
00309 return NULL;
00310
00311 case DTUnknown:
00312 wxLogError(_("Unknown device."));
00313
00314 return NULL;
00315
00316
00317
00318 case DTGis:
00319 Mode = MutaborDeviceStop;
00320
00321 return new InGis(Name, _T("GIS"));
00322
00323 break;
00324
00325 case DTMidiPort:
00326 return new InMidiPort(Name, DevId);
00327
00328 break;
00329
00330 case DTMidiFile:
00331 Mode = MutaborDeviceStop;
00332
00333 return new InMidiFile(Name, 0);
00334
00335 break;
00336
00337 default:
00338 wxLogError(_("Unknown device type %d."),DT);
00339
00340 return NULL;
00341 }
00342 }
00343
00344 };
00345
00346
00347 inline Route * ERoute::newRoute()
00348 {
00349 if (Box == -2)
00350 Active = false;
00351
00352 OutDevice * o;
00353
00354 if (Out) o = GetOut(Out->DevId);
00355 else o = NULL;
00356
00357 #ifdef DEBUG
00358 DEBUGLOG(other,_T("Out: %x, o: %x"),Out,o);
00359
00360 #endif
00361 return new Route(NULL, o,
00362 Type,
00363 IFrom, ITo,
00364 Box, Active,
00365 OFrom, OTo, ONoDrum);
00366
00367 }
00368
00370
00378 EDevice* NewDevice(EDevice **List,
00379 DevType dt,
00380 const wxString& name,
00381 int devId,
00382 EDevice *oldPos = 0,
00383 EDevice *newPos = 0);
00384
00386
00388 void ScanRoutes(char *config);
00389
00391
00393 void ScanRoutes(const wxString& config);
00394
00396
00398 void ScanRoutes(wxConfigBase * config);
00399
00401
00403 void WriteRoutes(char **config);
00404
00406
00408 void WriteRoutes(wxString &config);
00409
00411
00413 void WriteRoutes(wxConfigBase *config);
00414
00416 extern bool BoxUsed[MAX_BOX];
00417
00419 void CheckBoxesUsed();
00420
00422 void ScanDevices();
00423
00424 #endif
00425