| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | #ifndef INCLUDE_PLUGINMANAGER_H
 | 
					
						
							|  |  |  | #define INCLUDE_PLUGINMANAGER_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-26 10:35:29 +02:00
										 |  |  | #include <stdint.h>
 | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | #include <QObject>
 | 
					
						
							|  |  |  | #include <QDir>
 | 
					
						
							|  |  |  | #include "plugin/plugininterface.h"
 | 
					
						
							|  |  |  | #include "plugin/pluginapi.h"
 | 
					
						
							|  |  |  | #include "util/export.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class QComboBox; | 
					
						
							|  |  |  | class QPluginLoader; | 
					
						
							|  |  |  | class Preset; | 
					
						
							|  |  |  | class MainWindow; | 
					
						
							|  |  |  | class Message; | 
					
						
							| 
									
										
										
										
											2016-05-12 10:31:57 +02:00
										 |  |  | class MessageQueue; | 
					
						
							| 
									
										
										
										
											2016-10-11 01:17:55 +02:00
										 |  |  | class DeviceSourceAPI; | 
					
						
							| 
									
										
										
										
											2016-10-19 18:07:27 +02:00
										 |  |  | class DeviceSinkAPI; | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-30 01:26:51 +02:00
										 |  |  | class SDRANGEL_API PluginManager : public QObject { | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 	Q_OBJECT | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2015-08-09 04:09:05 +02:00
										 |  |  | 	struct Plugin | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 		QString filename; | 
					
						
							|  |  |  | 		QPluginLoader* loader; | 
					
						
							| 
									
										
										
										
											2015-09-30 08:55:58 +02:00
										 |  |  | 		PluginInterface* pluginInterface; | 
					
						
							| 
									
										
										
										
											2015-08-09 04:09:05 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 		Plugin(const QString& _filename, QPluginLoader* pluginLoader, PluginInterface* _plugin) : | 
					
						
							|  |  |  | 			filename(_filename), | 
					
						
							|  |  |  | 			loader(pluginLoader), | 
					
						
							| 
									
										
										
										
											2015-09-30 08:55:58 +02:00
										 |  |  | 			pluginInterface(_plugin) | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 		{ } | 
					
						
							|  |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2015-08-09 04:09:05 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 	typedef QList<Plugin> Plugins; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-17 00:04:27 +02:00
										 |  |  | 	explicit PluginManager(MainWindow* mainWindow, QObject* parent = NULL); | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 	~PluginManager(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-14 10:38:29 +02:00
										 |  |  | 	void loadPlugins(); | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 	const Plugins& getPlugins() const { return m_plugins; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-14 18:12:39 +02:00
										 |  |  | 	// Callbacks from the plugins
 | 
					
						
							| 
									
										
										
										
											2016-10-13 22:23:43 +02:00
										 |  |  | 	void registerRxChannel(const QString& channelName, PluginInterface* plugin); | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 	void registerSampleSource(const QString& sourceName, PluginInterface* plugin); | 
					
						
							| 
									
										
										
										
											2016-10-19 18:07:27 +02:00
										 |  |  | 	void registerTxChannel(const QString& channelName, PluginInterface* plugin); | 
					
						
							|  |  |  | 	void registerSampleSink(const QString& sourceName, PluginInterface* plugin); | 
					
						
							| 
									
										
										
										
											2016-05-14 18:12:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-13 22:23:43 +02:00
										 |  |  | 	PluginAPI::ChannelRegistrations *getRxChannelRegistrations() { return &m_rxChannelRegistrations; } | 
					
						
							| 
									
										
										
										
											2016-10-19 18:07:27 +02:00
										 |  |  | 	PluginAPI::ChannelRegistrations *getTxChannelRegistrations() { return &m_txChannelRegistrations; } | 
					
						
							| 
									
										
										
										
											2016-05-16 18:53:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 	void updateSampleSourceDevices(); | 
					
						
							| 
									
										
										
										
											2016-05-23 00:21:13 +02:00
										 |  |  | 	void duplicateLocalSampleSourceDevices(uint deviceUID); | 
					
						
							| 
									
										
										
										
											2016-05-22 21:56:07 +02:00
										 |  |  | 	void fillSampleSourceSelector(QComboBox* comboBox, uint deviceUID); | 
					
						
							| 
									
										
										
										
											2017-01-12 01:24:08 +01:00
										 |  |  | 	int getSampleSourceSelectorIndex(QComboBox* comboBox, DeviceSourceAPI *deviceSourceAPI); | 
					
						
							| 
									
										
										
										
											2016-05-16 03:21:21 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-19 18:07:27 +02:00
										 |  |  | 	void updateSampleSinkDevices(); | 
					
						
							|  |  |  | 	void duplicateLocalSampleSinkDevices(uint deviceUID); | 
					
						
							|  |  |  | 	void fillSampleSinkSelector(QComboBox* comboBox, uint deviceUID); | 
					
						
							| 
									
										
										
										
											2017-01-12 01:24:08 +01:00
										 |  |  | 	int getSampleSinkSelectorIndex(QComboBox* comboBox, DeviceSinkAPI *deviceSinkAPI); | 
					
						
							| 
									
										
										
										
											2016-10-19 18:07:27 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 01:17:55 +02:00
										 |  |  | 	int selectSampleSourceByIndex(int index, DeviceSourceAPI *deviceAPI); | 
					
						
							| 
									
										
										
										
											2017-05-25 20:13:34 +02:00
										 |  |  | 	int selectSampleSourceBySerialOrSequence(const QString& sourceId, const QString& sourceSerial, uint32_t sourceSequence, DeviceSourceAPI *deviceAPI); | 
					
						
							| 
									
										
										
										
											2016-10-11 01:17:55 +02:00
										 |  |  | 	void selectSampleSourceByDevice(void *devicePtr, DeviceSourceAPI *deviceAPI); | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-25 20:13:34 +02:00
										 |  |  | 	int selectSampleSinkBySerialOrSequence(const QString& sinkId, const QString& sinkSerial, uint32_t sinkSequence, DeviceSinkAPI *deviceAPI); | 
					
						
							| 
									
										
										
										
											2016-10-19 18:07:27 +02:00
										 |  |  | 	void selectSampleSinkByDevice(void *devicePtr, DeviceSinkAPI *deviceAPI); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-15 01:24:51 +02:00
										 |  |  | 	PluginInterface* getPluginInterfaceAt(int index); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-13 23:42:08 +02:00
										 |  |  | 	void populateRxChannelComboBox(QComboBox *channels); | 
					
						
							|  |  |  | 	void createRxChannelInstance(int channelPluginIndex, DeviceSourceAPI *deviceAPI); | 
					
						
							| 
									
										
										
										
											2016-05-14 18:12:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-19 18:07:27 +02:00
										 |  |  | 	void populateTxChannelComboBox(QComboBox *channels); | 
					
						
							|  |  |  | 	void createTxChannelInstance(int channelPluginIndex, DeviceSinkAPI *deviceAPI); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2016-10-13 22:23:43 +02:00
										 |  |  | 	struct SamplingDeviceRegistration { | 
					
						
							|  |  |  | 		QString m_deviceId; | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 		PluginInterface* m_plugin; | 
					
						
							| 
									
										
										
										
											2016-10-13 22:23:43 +02:00
										 |  |  | 		SamplingDeviceRegistration(const QString& deviceId, PluginInterface* plugin) : | 
					
						
							|  |  |  | 			m_deviceId(deviceId), | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 			m_plugin(plugin) | 
					
						
							|  |  |  | 		{ } | 
					
						
							|  |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2016-05-17 00:04:27 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-13 22:23:43 +02:00
										 |  |  | 	typedef QList<SamplingDeviceRegistration> SamplingDeviceRegistrations; | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-13 22:23:43 +02:00
										 |  |  | 	struct SamplingDevice { | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 		PluginInterface* m_plugin; | 
					
						
							|  |  |  | 		QString m_displayName; | 
					
						
							| 
									
										
										
										
											2016-12-29 12:41:10 +01:00
										 |  |  | 		QString m_hadrwareId; | 
					
						
							| 
									
										
										
										
											2016-10-13 22:23:43 +02:00
										 |  |  | 		QString m_deviceId; | 
					
						
							|  |  |  | 		QString m_deviceSerial; | 
					
						
							| 
									
										
										
										
											2017-05-25 20:13:34 +02:00
										 |  |  | 		uint32_t m_deviceSequence; | 
					
						
							| 
									
										
										
										
											2015-09-30 06:57:40 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-13 22:23:43 +02:00
										 |  |  | 		SamplingDevice(PluginInterface* plugin, | 
					
						
							| 
									
										
										
										
											2015-09-30 06:57:40 +02:00
										 |  |  | 				const QString& displayName, | 
					
						
							| 
									
										
										
										
											2016-12-29 12:41:10 +01:00
										 |  |  | 				const QString& hadrwareId, | 
					
						
							| 
									
										
										
										
											2016-10-13 22:23:43 +02:00
										 |  |  | 				const QString& deviceId, | 
					
						
							|  |  |  | 				const QString& deviceSerial, | 
					
						
							|  |  |  | 				int deviceSequence) : | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 			m_plugin(plugin), | 
					
						
							|  |  |  | 			m_displayName(displayName), | 
					
						
							| 
									
										
										
										
											2016-12-29 12:41:10 +01:00
										 |  |  | 			m_hadrwareId(hadrwareId), | 
					
						
							| 
									
										
										
										
											2016-10-13 22:23:43 +02:00
										 |  |  | 			m_deviceId(deviceId), | 
					
						
							|  |  |  | 			m_deviceSerial(deviceSerial), | 
					
						
							|  |  |  | 			m_deviceSequence(deviceSequence) | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 		{ } | 
					
						
							|  |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2016-05-17 00:04:27 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-13 22:23:43 +02:00
										 |  |  | 	typedef QList<SamplingDevice> SamplingDevices; | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	PluginAPI m_pluginAPI; | 
					
						
							|  |  |  | 	Plugins m_plugins; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-13 22:23:43 +02:00
										 |  |  | 	PluginAPI::ChannelRegistrations m_rxChannelRegistrations; //!< Channel plugins register here
 | 
					
						
							|  |  |  | 	SamplingDeviceRegistrations m_sampleSourceRegistrations;  //!< Input source plugins (one per device kind) register here
 | 
					
						
							|  |  |  | 	SamplingDevices m_sampleSourceDevices;                    //!< Instances of input sources present in the system
 | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-19 18:07:27 +02:00
										 |  |  | 	PluginAPI::ChannelRegistrations m_txChannelRegistrations; //!< Channel plugins register here
 | 
					
						
							|  |  |  | 	SamplingDeviceRegistrations m_sampleSinkRegistrations;    //!< Output sink plugins (one per device kind) register here
 | 
					
						
							|  |  |  | 	SamplingDevices m_sampleSinkDevices;                      //!< Instances of output sinks present in the system
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-23 00:21:13 +02:00
										 |  |  | 	// "Local" sample source device IDs
 | 
					
						
							| 
									
										
										
										
											2016-12-29 12:41:10 +01:00
										 |  |  |     static const QString m_sdrDaemonHardwareID;       //!< SDRdaemon hardware ID
 | 
					
						
							| 
									
										
										
										
											2016-10-19 18:07:27 +02:00
										 |  |  | 	static const QString m_sdrDaemonDeviceTypeID;     //!< SDRdaemon source plugin ID
 | 
					
						
							| 
									
										
										
										
											2016-12-29 12:41:10 +01:00
										 |  |  | 	static const QString m_sdrDaemonFECHardwareID;    //!< SDRdaemon with FEC hardware ID
 | 
					
						
							| 
									
										
										
										
											2016-10-19 18:07:27 +02:00
										 |  |  |     static const QString m_sdrDaemonFECDeviceTypeID;  //!< SDRdaemon with FEC source plugin ID
 | 
					
						
							| 
									
										
										
										
											2016-12-29 12:41:10 +01:00
										 |  |  |     static const QString m_fileSourceHardwareID;      //!< FileSource source hardware ID
 | 
					
						
							| 
									
										
										
										
											2016-10-19 18:07:27 +02:00
										 |  |  |     static const QString m_fileSourceDeviceTypeID;    //!< FileSource source plugin ID
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // "Local" sample sink device IDs
 | 
					
						
							|  |  |  |     static const QString m_fileSinkDeviceTypeID;      //!< FileSink sink plugin ID
 | 
					
						
							| 
									
										
										
										
											2016-05-22 21:56:07 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 	void loadPlugins(const QDir& dir); | 
					
						
							| 
									
										
										
										
											2016-05-17 00:04:27 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	friend class MainWindow; | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static inline bool operator<(const PluginManager::Plugin& a, const PluginManager::Plugin& b) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2015-09-30 08:55:58 +02:00
										 |  |  | 	return a.pluginInterface->getPluginDescriptor().displayedName < b.pluginInterface->getPluginDescriptor().displayedName; | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif // INCLUDE_PLUGINMANAGER_H
 |