2014-05-18 15:52:39 +00: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 08:31:57 +00:00
|
|
|
class MessageQueue;
|
2016-05-11 15:03:02 +00:00
|
|
|
class DSPDeviceEngine;
|
2016-05-15 23:12:37 +00:00
|
|
|
class DeviceAPI;
|
2014-05-18 15:52:39 +00:00
|
|
|
|
2015-08-29 23:26:51 +00:00
|
|
|
class SDRANGEL_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;
|
|
|
|
QPluginLoader* loader;
|
2015-09-30 06:55:58 +00:00
|
|
|
PluginInterface* pluginInterface;
|
2015-08-09 02:09:05 +00:00
|
|
|
|
2014-05-18 15:52:39 +00:00
|
|
|
Plugin(const QString& _filename, QPluginLoader* pluginLoader, PluginInterface* _plugin) :
|
|
|
|
filename(_filename),
|
|
|
|
loader(pluginLoader),
|
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;
|
|
|
|
|
2016-05-16 22:04:27 +00:00
|
|
|
explicit PluginManager(MainWindow* mainWindow, QObject* parent = NULL);
|
2014-05-18 15:52:39 +00:00
|
|
|
~PluginManager();
|
|
|
|
|
2016-05-14 08:38:29 +00:00
|
|
|
void loadPlugins();
|
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
|
2016-05-14 19:33:12 +00:00
|
|
|
void registerChannel(const QString& channelName, PluginInterface* plugin);
|
2014-05-18 15:52:39 +00:00
|
|
|
void registerSampleSource(const QString& sourceName, PluginInterface* plugin);
|
2016-05-14 16:12:39 +00:00
|
|
|
|
2016-05-16 16:53:01 +00:00
|
|
|
PluginAPI::ChannelRegistrations *getChannelRegistrations() { return &m_channelRegistrations; }
|
|
|
|
|
2014-05-18 15:52:39 +00:00
|
|
|
void updateSampleSourceDevices();
|
2016-05-22 22:21:13 +00:00
|
|
|
void duplicateLocalSampleSourceDevices(uint deviceUID);
|
2016-05-22 19:56:07 +00:00
|
|
|
void fillSampleSourceSelector(QComboBox* comboBox, uint deviceUID);
|
2016-05-16 01:21:21 +00:00
|
|
|
|
2016-05-15 23:12:37 +00:00
|
|
|
int selectSampleSourceByIndex(int index, DeviceAPI *deviceAPI);
|
|
|
|
int selectFirstSampleSource(const QString& sourceId, DeviceAPI *deviceAPI);
|
|
|
|
int selectSampleSourceBySerialOrSequence(const QString& sourceId, const QString& sourceSerial, int sourceSequence, DeviceAPI *deviceAPI);
|
2016-05-22 22:21:13 +00:00
|
|
|
void selectSampleSourceByDevice(void *devicePtr, DeviceAPI *deviceAPI);
|
2014-05-18 15:52:39 +00:00
|
|
|
|
2016-05-14 16:12:39 +00:00
|
|
|
void populateChannelComboBox(QComboBox *channels);
|
2016-05-16 01:21:21 +00:00
|
|
|
void createChannelInstance(int channelPluginIndex, DeviceAPI *deviceAPI);
|
2016-05-14 16:12:39 +00:00
|
|
|
|
2014-05-18 15:52:39 +00:00
|
|
|
private:
|
|
|
|
struct SampleSourceRegistration {
|
2015-09-30 04:57:40 +00:00
|
|
|
QString m_sourceId;
|
2014-05-18 15:52:39 +00:00
|
|
|
PluginInterface* m_plugin;
|
2015-09-30 04:57:40 +00:00
|
|
|
SampleSourceRegistration(const QString& sourceId, PluginInterface* plugin) :
|
|
|
|
m_sourceId(sourceId),
|
2014-05-18 15:52:39 +00:00
|
|
|
m_plugin(plugin)
|
|
|
|
{ }
|
|
|
|
};
|
2016-05-16 22:04:27 +00:00
|
|
|
|
2014-05-18 15:52:39 +00:00
|
|
|
typedef QList<SampleSourceRegistration> SampleSourceRegistrations;
|
|
|
|
|
|
|
|
struct SampleSourceDevice {
|
|
|
|
PluginInterface* m_plugin;
|
|
|
|
QString m_displayName;
|
2015-09-30 04:57:40 +00:00
|
|
|
QString m_sourceId;
|
|
|
|
QString m_sourceSerial;
|
|
|
|
int m_sourceSequence;
|
|
|
|
|
|
|
|
SampleSourceDevice(PluginInterface* plugin,
|
|
|
|
const QString& displayName,
|
|
|
|
const QString& sourceId,
|
|
|
|
const QString& sourceSerial,
|
|
|
|
int sourceSequence) :
|
2014-05-18 15:52:39 +00:00
|
|
|
m_plugin(plugin),
|
|
|
|
m_displayName(displayName),
|
2015-09-30 04:57:40 +00:00
|
|
|
m_sourceId(sourceId),
|
|
|
|
m_sourceSerial(sourceSerial),
|
|
|
|
m_sourceSequence(sourceSequence)
|
2014-05-18 15:52:39 +00:00
|
|
|
{ }
|
|
|
|
};
|
2016-05-16 22:04:27 +00:00
|
|
|
|
2014-05-18 15:52:39 +00:00
|
|
|
typedef QList<SampleSourceDevice> SampleSourceDevices;
|
|
|
|
|
|
|
|
PluginAPI m_pluginAPI;
|
|
|
|
MainWindow* m_mainWindow;
|
|
|
|
Plugins m_plugins;
|
|
|
|
|
2016-05-22 22:21:13 +00:00
|
|
|
PluginAPI::ChannelRegistrations m_channelRegistrations; //!< Channel plugins register here
|
|
|
|
SampleSourceRegistrations m_sampleSourceRegistrations; //!< Input source plugins (one per device kind) register here
|
|
|
|
SampleSourceDevices m_sampleSourceDevices; //!< Instances of input sources present in the system
|
2014-05-18 15:52:39 +00:00
|
|
|
|
2016-05-22 22:21:13 +00:00
|
|
|
// "Local" sample source device IDs
|
|
|
|
static const QString m_sdrDaemonDeviceTypeID; //!< SDRdaemon source plugin ID
|
2016-06-19 23:58:46 +00:00
|
|
|
static const QString m_sdrDaemonFECDeviceTypeID; //!< SDRdaemon with FEC source plugin ID
|
2016-05-22 22:21:13 +00:00
|
|
|
static const QString m_fileSourceDeviceTypeID; //!< FileSource source plugin ID
|
2016-05-22 19:56:07 +00:00
|
|
|
|
2016-05-17 09:06:56 +00:00
|
|
|
// QString m_sampleSourceId;
|
|
|
|
// QString m_sampleSourceSerial;
|
|
|
|
// int m_sampleSourceSequence;
|
|
|
|
// PluginGUI* m_sampleSourcePluginGUI;
|
2014-05-18 15:52:39 +00:00
|
|
|
|
|
|
|
void loadPlugins(const QDir& dir);
|
2016-05-16 22:04:27 +00:00
|
|
|
|
|
|
|
friend class MainWindow;
|
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
|