37 |
|
|
38 |
namespace LinuxSampler { |
namespace LinuxSampler { |
39 |
|
|
40 |
|
class Plugin; |
41 |
|
|
42 |
class MidiInputDeviceFactory { |
class MidiInputDeviceFactory { |
43 |
public: |
public: |
44 |
class InnerFactory { |
class InnerFactory { |
46 |
virtual MidiInputDevice* Create(std::map<String,DeviceCreationParameter*>& Parameters, Sampler* pSampler) = 0; |
virtual MidiInputDevice* Create(std::map<String,DeviceCreationParameter*>& Parameters, Sampler* pSampler) = 0; |
47 |
virtual String Description() = 0; |
virtual String Description() = 0; |
48 |
virtual String Version() = 0; |
virtual String Version() = 0; |
49 |
|
virtual bool isAutonomousDriver() = 0; |
50 |
}; |
}; |
51 |
|
|
52 |
template <class Driver_T> |
template <class Driver_T> |
55 |
virtual MidiInputDevice* Create(std::map<String,DeviceCreationParameter*>& Parameters, Sampler* pSampler) { return new Driver_T(Parameters, pSampler); } |
virtual MidiInputDevice* Create(std::map<String,DeviceCreationParameter*>& Parameters, Sampler* pSampler) { return new Driver_T(Parameters, pSampler); } |
56 |
virtual String Description() { return Driver_T::Description(); } |
virtual String Description() { return Driver_T::Description(); } |
57 |
virtual String Version() { return Driver_T::Version(); } |
virtual String Version() { return Driver_T::Version(); } |
58 |
|
virtual bool isAutonomousDriver() { return Driver_T::isAutonomousDriver(); } |
59 |
}; |
}; |
60 |
|
|
61 |
template <class Driver_T> |
template <class Driver_T> |
63 |
public: |
public: |
64 |
InnerFactoryRegistrator() { |
InnerFactoryRegistrator() { |
65 |
MidiInputDeviceFactory::InnerFactories[Driver_T::Name()] = new MidiInputDeviceFactory::InnerFactoryTemplate<Driver_T>; |
MidiInputDeviceFactory::InnerFactories[Driver_T::Name()] = new MidiInputDeviceFactory::InnerFactoryTemplate<Driver_T>; |
66 |
MidiInputDeviceFactory::ParameterFactories[Driver_T::Name()] = new DeviceParameterFactory(); |
MidiInputDeviceFactory::ParameterFactories[Driver_T::Name()] = new DeviceParameterFactory(); |
67 |
} |
} |
68 |
~InnerFactoryRegistrator() { |
~InnerFactoryRegistrator() { |
69 |
std::map<String, InnerFactory*>::iterator iter = MidiInputDeviceFactory::InnerFactories.find(Driver_T::Name()); |
std::map<String, InnerFactory*>::iterator iter = MidiInputDeviceFactory::InnerFactories.find(Driver_T::Name()); |
76 |
} |
} |
77 |
}; |
}; |
78 |
|
|
79 |
template <class Driver_T, class Parameter_T> |
template <class Driver_T, class Parameter_T> |
80 |
class ParameterRegistrator { |
class ParameterRegistrator { |
81 |
public: |
public: |
82 |
ParameterRegistrator() { |
ParameterRegistrator() { |
83 |
DeviceParameterFactory::Register<Parameter_T>(MidiInputDeviceFactory::ParameterFactories[Driver_T::Name()]); |
DeviceParameterFactory::Register<Parameter_T>(MidiInputDeviceFactory::ParameterFactories[Driver_T::Name()]); |
84 |
} |
} |
85 |
}; |
}; |
|
|
|
86 |
|
|
87 |
static MidiInputDevice* Create(String DriverName, std::map<String,String> Parameters, Sampler* pSampler) throw (Exception); |
static MidiInputDevice* Create(String DriverName, std::map<String,String> Parameters, Sampler* pSampler) throw (Exception); |
88 |
|
static void Destroy(MidiInputDevice* pDevice) throw (Exception); |
89 |
static std::vector<String> AvailableDrivers(); |
static std::vector<String> AvailableDrivers(); |
90 |
static String AvailableDriversAsString(); |
static String AvailableDriversAsString(); |
91 |
static std::map<String,DeviceCreationParameter*> GetAvailableDriverParameters(String DriverName) throw (Exception); |
static std::map<String,DeviceCreationParameter*> GetAvailableDriverParameters(String DriverName) throw (Exception); |
92 |
static DeviceCreationParameter* GetDriverParameter(String DriverName, String ParameterName) throw (Exception); |
static DeviceCreationParameter* GetDriverParameter(String DriverName, String ParameterName) throw (Exception); |
93 |
static String GetDriverDescription(String DriverName) throw (Exception); |
static String GetDriverDescription(String DriverName) throw (Exception); |
94 |
static String GetDriverVersion(String DriverName) throw (Exception); |
static String GetDriverVersion(String DriverName) throw (Exception); |
95 |
|
static std::map<uint, MidiInputDevice*> Devices(); |
96 |
|
|
97 |
|
protected: |
98 |
|
static MidiInputDevice* CreatePrivate(String DriverName, std::map<String,String> Parameters, Sampler* pSampler) throw (Exception); |
99 |
|
static void DestroyPrivate(MidiInputDevice* pDevice) throw (Exception); |
100 |
|
friend class Plugin; // host plugin base class (e.g. for VST, AU, DSSI, LV2) |
101 |
|
|
102 |
// protected: /* FIXME: fields below should be protected, causes errors on gcc 2.95 though */ |
public: /* FIXME: fields below should be protected, causes errors on gcc 2.95 though */ |
103 |
static std::map<String, InnerFactory*> InnerFactories; |
static std::map<String, InnerFactory*> InnerFactories; |
104 |
static std::map<String, DeviceParameterFactory*> ParameterFactories; |
static std::map<String, DeviceParameterFactory*> ParameterFactories; |
105 |
|
|
106 |
|
private: |
107 |
|
typedef std::map<uint, MidiInputDevice*> MidiInputDeviceMap; |
108 |
|
static MidiInputDeviceMap mMidiInputDevices; ///< contains all created MIDI input devices |
109 |
}; |
}; |
110 |
|
|
111 |
} // namespace LinuxSampler |
} // namespace LinuxSampler |