2019-05-18 00:30:37 -04: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 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;
|
2015-09-30 02:55:58 -04:00
|
|
|
PluginInterface* pluginInterface;
|
2015-08-08 22:09:05 -04:00
|
|
|
|
2019-05-22 02:31:07 -04:00
|
|
|
Plugin(const QString& _filename, PluginInterface* _plugin) :
|
2014-05-18 11:52:39 -04:00
|
|
|
filename(_filename),
|
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);
|
2019-05-18 00:30:37 -04:00
|
|
|
void registerSampleSink(const QString& sinkName, PluginInterface* plugin);
|
|
|
|
void registerSampleMIMO(const QString& mimoName, 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; }
|
2019-05-18 00:30:37 -04:00
|
|
|
PluginAPI::SamplingDeviceRegistrations& getMIMODeviceRegistrations() { return m_sampleMIMORegistrations; }
|
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
|
|
|
|
2019-08-01 12:50:21 -04:00
|
|
|
const PluginInterface *getChannelPluginInterface(const QString& channelIdURI) const;
|
2019-08-03 05:21:46 -04:00
|
|
|
const PluginInterface *getDevicePluginInterface(const QString& deviceId) const;
|
2019-08-01 12:50:21 -04:00
|
|
|
|
2019-07-07 18:59:04 -04:00
|
|
|
static const QString& getFileInputDeviceId() { return m_fileInputDeviceTypeID; }
|
2017-11-01 22:30:54 -04:00
|
|
|
static const QString& getFileSinkDeviceId() { return m_fileSinkDeviceTypeID; }
|
2019-05-18 05:59:56 -04:00
|
|
|
static const QString& getTestMIMODeviceId() { return m_testMIMODeviceTypeID; }
|
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
|
|
|
|
2019-05-18 00:30:37 -04:00
|
|
|
PluginAPI::SamplingDeviceRegistrations m_sampleMIMORegistrations; //!< MIMO sink plugins (one per device kind) register here
|
|
|
|
|
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
|
2019-07-07 18:59:04 -04:00
|
|
|
static const QString m_fileInputHardwareID; //!< File input hardware ID
|
|
|
|
static const QString m_fileInputDeviceTypeID; //!< File input 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
|
2019-07-07 18:59:04 -04:00
|
|
|
static const QString m_fileSinkHardwareID; //!< FileSink sink hardware ID
|
2019-02-02 19:52:11 -05:00
|
|
|
static const QString m_fileSinkDeviceTypeID; //!< FileSink sink plugin ID
|
2016-05-22 15:56:07 -04:00
|
|
|
|
2019-05-18 05:59:56 -04:00
|
|
|
// "Local" sample MIMO device IDs
|
|
|
|
static const QString m_testMIMOHardwareID; //!< Test MIMO hardware ID
|
|
|
|
static const QString m_testMIMODeviceTypeID; //!< Test MIMO plugin ID
|
|
|
|
|
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
|