2014-05-18 11:52:39 -04:00
|
|
|
#ifndef INCLUDE_PLUGINMANAGER_H
|
|
|
|
#define INCLUDE_PLUGINMANAGER_H
|
|
|
|
|
|
|
|
#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 04:31:57 -04:00
|
|
|
class MessageQueue;
|
2016-10-10 19:17:55 -04:00
|
|
|
class DeviceSourceAPI;
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2015-08-29 19:26:51 -04:00
|
|
|
class SDRANGEL_API PluginManager : public QObject {
|
2014-05-18 11:52:39 -04:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2015-08-08 22:09:05 -04:00
|
|
|
struct Plugin
|
|
|
|
{
|
2014-05-18 11:52:39 -04:00
|
|
|
QString filename;
|
|
|
|
QPluginLoader* loader;
|
2015-09-30 02:55:58 -04:00
|
|
|
PluginInterface* pluginInterface;
|
2015-08-08 22:09:05 -04:00
|
|
|
|
2014-05-18 11:52:39 -04:00
|
|
|
Plugin(const QString& _filename, QPluginLoader* pluginLoader, PluginInterface* _plugin) :
|
|
|
|
filename(_filename),
|
|
|
|
loader(pluginLoader),
|
2015-09-30 02:55:58 -04:00
|
|
|
pluginInterface(_plugin)
|
2014-05-18 11:52:39 -04:00
|
|
|
{ }
|
|
|
|
};
|
2015-08-08 22:09:05 -04:00
|
|
|
|
2014-05-18 11:52:39 -04:00
|
|
|
typedef QList<Plugin> Plugins;
|
|
|
|
|
2016-05-16 18:04:27 -04:00
|
|
|
explicit PluginManager(MainWindow* mainWindow, QObject* parent = NULL);
|
2014-05-18 11:52:39 -04:00
|
|
|
~PluginManager();
|
|
|
|
|
2016-05-14 04:38:29 -04:00
|
|
|
void loadPlugins();
|
2014-05-18 11:52:39 -04:00
|
|
|
const Plugins& getPlugins() const { return m_plugins; }
|
|
|
|
|
2016-05-14 12:12:39 -04:00
|
|
|
// Callbacks from the plugins
|
2016-10-13 16:23:43 -04:00
|
|
|
void registerRxChannel(const QString& channelName, PluginInterface* plugin);
|
2014-05-18 11:52:39 -04:00
|
|
|
void registerSampleSource(const QString& sourceName, PluginInterface* plugin);
|
2016-05-14 12:12:39 -04:00
|
|
|
|
2016-10-13 16:23:43 -04:00
|
|
|
PluginAPI::ChannelRegistrations *getRxChannelRegistrations() { return &m_rxChannelRegistrations; }
|
2016-05-16 12:53:01 -04:00
|
|
|
|
2014-05-18 11:52:39 -04:00
|
|
|
void updateSampleSourceDevices();
|
2016-05-22 18:21:13 -04:00
|
|
|
void duplicateLocalSampleSourceDevices(uint deviceUID);
|
2016-05-22 15:56:07 -04:00
|
|
|
void fillSampleSourceSelector(QComboBox* comboBox, uint deviceUID);
|
2016-05-15 21:21:21 -04:00
|
|
|
|
2016-10-10 19:17:55 -04:00
|
|
|
int selectSampleSourceByIndex(int index, DeviceSourceAPI *deviceAPI);
|
|
|
|
int selectFirstSampleSource(const QString& sourceId, DeviceSourceAPI *deviceAPI);
|
|
|
|
int selectSampleSourceBySerialOrSequence(const QString& sourceId, const QString& sourceSerial, int sourceSequence, DeviceSourceAPI *deviceAPI);
|
|
|
|
void selectSampleSourceByDevice(void *devicePtr, DeviceSourceAPI *deviceAPI);
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2016-10-13 17:42:08 -04:00
|
|
|
void populateRxChannelComboBox(QComboBox *channels);
|
|
|
|
void createRxChannelInstance(int channelPluginIndex, DeviceSourceAPI *deviceAPI);
|
2016-05-14 12:12:39 -04:00
|
|
|
|
2014-05-18 11:52:39 -04:00
|
|
|
private:
|
2016-10-13 16:23:43 -04:00
|
|
|
struct SamplingDeviceRegistration {
|
|
|
|
QString m_deviceId;
|
2014-05-18 11:52:39 -04:00
|
|
|
PluginInterface* m_plugin;
|
2016-10-13 16:23:43 -04:00
|
|
|
SamplingDeviceRegistration(const QString& deviceId, PluginInterface* plugin) :
|
|
|
|
m_deviceId(deviceId),
|
2014-05-18 11:52:39 -04:00
|
|
|
m_plugin(plugin)
|
|
|
|
{ }
|
|
|
|
};
|
2016-05-16 18:04:27 -04:00
|
|
|
|
2016-10-13 16:23:43 -04:00
|
|
|
typedef QList<SamplingDeviceRegistration> SamplingDeviceRegistrations;
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2016-10-13 16:23:43 -04:00
|
|
|
struct SamplingDevice {
|
2014-05-18 11:52:39 -04:00
|
|
|
PluginInterface* m_plugin;
|
|
|
|
QString m_displayName;
|
2016-10-13 16:23:43 -04:00
|
|
|
QString m_deviceId;
|
|
|
|
QString m_deviceSerial;
|
|
|
|
int m_deviceSequence;
|
2015-09-30 00:57:40 -04:00
|
|
|
|
2016-10-13 16:23:43 -04:00
|
|
|
SamplingDevice(PluginInterface* plugin,
|
2015-09-30 00:57:40 -04:00
|
|
|
const QString& displayName,
|
2016-10-13 16:23:43 -04:00
|
|
|
const QString& deviceId,
|
|
|
|
const QString& deviceSerial,
|
|
|
|
int deviceSequence) :
|
2014-05-18 11:52:39 -04:00
|
|
|
m_plugin(plugin),
|
|
|
|
m_displayName(displayName),
|
2016-10-13 16:23:43 -04:00
|
|
|
m_deviceId(deviceId),
|
|
|
|
m_deviceSerial(deviceSerial),
|
|
|
|
m_deviceSequence(deviceSequence)
|
2014-05-18 11:52:39 -04:00
|
|
|
{ }
|
|
|
|
};
|
2016-05-16 18:04:27 -04:00
|
|
|
|
2016-10-13 16:23:43 -04:00
|
|
|
typedef QList<SamplingDevice> SamplingDevices;
|
2014-05-18 11:52:39 -04:00
|
|
|
|
|
|
|
PluginAPI m_pluginAPI;
|
|
|
|
MainWindow* m_mainWindow;
|
|
|
|
Plugins m_plugins;
|
|
|
|
|
2016-10-13 16:23:43 -04: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 11:52:39 -04:00
|
|
|
|
2016-05-22 18:21:13 -04:00
|
|
|
// "Local" sample source device IDs
|
|
|
|
static const QString m_sdrDaemonDeviceTypeID; //!< SDRdaemon source plugin ID
|
2016-06-19 19:58:46 -04:00
|
|
|
static const QString m_sdrDaemonFECDeviceTypeID; //!< SDRdaemon with FEC source plugin ID
|
2016-05-22 18:21:13 -04:00
|
|
|
static const QString m_fileSourceDeviceTypeID; //!< FileSource source plugin ID
|
2016-05-22 15:56:07 -04:00
|
|
|
|
2014-05-18 11:52:39 -04:00
|
|
|
void loadPlugins(const QDir& dir);
|
2016-05-16 18:04:27 -04:00
|
|
|
|
|
|
|
friend class MainWindow;
|
2014-05-18 11:52:39 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline bool operator<(const PluginManager::Plugin& a, const PluginManager::Plugin& b)
|
|
|
|
{
|
2015-09-30 02:55:58 -04:00
|
|
|
return a.pluginInterface->getPluginDescriptor().displayedName < b.pluginInterface->getPluginDescriptor().displayedName;
|
2014-05-18 11:52:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // INCLUDE_PLUGINMANAGER_H
|