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"
|
2018-03-20 08:49:21 -04:00
|
|
|
#include "export.h"
|
2014-05-18 11:52:39 -04:00
|
|
|
|
|
|
|
class QComboBox;
|
|
|
|
class QPluginLoader;
|
|
|
|
class Preset;
|
|
|
|
class Message;
|
2016-05-12 04:31:57 -04:00
|
|
|
class MessageQueue;
|
2019-05-08 16:11:53 -04:00
|
|
|
class DeviceAPI;
|
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);
|
2018-08-18 15:30:51 -04:00
|
|
|
void loadPluginsPart(const QString& pluginsSubDir);
|
|
|
|
void loadPluginsFinal();
|
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
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
void createRxChannelInstance(int channelPluginIndex, DeviceUISet *deviceUISet, DeviceAPI *deviceAPI);
|
2017-11-01 03:32:44 -04:00
|
|
|
void listRxChannels(QList<QString>& list);
|
2016-05-14 12:12:39 -04:00
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
void createTxChannelInstance(int channelPluginIndex, DeviceUISet *deviceUISet, DeviceAPI *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
|
2019-05-01 22:02:40 -04:00
|
|
|
static const QString m_localInputHardwareID; //!< Local input hardware ID
|
|
|
|
static const QString m_localInputDeviceTypeID; //!< Local input plugin ID
|
2019-02-02 19:52:11 -05:00
|
|
|
static const QString m_remoteInputHardwareID; //!< Remote input hardware ID
|
|
|
|
static const QString m_remoteInputDeviceTypeID; //!< Remote input 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
|
2019-05-10 17:38:52 -04:00
|
|
|
static const QString m_localOutputHardwareID; //!< Local output hardware ID
|
|
|
|
static const QString m_localOutputDeviceTypeID; //!< Local output plugin ID
|
2019-02-02 19:52:11 -05:00
|
|
|
static const QString m_remoteOutputHardwareID; //!< Remote output hardware ID
|
|
|
|
static const QString m_remoteOutputDeviceTypeID; //!< Remote output plugin ID
|
|
|
|
static const QString m_fileSinkHardwareID; //!< FileSource source hardware ID
|
|
|
|
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
|