1 |
/*************************************************************************** |
2 |
* * |
3 |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
* Copyright (C) 2005 - 2009 Christian Schoenebeck * |
7 |
* * |
8 |
* This program is free software; you can redistribute it and/or modify * |
9 |
* it under the terms of the GNU General Public License as published by * |
10 |
* the Free Software Foundation; either version 2 of the License, or * |
11 |
* (at your option) any later version. * |
12 |
* * |
13 |
* This program is distributed in the hope that it will be useful, * |
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
16 |
* GNU General Public License for more details. * |
17 |
* * |
18 |
* You should have received a copy of the GNU General Public License * |
19 |
* along with this program; if not, write to the Free Software * |
20 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * |
21 |
* MA 02111-1307 USA * |
22 |
***************************************************************************/ |
23 |
|
24 |
#ifndef __LS_DEVICE_H__ |
25 |
#define __LS_DEVICE_H__ |
26 |
|
27 |
namespace LinuxSampler { |
28 |
|
29 |
class AudioOutputDeviceFactory; |
30 |
class MidiInputDeviceFactory; |
31 |
|
32 |
/** |
33 |
* Abstract base class for all kind of drivers in LinuxSampler. |
34 |
*/ |
35 |
class Device { |
36 |
public: |
37 |
/** |
38 |
* Determines whether the device is an autonomous instance of some |
39 |
* driver or not autonomous (that is bound to some other entity). |
40 |
* An autonomous device can be created and deleted separately. |
41 |
* A non autonomous device only exists in the context of some |
42 |
* entity, e.g. in the context of a host plugin |
43 |
* (VST, AU, LV2, DSSI, ...) instance, and thus such a device |
44 |
* cannot be created or deleted on its own. |
45 |
* |
46 |
* By default, this method returns @c true unless overridden by the |
47 |
* descendent. |
48 |
*/ |
49 |
virtual bool isAutonomousDevice(); |
50 |
|
51 |
/** |
52 |
* Returns the numerical ID of this device instance. Every device |
53 |
* instance has a unique ID among all devices of its category, that |
54 |
* is e.g. every MIDI input device has a unique ID among all MIDI |
55 |
* input devices and every audio output device has a unique ID |
56 |
* among all audio output devices. The IDs are usually generated by |
57 |
* the respective factory class. |
58 |
*/ |
59 |
int deviceId() const; |
60 |
|
61 |
/** |
62 |
* Whether this is an autonomous device driver. |
63 |
* |
64 |
* @see isAutonomousDevice() |
65 |
*/ |
66 |
static bool isAutonomousDriver(); |
67 |
|
68 |
protected: |
69 |
void setDeviceId(int id); |
70 |
|
71 |
//TODO: maybe it would be cleaner to pass the device id through the drivers' constructors instead of having a setDeviceId() method being available only for the factory classes |
72 |
friend class AudioOutputDeviceFactory; |
73 |
friend class MidiInputDeviceFactory; |
74 |
private: |
75 |
int iDeviceId; //TODO: there is not default initialization (e.g. with -1) yet, since there is no constructor yet, it would require all driver implementations to be updated with a constructor call |
76 |
}; |
77 |
|
78 |
} // namespace LinuxSampler |
79 |
|
80 |
#endif // __LS_DEVICE_H__ |