00001
00002
00114 #ifndef MUTABOR_ROUTE_H
00115 #define MUTABOR_ROUTE_H
00116
00117 #include "Defs.h"
00118
00119 #ifdef WX
00120 #include "wx/config.h"
00121 #endif
00122
00123 #include "treestorage.h"
00124
00125
00126
00127 enum BoxType
00128 {
00129 NewBox = -3,
00130 NoBox,
00131 GmnBox,
00132 Box0
00133 };
00134
00136 enum RouteType
00137 {
00138 RTall, RTelse, RTchannel, RTstaff
00139 };
00140
00141 extern const mutString RTName[];
00142
00143 class OutDevice;
00144 class InDevice;
00145
00146 class Route
00147 {
00148
00149
00150
00151
00152
00153
00154 WATCHEDPTR(void,routing,Route) userdata;
00155 WATCHEDPTR(Route,routing,Route) Next;
00156 WATCHEDPTR(OutDevice,routing,Route) Out;
00157 WATCHEDPTR(InDevice,routing,Route) In;
00158 WATCHEDPTR(Route,routing,Route) globalNext;
00159 static WATCHEDPTR(Route,routing,Route) routeList;
00160 int Id;
00161 int inputid;
00162 int outputid;
00163 public:
00164 RouteType Type;
00165 int IFrom, ITo;
00166 int Box;
00167 bool Active;
00168 int OFrom, OTo;
00169 bool ONoDrum;
00170 static int maxRouteId;
00171
00172
00173
00174 Route(
00175 InDevice * in = NULL,
00176 OutDevice *out = NULL,
00177 RouteType type = RTall,
00178 int iFrom = -1,
00179 int iTo = -1,
00180 int box = -1,
00181 bool active = false,
00182 int oFrom = -1,
00183 int oTo = -1,
00184 bool oNoDrum = true,
00185 Route *next = 0):userdata(this,_T("userdata")),
00186 Next(this,_T("Next"),next),
00187 Out(this,_T("Out"),out),
00188 In(this,_T("In"),in),
00189 globalNext(this,_T("Global Next"),NULL)
00190 {
00191 Type = type;
00192 IFrom = iFrom;
00193 ITo = iTo;
00194 Box = box;
00195 Active = active;
00196 OFrom = oFrom;
00197 OTo = oTo;
00198 ONoDrum = oNoDrum;
00199 Id = NextRouteId();
00200 AppendToRouteList(this);
00201 }
00202
00203 virtual ~Route()
00204 {
00205 DEBUGLOG(routing,_T("deleting chain from %p"));
00206 if ( Next ) delete Next;
00207 DEBUGLOG(routing,_T("deleting %p"));
00208 RemoveFromRouteList(this);
00209 }
00210
00212
00214 virtual void Save(tree_storage & config);
00215
00217
00219 virtual void Load(tree_storage & config);
00220
00221 static unsigned int NextRouteId() {
00222 return maxRouteId++;
00223 }
00224
00225
00226 char Check(int i)
00227 {
00228 return (IFrom <= i && i <= ITo);
00229 }
00230
00231 void setUserData (void * data)
00232 {
00233 userdata = data;
00234 }
00235
00236 void * getUserData() const
00237 {
00238 return userdata;
00239 }
00240
00241 OutDevice * GetOutDevice() const {
00242 return Out;
00243 }
00244
00245 void SetOutDevice (OutDevice * out)
00246 {
00247 Out = out;
00248 }
00249
00250 InDevice * GetInDevice() const {
00251 return In;
00252 }
00253
00254 void SetInDevice (InDevice * in)
00255 {
00256 In = in;
00257 for (Route * route = GetNext(); route; route=route->GetNext())
00258 route -> In = in;
00259 }
00260
00261 void SetInputId(int Id)
00262 {
00263 inputid = Id;
00264 }
00265
00266
00267 bool GetActive() const
00268 {
00269 return Active;
00270 }
00271
00272 void SetActive(bool active)
00273 {
00274 Active = active;
00275 }
00276
00277 int GetBox() const
00278 {
00279 return Box;
00280 }
00281
00282 void SetBox(int box)
00283 {
00284 Box = box;
00285 }
00286
00287 RouteType GetType() const
00288 {
00289 return Type;
00290 }
00291
00292 void SetType(RouteType type)
00293 {
00294 Type = type;
00295 }
00296
00297 const mutString & GetTypeName()
00298 {
00299 return RTName[Type];
00300 }
00301
00302 int GetInputFrom() const
00303 {
00304 return IFrom;
00305 }
00306
00307 void SetInputFrom(int i)
00308 {
00309 IFrom = i;
00310 }
00311
00312 int GetOutputFrom() const
00313 {
00314 return OFrom;
00315 }
00316
00317 void SetOutputFrom(int o)
00318 {
00319 OFrom = o;
00320 }
00321
00322 int GetInputTo() const
00323 {
00324 return ITo;
00325 }
00326
00327 void SetInputTo(int i)
00328 {
00329 ITo = i;
00330 }
00331
00332 int GetOutputTo() const
00333 {
00334 return OTo;
00335 }
00336
00337 void SetOutputTo(int o)
00338 {
00339 OTo = o;
00340 }
00341
00342
00343 bool OutputAvoidDrumChannel() const
00344 {
00345 return ONoDrum;
00346 }
00347 void OutputAvoidDrumChannel(bool avoid)
00348 {
00349 ONoDrum = avoid;
00350 }
00351
00352 Route * GetNext() const
00353 {
00354 return Next;
00355 }
00356 void SetNext(Route * route)
00357 {
00358 Next = route;
00359 for (Route * r = GetNext(); r; r=r->GetNext())
00360 r -> In = In;
00361 }
00362
00363 int GetId() const
00364 {
00365 return Id;
00366 }
00367
00368 static Route * GetRouteList()
00369 {
00370 return routeList;
00371 }
00372
00373 Route * GetGlobalNext()
00374 {
00375 return globalNext;
00376 }
00377
00379
00383 static void InitializeIds();
00384
00386
00389 static void SaveRoutes(tree_storage & config);
00390
00392
00395 static void LoadRoutes(tree_storage & config);
00396 protected:
00397 static void AppendToRouteList (Route * route);
00398 static void RemoveFromRouteList (Route * route);
00399 };
00400
00401 extern const mutString DevTypeName[];
00402
00404
00406 void LoadRoutes(tree_storage & config);
00407
00409
00411 void SaveRoutes(tree_storage & config);
00412
00413
00414 #endif
00415
00416
00417
00418
00419