2019-05-18 04:30:37 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2016-2019 Edouard Griffiths, F4EXB //
|
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
|
|
|
// (at your option) any later version. //
|
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2014-05-18 15:52:39 +00:00
|
|
|
#ifndef INCLUDE_PLUGINMANAGER_H
|
|
|
|
#define INCLUDE_PLUGINMANAGER_H
|
|
|
|
|
2017-05-26 08:35:29 +00:00
|
|
|
#include <stdint.h>
|
2014-05-18 15:52:39 +00:00
|
|
|
#include <QObject>
|
|
|
|
#include <QDir>
|
2017-11-01 07:32:44 +00:00
|
|
|
#include <QList>
|
|
|
|
#include <QString>
|
|
|
|
|
2014-05-18 15:52:39 +00:00
|
|
|
#include "plugin/plugininterface.h"
|
|
|
|
#include "plugin/pluginapi.h"
|
2018-03-20 12:49:21 +00:00
|
|
|
#include "export.h"
|
2014-05-18 15:52:39 +00:00
|
|
|
|
|
|
|
class QComboBox;
|
|
|
|
class QPluginLoader;
|
|
|
|
class Preset;
|
|
|
|
class Message;
|
2016-05-12 08:31:57 +00:00
|
|
|
class MessageQueue;
|
2019-05-08 20:11:53 +00:00
|
|
|
class DeviceAPI;
|
2019-12-16 00:03:47 +00:00
|
|
|
class DeviceUserArgs;
|
2014-05-18 15:52:39 +00:00
|
|
|
|
2018-03-03 19:23:38 +00:00
|
|
|
class SDRBASE_API PluginManager : public QObject {
|
2014-05-18 15:52:39 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2015-08-09 02:09:05 +00:00
|
|
|
struct Plugin
|
|
|
|
{
|
2014-05-18 15:52:39 +00:00
|
|
|
QString filename;
|
2015-09-30 06:55:58 +00:00
|
|
|
PluginInterface* pluginInterface;
|
2015-08-09 02:09:05 +00:00
|
|
|
|
2019-05-22 06:31:07 +00:00
|
|
|
Plugin(const QString& _filename, PluginInterface* _plugin) :
|
2014-05-18 15:52:39 +00:00
|
|
|
filename(_filename),
|
2015-09-30 06:55:58 +00:00
|
|
|
pluginInterface(_plugin)
|
2014-05-18 15:52:39 +00:00
|
|
|
{ }
|
|
|
|
};
|
2015-08-09 02:09:05 +00:00
|
|
|
|
2014-05-18 15:52:39 +00:00
|
|
|
typedef QList<Plugin> Plugins;
|
|
|
|
|
2017-10-24 12:15:08 +00:00
|
|
|
explicit PluginManager(QObject* parent = 0);
|
2014-05-18 15:52:39 +00:00
|
|
|
~PluginManager();
|
|
|
|
|
2017-10-24 12:15:08 +00:00
|
|
|
PluginAPI *getPluginAPI() { return &m_pluginAPI; }
|
2017-12-17 09:36:22 +00:00
|
|
|
void loadPlugins(const QString& pluginsSubDir);
|
2018-08-18 19:30:51 +00:00
|
|
|
void loadPluginsPart(const QString& pluginsSubDir);
|
|
|
|
void loadPluginsFinal();
|
2019-12-16 00:03:47 +00:00
|
|
|
void loadPluginsNonDiscoverable(const DeviceUserArgs& deviceUserArgs);
|
2014-05-18 15:52:39 +00:00
|
|
|
const Plugins& getPlugins() const { return m_plugins; }
|
|
|
|
|
2016-05-14 16:12:39 +00:00
|
|
|
// Callbacks from the plugins
|
2017-11-23 00:19:32 +00:00
|
|
|
void registerRxChannel(const QString& channelIdURI, const QString& channelId, PluginInterface* plugin);
|
|
|
|
void registerTxChannel(const QString& channelIdURI, const QString& channelId, PluginInterface* plugin);
|
2019-09-02 16:36:56 +00:00
|
|
|
void registerMIMOChannel(const QString& channelIdURI, const QString& channelId, PluginInterface* plugin);
|
|
|
|
void registerSampleSource(const QString& sourceName, PluginInterface* plugin);
|
2019-05-18 04:30:37 +00:00
|
|
|
void registerSampleSink(const QString& sinkName, PluginInterface* plugin);
|
|
|
|
void registerSampleMIMO(const QString& mimoName, PluginInterface* plugin);
|
2016-05-14 16:12:39 +00:00
|
|
|
|
2017-11-02 02:30:54 +00:00
|
|
|
PluginAPI::SamplingDeviceRegistrations& getSourceDeviceRegistrations() { return m_sampleSourceRegistrations; }
|
|
|
|
PluginAPI::SamplingDeviceRegistrations& getSinkDeviceRegistrations() { return m_sampleSinkRegistrations; }
|
2019-05-18 04:30:37 +00:00
|
|
|
PluginAPI::SamplingDeviceRegistrations& getMIMODeviceRegistrations() { return m_sampleMIMORegistrations; }
|
2016-10-13 20:23:43 +00:00
|
|
|
PluginAPI::ChannelRegistrations *getRxChannelRegistrations() { return &m_rxChannelRegistrations; }
|
2016-10-19 16:07:27 +00:00
|
|
|
PluginAPI::ChannelRegistrations *getTxChannelRegistrations() { return &m_txChannelRegistrations; }
|
2019-09-02 16:36:56 +00:00
|
|
|
PluginAPI::ChannelRegistrations *getMIMOChannelRegistrations() { return &m_mimoChannelRegistrations; }
|
2016-05-16 16:53:01 +00:00
|
|
|
|
2019-05-08 20:11:53 +00:00
|
|
|
void createRxChannelInstance(int channelPluginIndex, DeviceUISet *deviceUISet, DeviceAPI *deviceAPI);
|
2017-11-01 07:32:44 +00:00
|
|
|
void listRxChannels(QList<QString>& list);
|
2016-05-14 16:12:39 +00:00
|
|
|
|
2019-05-08 20:11:53 +00:00
|
|
|
void createTxChannelInstance(int channelPluginIndex, DeviceUISet *deviceUISet, DeviceAPI *deviceAPI);
|
2017-11-01 07:32:44 +00:00
|
|
|
void listTxChannels(QList<QString>& list);
|
2016-10-19 16:07:27 +00:00
|
|
|
|
2019-09-02 16:36:56 +00:00
|
|
|
void createMIMOChannelInstance(int channelPluginIndex, DeviceUISet *deviceUISet, DeviceAPI *deviceAPI);
|
|
|
|
void listMIMOChannels(QList<QString>& list);
|
|
|
|
|
2019-08-01 16:50:21 +00:00
|
|
|
const PluginInterface *getChannelPluginInterface(const QString& channelIdURI) const;
|
2019-08-03 09:21:46 +00:00
|
|
|
const PluginInterface *getDevicePluginInterface(const QString& deviceId) const;
|
2019-08-01 16:50:21 +00:00
|
|
|
|
2019-07-07 22:59:04 +00:00
|
|
|
static const QString& getFileInputDeviceId() { return m_fileInputDeviceTypeID; }
|
2020-08-03 22:53:34 +00:00
|
|
|
static const QString& getFileOutputDeviceId() { return m_fileOutputDeviceTypeID; }
|
2014-05-18 15:52:39 +00:00
|
|
|
|
2017-11-02 02:30:54 +00:00
|
|
|
private:
|
2017-11-01 12:03:12 +00:00
|
|
|
struct SamplingDevice { //!< This is the device registration
|
2014-05-18 15:52:39 +00:00
|
|
|
PluginInterface* m_plugin;
|
|
|
|
QString m_displayName;
|
2016-12-29 11:41:10 +00:00
|
|
|
QString m_hadrwareId;
|
2016-10-13 20:23:43 +00:00
|
|
|
QString m_deviceId;
|
|
|
|
QString m_deviceSerial;
|
2017-05-25 18:13:34 +00:00
|
|
|
uint32_t m_deviceSequence;
|
2015-09-30 04:57:40 +00:00
|
|
|
|
2016-10-13 20:23:43 +00:00
|
|
|
SamplingDevice(PluginInterface* plugin,
|
2015-09-30 04:57:40 +00:00
|
|
|
const QString& displayName,
|
2016-12-29 11:41:10 +00:00
|
|
|
const QString& hadrwareId,
|
2016-10-13 20:23:43 +00:00
|
|
|
const QString& deviceId,
|
|
|
|
const QString& deviceSerial,
|
|
|
|
int deviceSequence) :
|
2014-05-18 15:52:39 +00:00
|
|
|
m_plugin(plugin),
|
|
|
|
m_displayName(displayName),
|
2016-12-29 11:41:10 +00:00
|
|
|
m_hadrwareId(hadrwareId),
|
2016-10-13 20:23:43 +00:00
|
|
|
m_deviceId(deviceId),
|
|
|
|
m_deviceSerial(deviceSerial),
|
|
|
|
m_deviceSequence(deviceSequence)
|
2014-05-18 15:52:39 +00:00
|
|
|
{ }
|
|
|
|
};
|
2016-05-16 22:04:27 +00:00
|
|
|
|
2016-10-13 20:23:43 +00:00
|
|
|
typedef QList<SamplingDevice> SamplingDevices;
|
2014-05-18 15:52:39 +00:00
|
|
|
|
|
|
|
PluginAPI m_pluginAPI;
|
|
|
|
Plugins m_plugins;
|
|
|
|
|
2017-11-02 02:30:54 +00:00
|
|
|
PluginAPI::ChannelRegistrations m_rxChannelRegistrations; //!< Channel plugins register here
|
2019-09-02 16:36:56 +00:00
|
|
|
PluginAPI::ChannelRegistrations m_txChannelRegistrations; //!< Channel plugins register here
|
|
|
|
PluginAPI::ChannelRegistrations m_mimoChannelRegistrations; //!< Channel plugins register here
|
2016-10-19 16:07:27 +00:00
|
|
|
|
2019-09-02 16:36:56 +00:00
|
|
|
PluginAPI::SamplingDeviceRegistrations m_sampleSourceRegistrations; //!< Input source plugins (one per device kind) register here
|
|
|
|
PluginAPI::SamplingDeviceRegistrations m_sampleSinkRegistrations; //!< Output sink plugins (one per device kind) register here
|
|
|
|
PluginAPI::SamplingDeviceRegistrations m_sampleMIMORegistrations; //!< MIMO sink plugins (one per device kind) register here
|
2019-05-18 04:30:37 +00:00
|
|
|
|
2016-05-22 22:21:13 +00:00
|
|
|
// "Local" sample source device IDs
|
2019-05-02 02:02:40 +00:00
|
|
|
static const QString m_localInputHardwareID; //!< Local input hardware ID
|
|
|
|
static const QString m_localInputDeviceTypeID; //!< Local input plugin ID
|
2019-02-03 00:52:11 +00:00
|
|
|
static const QString m_remoteInputHardwareID; //!< Remote input hardware ID
|
|
|
|
static const QString m_remoteInputDeviceTypeID; //!< Remote input plugin ID
|
2019-07-07 22:59:04 +00:00
|
|
|
static const QString m_fileInputHardwareID; //!< File input hardware ID
|
|
|
|
static const QString m_fileInputDeviceTypeID; //!< File input plugin ID
|
2016-10-19 16:07:27 +00:00
|
|
|
|
|
|
|
// "Local" sample sink device IDs
|
2019-05-10 21:38:52 +00:00
|
|
|
static const QString m_localOutputHardwareID; //!< Local output hardware ID
|
|
|
|
static const QString m_localOutputDeviceTypeID; //!< Local output plugin ID
|
2019-02-03 00:52:11 +00:00
|
|
|
static const QString m_remoteOutputHardwareID; //!< Remote output hardware ID
|
|
|
|
static const QString m_remoteOutputDeviceTypeID; //!< Remote output plugin ID
|
2020-08-03 22:29:15 +00:00
|
|
|
static const QString m_fileOutputHardwareID; //!< FileOutput sink hardware ID
|
|
|
|
static const QString m_fileOutputDeviceTypeID; //!< FileOutput sink plugin ID
|
2016-05-22 19:56:07 +00:00
|
|
|
|
2017-12-17 09:36:22 +00:00
|
|
|
void loadPluginsDir(const QDir& dir);
|
2014-05-18 15:52:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline bool operator<(const PluginManager::Plugin& a, const PluginManager::Plugin& b)
|
|
|
|
{
|
2015-09-30 06:55:58 +00:00
|
|
|
return a.pluginInterface->getPluginDescriptor().displayedName < b.pluginInterface->getPluginDescriptor().displayedName;
|
2014-05-18 15:52:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // INCLUDE_PLUGINMANAGER_H
|