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