1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-03 07:21:14 -05:00
sdrangel/sdrbase/plugin/pluginmanager.h

119 lines
3.6 KiB
C
Raw Normal View History

#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;
class MessageQueue;
class DeviceSourceAPI;
2015-08-29 19:26:51 -04:00
class SDRANGEL_API PluginManager : public QObject {
Q_OBJECT
public:
struct Plugin
{
QString filename;
QPluginLoader* loader;
2015-09-30 02:55:58 -04:00
PluginInterface* pluginInterface;
Plugin(const QString& _filename, QPluginLoader* pluginLoader, PluginInterface* _plugin) :
filename(_filename),
loader(pluginLoader),
2015-09-30 02:55:58 -04:00
pluginInterface(_plugin)
{ }
};
typedef QList<Plugin> Plugins;
explicit PluginManager(MainWindow* mainWindow, QObject* parent = NULL);
~PluginManager();
2016-05-14 04:38:29 -04:00
void loadPlugins();
const Plugins& getPlugins() const { return m_plugins; }
// Callbacks from the plugins
2016-10-13 16:23:43 -04:00
void registerRxChannel(const QString& channelName, PluginInterface* plugin);
void registerSampleSource(const QString& sourceName, PluginInterface* plugin);
2016-10-13 16:23:43 -04:00
PluginAPI::ChannelRegistrations *getRxChannelRegistrations() { return &m_rxChannelRegistrations; }
void updateSampleSourceDevices();
void duplicateLocalSampleSourceDevices(uint deviceUID);
void fillSampleSourceSelector(QComboBox* comboBox, uint deviceUID);
int selectSampleSourceByIndex(int index, DeviceSourceAPI *deviceAPI);
int selectFirstSampleSource(const QString& sourceId, DeviceSourceAPI *deviceAPI);
int selectSampleSourceBySerialOrSequence(const QString& sourceId, const QString& sourceSerial, int sourceSequence, DeviceSourceAPI *deviceAPI);
void selectSampleSourceByDevice(void *devicePtr, DeviceSourceAPI *deviceAPI);
2016-10-13 17:42:08 -04:00
void populateRxChannelComboBox(QComboBox *channels);
void createRxChannelInstance(int channelPluginIndex, DeviceSourceAPI *deviceAPI);
private:
2016-10-13 16:23:43 -04:00
struct SamplingDeviceRegistration {
QString m_deviceId;
PluginInterface* m_plugin;
2016-10-13 16:23:43 -04:00
SamplingDeviceRegistration(const QString& deviceId, PluginInterface* plugin) :
m_deviceId(deviceId),
m_plugin(plugin)
{ }
};
2016-10-13 16:23:43 -04:00
typedef QList<SamplingDeviceRegistration> SamplingDeviceRegistrations;
2016-10-13 16:23:43 -04:00
struct SamplingDevice {
PluginInterface* m_plugin;
QString m_displayName;
2016-10-13 16:23:43 -04:00
QString m_deviceId;
QString m_deviceSerial;
int m_deviceSequence;
2016-10-13 16:23:43 -04:00
SamplingDevice(PluginInterface* plugin,
const QString& displayName,
2016-10-13 16:23:43 -04:00
const QString& deviceId,
const QString& deviceSerial,
int deviceSequence) :
m_plugin(plugin),
m_displayName(displayName),
2016-10-13 16:23:43 -04:00
m_deviceId(deviceId),
m_deviceSerial(deviceSerial),
m_deviceSequence(deviceSequence)
{ }
};
2016-10-13 16:23:43 -04:00
typedef QList<SamplingDevice> SamplingDevices;
PluginAPI m_pluginAPI;
MainWindow* m_mainWindow;
Plugins m_plugins;
2016-10-13 16:23:43 -04:00
PluginAPI::ChannelRegistrations m_rxChannelRegistrations; //!< Channel plugins register here
SamplingDeviceRegistrations m_sampleSourceRegistrations; //!< Input source plugins (one per device kind) register here
SamplingDevices m_sampleSourceDevices; //!< Instances of input sources present in the system
// "Local" sample source device IDs
static const QString m_sdrDaemonDeviceTypeID; //!< SDRdaemon source plugin ID
static const QString m_sdrDaemonFECDeviceTypeID; //!< SDRdaemon with FEC source plugin ID
static const QString m_fileSourceDeviceTypeID; //!< FileSource source plugin ID
void loadPlugins(const QDir& dir);
friend class MainWindow;
};
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;
}
#endif // INCLUDE_PLUGINMANAGER_H