2014-05-18 11:52:39 -04:00
|
|
|
#ifndef INCLUDE_PLUGINMANAGER_H
|
|
|
|
#define INCLUDE_PLUGINMANAGER_H
|
|
|
|
|
2017-05-26 04:35:29 -04:00
|
|
|
#include <stdint.h>
|
2014-05-18 11:52:39 -04:00
|
|
|
#include <QObject>
|
|
|
|
#include <QDir>
|
2017-11-01 03:32:44 -04:00
|
|
|
#include <QList>
|
|
|
|
#include <QString>
|
|
|
|
|
2014-05-18 11:52:39 -04:00
|
|
|
#include "plugin/plugininterface.h"
|
|
|
|
#include "plugin/pluginapi.h"
|
|
|
|
#include "util/export.h"
|
|
|
|
|
|
|
|
class QComboBox;
|
|
|
|
class QPluginLoader;
|
|
|
|
class Preset;
|
|
|
|
class Message;
|
2016-05-12 04:31:57 -04:00
|
|
|
class MessageQueue;
|
2016-10-10 19:17:55 -04:00
|
|
|
class DeviceSourceAPI;
|
2016-10-19 12:07:27 -04:00
|
|
|
class DeviceSinkAPI;
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2018-03-03 14:23:38 -05:00
|
|
|
class SDRBASE_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;
|
|
|
|
|
2017-10-24 08:15:08 -04:00
|
|
|
explicit PluginManager(QObject* parent = 0);
|
2014-05-18 11:52:39 -04:00
|
|
|
~PluginManager();
|
|
|
|
|
2017-10-24 08:15:08 -04:00
|
|
|
PluginAPI *getPluginAPI() { return &m_pluginAPI; }
|
2017-12-17 04:36:22 -05:00
|
|
|
void loadPlugins(const QString& pluginsSubDir);
|
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
|
2017-11-22 19:19:32 -05:00
|
|
|
void registerRxChannel(const QString& channelIdURI, const QString& channelId, PluginInterface* plugin);
|
2014-05-18 11:52:39 -04:00
|
|
|
void registerSampleSource(const QString& sourceName, PluginInterface* plugin);
|
2017-11-22 19:19:32 -05:00
|
|
|
void registerTxChannel(const QString& channelIdURI, const QString& channelId, PluginInterface* plugin);
|
2016-10-19 12:07:27 -04:00
|
|
|
void registerSampleSink(const QString& sourceName, PluginInterface* plugin);
|
2016-05-14 12:12:39 -04:00
|
|
|
|
2017-11-01 22:30:54 -04:00
|
|
|
PluginAPI::SamplingDeviceRegistrations& getSourceDeviceRegistrations() { return m_sampleSourceRegistrations; }
|
|
|
|
PluginAPI::SamplingDeviceRegistrations& getSinkDeviceRegistrations() { return m_sampleSinkRegistrations; }
|
2016-10-13 16:23:43 -04:00
|
|
|
PluginAPI::ChannelRegistrations *getRxChannelRegistrations() { return &m_rxChannelRegistrations; }
|
2016-10-19 12:07:27 -04:00
|
|
|
PluginAPI::ChannelRegistrations *getTxChannelRegistrations() { return &m_txChannelRegistrations; }
|
2016-05-16 12:53:01 -04:00
|
|
|
|
2017-11-08 19:03:05 -05:00
|
|
|
void createRxChannelInstance(int channelPluginIndex, DeviceUISet *deviceUISet, DeviceSourceAPI *deviceAPI);
|
2017-11-01 03:32:44 -04:00
|
|
|
void listRxChannels(QList<QString>& list);
|
2016-05-14 12:12:39 -04:00
|
|
|
|
2017-11-08 16:54:58 -05:00
|
|
|
void createTxChannelInstance(int channelPluginIndex, DeviceUISet *deviceUISet, DeviceSinkAPI *deviceAPI);
|
2017-11-01 03:32:44 -04:00
|
|
|
void listTxChannels(QList<QString>& list);
|
2016-10-19 12:07:27 -04:00
|
|
|
|
2017-11-01 22:30:54 -04:00
|
|
|
static const QString& getFileSourceDeviceId() { return m_fileSourceDeviceTypeID; }
|
|
|
|
static const QString& getFileSinkDeviceId() { return m_fileSinkDeviceTypeID; }
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2017-11-01 22:30:54 -04:00
|
|
|
private:
|
2017-11-01 08:03:12 -04:00
|
|
|
struct SamplingDevice { //!< This is the device registration
|
2014-05-18 11:52:39 -04:00
|
|
|
PluginInterface* m_plugin;
|
|
|
|
QString m_displayName;
|
2016-12-29 06:41:10 -05:00
|
|
|
QString m_hadrwareId;
|
2016-10-13 16:23:43 -04:00
|
|
|
QString m_deviceId;
|
|
|
|
QString m_deviceSerial;
|
2017-05-25 14:13:34 -04:00
|
|
|
uint32_t 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-12-29 06:41:10 -05:00
|
|
|
const QString& hadrwareId,
|
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-12-29 06:41:10 -05:00
|
|
|
m_hadrwareId(hadrwareId),
|
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;
|
|
|
|
Plugins m_plugins;
|
|
|
|
|
2017-11-01 22:30:54 -04:00
|
|
|
PluginAPI::ChannelRegistrations m_rxChannelRegistrations; //!< Channel plugins register here
|
|
|
|
PluginAPI::SamplingDeviceRegistrations m_sampleSourceRegistrations; //!< Input source plugins (one per device kind) register here
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2017-11-01 22:30:54 -04:00
|
|
|
PluginAPI::ChannelRegistrations m_txChannelRegistrations; //!< Channel plugins register here
|
|
|
|
PluginAPI::SamplingDeviceRegistrations m_sampleSinkRegistrations; //!< Output sink plugins (one per device kind) register here
|
2016-10-19 12:07:27 -04:00
|
|
|
|
2016-05-22 18:21:13 -04:00
|
|
|
// "Local" sample source device IDs
|
2017-11-01 08:03:12 -04:00
|
|
|
static const QString m_sdrDaemonSourceHardwareID; //!< SDRdaemon source hardware ID
|
|
|
|
static const QString m_sdrDaemonSourceDeviceTypeID; //!< SDRdaemon source plugin ID
|
|
|
|
static const QString m_fileSourceHardwareID; //!< FileSource source hardware ID
|
|
|
|
static const QString m_fileSourceDeviceTypeID; //!< FileSource source plugin ID
|
2016-10-19 12:07:27 -04:00
|
|
|
|
|
|
|
// "Local" sample sink device IDs
|
2017-11-01 08:03:12 -04:00
|
|
|
static const QString m_sdrDaemonSinkHardwareID; //!< SDRdaemon source hardware ID
|
|
|
|
static const QString m_sdrDaemonSinkDeviceTypeID; //!< SDRdaemon source plugin ID
|
|
|
|
static const QString m_fileSinkHardwareID; //!< FileSource source hardware ID
|
2016-10-19 12:07:27 -04:00
|
|
|
static const QString m_fileSinkDeviceTypeID; //!< FileSink sink plugin ID
|
2016-05-22 15:56:07 -04:00
|
|
|
|
2017-12-17 04:36:22 -05:00
|
|
|
void loadPluginsDir(const QDir& dir);
|
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
|