SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
pluginmanager.h
Go to the documentation of this file.
1 // Copyright (C) 2016-2019 Edouard Griffiths, F4EXB //
3 // //
4 // This program is free software; you can redistribute it and/or modify //
5 // it under the terms of the GNU General Public License as published by //
6 // the Free Software Foundation as version 3 of the License, or //
7 // (at your option) any later version. //
8 // //
9 // This program is distributed in the hope that it will be useful, //
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
12 // GNU General Public License V3 for more details. //
13 // //
14 // You should have received a copy of the GNU General Public License //
15 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
17 
18 #ifndef INCLUDE_PLUGINMANAGER_H
19 #define INCLUDE_PLUGINMANAGER_H
20 
21 #include <stdint.h>
22 #include <QObject>
23 #include <QDir>
24 #include <QList>
25 #include <QString>
26 
27 #include "plugin/plugininterface.h"
28 #include "plugin/pluginapi.h"
29 #include "export.h"
30 
31 class QComboBox;
32 class QPluginLoader;
33 class Preset;
34 class Message;
35 class MessageQueue;
36 class DeviceAPI;
37 
38 class SDRBASE_API PluginManager : public QObject {
39  Q_OBJECT
40 
41 public:
42  struct Plugin
43  {
44  QString filename;
46 
47  Plugin(const QString& _filename, PluginInterface* _plugin) :
48  filename(_filename),
49  pluginInterface(_plugin)
50  { }
51  };
52 
53  typedef QList<Plugin> Plugins;
54 
55  explicit PluginManager(QObject* parent = 0);
56  ~PluginManager();
57 
58  PluginAPI *getPluginAPI() { return &m_pluginAPI; }
59  void loadPlugins(const QString& pluginsSubDir);
60  void loadPluginsPart(const QString& pluginsSubDir);
61  void loadPluginsFinal();
62  const Plugins& getPlugins() const { return m_plugins; }
63 
64  // Callbacks from the plugins
65  void registerRxChannel(const QString& channelIdURI, const QString& channelId, PluginInterface* plugin);
66  void registerSampleSource(const QString& sourceName, PluginInterface* plugin);
67  void registerTxChannel(const QString& channelIdURI, const QString& channelId, PluginInterface* plugin);
68  void registerSampleSink(const QString& sinkName, PluginInterface* plugin);
69  void registerSampleMIMO(const QString& mimoName, PluginInterface* plugin);
70 
71  PluginAPI::SamplingDeviceRegistrations& getSourceDeviceRegistrations() { return m_sampleSourceRegistrations; }
72  PluginAPI::SamplingDeviceRegistrations& getSinkDeviceRegistrations() { return m_sampleSinkRegistrations; }
73  PluginAPI::SamplingDeviceRegistrations& getMIMODeviceRegistrations() { return m_sampleMIMORegistrations; }
74  PluginAPI::ChannelRegistrations *getRxChannelRegistrations() { return &m_rxChannelRegistrations; }
75  PluginAPI::ChannelRegistrations *getTxChannelRegistrations() { return &m_txChannelRegistrations; }
76 
77  void createRxChannelInstance(int channelPluginIndex, DeviceUISet *deviceUISet, DeviceAPI *deviceAPI);
78  void listRxChannels(QList<QString>& list);
79 
80  void createTxChannelInstance(int channelPluginIndex, DeviceUISet *deviceUISet, DeviceAPI *deviceAPI);
81  void listTxChannels(QList<QString>& list);
82 
83  static const QString& getFileInputDeviceId() { return m_fileInputDeviceTypeID; }
84  static const QString& getFileSinkDeviceId() { return m_fileSinkDeviceTypeID; }
85  static const QString& getTestMIMODeviceId() { return m_testMIMODeviceTypeID; }
86 
87 private:
88  struct SamplingDevice {
90  QString m_displayName;
91  QString m_hadrwareId;
92  QString m_deviceId;
93  QString m_deviceSerial;
95 
97  const QString& displayName,
98  const QString& hadrwareId,
99  const QString& deviceId,
100  const QString& deviceSerial,
101  int deviceSequence) :
102  m_plugin(plugin),
103  m_displayName(displayName),
104  m_hadrwareId(hadrwareId),
105  m_deviceId(deviceId),
106  m_deviceSerial(deviceSerial),
107  m_deviceSequence(deviceSequence)
108  { }
109  };
110 
111  typedef QList<SamplingDevice> SamplingDevices;
112 
114  Plugins m_plugins;
115 
118 
121 
123 
124  // "Local" sample source device IDs
125  static const QString m_localInputHardwareID;
126  static const QString m_localInputDeviceTypeID;
127  static const QString m_remoteInputHardwareID;
128  static const QString m_remoteInputDeviceTypeID;
129  static const QString m_fileInputHardwareID;
130  static const QString m_fileInputDeviceTypeID;
131 
132  // "Local" sample sink device IDs
133  static const QString m_localOutputHardwareID;
134  static const QString m_localOutputDeviceTypeID;
135  static const QString m_remoteOutputHardwareID;
136  static const QString m_remoteOutputDeviceTypeID;
137  static const QString m_fileSinkHardwareID;
138  static const QString m_fileSinkDeviceTypeID;
139 
140  // "Local" sample MIMO device IDs
141  static const QString m_testMIMOHardwareID;
142  static const QString m_testMIMODeviceTypeID;
143 
144  void loadPluginsDir(const QDir& dir);
145 };
146 
147 static inline bool operator<(const PluginManager::Plugin& a, const PluginManager::Plugin& b)
148 {
150 }
151 
152 #endif // INCLUDE_PLUGINMANAGER_H
QList< Plugin > Plugins
Definition: pluginmanager.h:53
static const QString m_remoteInputHardwareID
Remote input hardware ID.
QList< ChannelRegistration > ChannelRegistrations
Definition: pluginapi.h:44
const QString displayedName
static const QString m_fileSinkHardwareID
FileSink sink hardware ID.
PluginAPI::ChannelRegistrations * getRxChannelRegistrations()
Definition: pluginmanager.h:74
static const QString & getFileSinkDeviceId()
Definition: pluginmanager.h:84
static const QString & getFileInputDeviceId()
Definition: pluginmanager.h:83
static const QString m_testMIMODeviceTypeID
Test MIMO plugin ID.
static const QString m_localOutputDeviceTypeID
Local output plugin ID.
PluginAPI::ChannelRegistrations m_rxChannelRegistrations
Channel plugins register here.
virtual const PluginDescriptor & getPluginDescriptor() const =0
PluginInterface * pluginInterface
Definition: pluginmanager.h:45
static const QString m_remoteOutputDeviceTypeID
Remote output plugin ID.
static const QString m_localOutputHardwareID
Local output hardware ID.
static const QString m_fileSinkDeviceTypeID
FileSink sink plugin ID.
PluginAPI::ChannelRegistrations * getTxChannelRegistrations()
Definition: pluginmanager.h:75
QList< SamplingDeviceRegistration > SamplingDeviceRegistrations
Definition: pluginapi.h:30
static const QString & getTestMIMODeviceId()
Definition: pluginmanager.h:85
unsigned int uint32_t
Definition: rtptypes_win.h:46
PluginAPI::SamplingDeviceRegistrations m_sampleMIMORegistrations
MIMO sink plugins (one per device kind) register here.
static const QString m_localInputHardwareID
Local input hardware ID.
static const QString m_testMIMOHardwareID
Test MIMO hardware ID.
static const QString m_fileInputHardwareID
File input hardware ID.
Definition: preset.h:28
PluginAPI::SamplingDeviceRegistrations m_sampleSinkRegistrations
Output sink plugins (one per device kind) register here.
PluginAPI * getPluginAPI()
Definition: pluginmanager.h:58
static const QString m_remoteInputDeviceTypeID
Remote input plugin ID.
static const QString m_remoteOutputHardwareID
Remote output hardware ID.
static const QString m_localInputDeviceTypeID
Local input plugin ID.
PluginAPI::SamplingDeviceRegistrations & getSinkDeviceRegistrations()
Definition: pluginmanager.h:72
static const QString m_fileInputDeviceTypeID
File input plugin ID.
PluginAPI::ChannelRegistrations m_txChannelRegistrations
Channel plugins register here.
PluginInterface * m_plugin
< This is the device registration
Definition: pluginmanager.h:89
PluginAPI m_pluginAPI
Plugin(const QString &_filename, PluginInterface *_plugin)
Definition: pluginmanager.h:47
QList< SamplingDevice > SamplingDevices
#define SDRBASE_API
Definition: export.h:40
Plugins m_plugins
PluginAPI::SamplingDeviceRegistrations & getMIMODeviceRegistrations()
Definition: pluginmanager.h:73
SamplingDevice(PluginInterface *plugin, const QString &displayName, const QString &hadrwareId, const QString &deviceId, const QString &deviceSerial, int deviceSequence)
Definition: pluginmanager.h:96
PluginAPI::SamplingDeviceRegistrations & getSourceDeviceRegistrations()
Definition: pluginmanager.h:71
const Plugins & getPlugins() const
Definition: pluginmanager.h:62
PluginAPI::SamplingDeviceRegistrations m_sampleSourceRegistrations
Input source plugins (one per device kind) register here.