diff --git a/plugins/channelrx/demodais/aisdemodsink.cpp b/plugins/channelrx/demodais/aisdemodsink.cpp index a46d6ea8c..32716bb08 100644 --- a/plugins/channelrx/demodais/aisdemodsink.cpp +++ b/plugins/channelrx/demodais/aisdemodsink.cpp @@ -25,7 +25,6 @@ #include "dsp/scopevis.h" #include "util/db.h" #include "util/stepfunctions.h" -#include "pipes/pipeendpoint.h" #include "maincore.h" #include "aisdemod.h" diff --git a/plugins/channelrx/demodapt/aptdemodsink.cpp b/plugins/channelrx/demodapt/aptdemodsink.cpp index 7e341d6c4..18457ca32 100644 --- a/plugins/channelrx/demodapt/aptdemodsink.cpp +++ b/plugins/channelrx/demodapt/aptdemodsink.cpp @@ -24,7 +24,6 @@ #include "dsp/dspengine.h" #include "util/db.h" #include "util/stepfunctions.h" -#include "pipes/pipeendpoint.h" #include "maincore.h" #include "aptdemod.h" diff --git a/plugins/channelrx/demoddab/dabdemodsink.cpp b/plugins/channelrx/demoddab/dabdemodsink.cpp index f89e8200f..5709ed5e4 100644 --- a/plugins/channelrx/demoddab/dabdemodsink.cpp +++ b/plugins/channelrx/demoddab/dabdemodsink.cpp @@ -23,7 +23,6 @@ #include "dsp/dspengine.h" #include "dsp/datafifo.h" #include "util/db.h" -#include "pipes/pipeendpoint.h" #include "maincore.h" #include "dabdemod.h" diff --git a/plugins/channelrx/demodpacket/packetdemodsink.cpp b/plugins/channelrx/demodpacket/packetdemodsink.cpp index 9741bad68..98928638e 100644 --- a/plugins/channelrx/demodpacket/packetdemodsink.cpp +++ b/plugins/channelrx/demodpacket/packetdemodsink.cpp @@ -24,7 +24,6 @@ #include "dsp/datafifo.h" #include "util/db.h" #include "util/stepfunctions.h" -#include "pipes/pipeendpoint.h" #include "maincore.h" #include "packetdemod.h" diff --git a/plugins/channelrx/radioastronomy/radioastronomy.h b/plugins/channelrx/radioastronomy/radioastronomy.h index 6bd82a1cd..59b3a1420 100644 --- a/plugins/channelrx/radioastronomy/radioastronomy.h +++ b/plugins/channelrx/radioastronomy/radioastronomy.h @@ -39,6 +39,7 @@ class QNetworkAccessManager; class QNetworkReply; class QThread; class DeviceAPI; +class Feature; class RadioAstronomyWorker; class RadioAstronomy : public BasebandSampleSink, public ChannelAPI { diff --git a/plugins/feature/antennatools/antennatoolsgui.h b/plugins/feature/antennatools/antennatoolsgui.h index 46ba3be10..5d4213ab4 100644 --- a/plugins/feature/antennatools/antennatoolsgui.h +++ b/plugins/feature/antennatools/antennatoolsgui.h @@ -24,7 +24,6 @@ #include "feature/featuregui.h" #include "util/messagequeue.h" -#include "pipes/pipeendpoint.h" #include "settings/rollupstate.h" #include "antennatoolssettings.h" diff --git a/plugins/feature/map/mapgui.h b/plugins/feature/map/mapgui.h index 5dd9c0cb0..96cbf2c2b 100644 --- a/plugins/feature/map/mapgui.h +++ b/plugins/feature/map/mapgui.h @@ -30,7 +30,6 @@ #include "feature/featuregui.h" #include "util/messagequeue.h" #include "util/azel.h" -#include "pipes/pipeendpoint.h" #include "settings/rollupstate.h" #include "SWGMapItem.h" diff --git a/plugins/feature/pertester/pertestergui.h b/plugins/feature/pertester/pertestergui.h index 839013f4a..26f26e585 100644 --- a/plugins/feature/pertester/pertestergui.h +++ b/plugins/feature/pertester/pertestergui.h @@ -23,7 +23,6 @@ #include "feature/featuregui.h" #include "util/messagequeue.h" -#include "pipes/pipeendpoint.h" #include "settings/rollupstate.h" #include "pertestersettings.h" diff --git a/sdrbase/CMakeLists.txt b/sdrbase/CMakeLists.txt index 5d5d3a468..899bd7bdc 100644 --- a/sdrbase/CMakeLists.txt +++ b/sdrbase/CMakeLists.txt @@ -170,13 +170,9 @@ set(sdrbase_SOURCES pipes/datafifostore.cpp pipes/datapipes.cpp pipes/datapipesgcworker.cpp - pipes/messagepipeslegacy.cpp pipes/messagepipes.cpp - pipes/messagepipeslegacycommon.cpp - pipes/messagepipeslegacygcworker.cpp pipes/messagepipesgcworker.cpp pipes/messagequeuestore.cpp - pipes/pipeendpoint.cpp pipes/objectpipe.cpp pipes/objectpipesregistrations.cpp @@ -383,13 +379,9 @@ set(sdrbase_HEADERS pipes/datapipesgcworker.h pipes/elementpipescommon.h pipes/elementpipesgc.h - pipes/messagepipeslegacy.h pipes/messagepipes.h - pipes/messagepipeslegacycommon.h - pipes/messagepipeslegacygcworker.h pipes/messagepipesgcworker.h pipes/messagequeuestore.h - pipes/pipeendpoint.h pipes/objectpipe.h pipes/objectpipesregistrations.h diff --git a/sdrbase/channel/channelapi.h b/sdrbase/channel/channelapi.h index 65405560e..dd284db0a 100644 --- a/sdrbase/channel/channelapi.h +++ b/sdrbase/channel/channelapi.h @@ -28,7 +28,6 @@ #include #include "export.h" -#include "pipes/pipeendpoint.h" #include "util/messagequeue.h" class DeviceAPI; @@ -40,7 +39,7 @@ namespace SWGSDRangel class SWGChannelActions; } -class SDRBASE_API ChannelAPI : public QObject, public PipeEndPoint { +class SDRBASE_API ChannelAPI : public QObject { Q_OBJECT public: enum StreamType //!< This is the same enum as in PluginInterface diff --git a/sdrbase/feature/feature.h b/sdrbase/feature/feature.h index a40c5bf1f..7f04633cc 100644 --- a/sdrbase/feature/feature.h +++ b/sdrbase/feature/feature.h @@ -25,7 +25,6 @@ #include #include "export.h" -#include "pipes/pipeendpoint.h" #include "util/messagequeue.h" class WebAPIAdapterInterface; @@ -41,7 +40,7 @@ namespace SWGSDRangel class SWGChannelSettings; } -class SDRBASE_API Feature : public QObject, public PipeEndPoint { +class SDRBASE_API Feature : public QObject { Q_OBJECT public: enum FeatureState { @@ -164,7 +163,6 @@ protected: protected slots: void handleInputMessages(); void handlePipeMessageQueue(MessageQueue* messageQueue); - friend PipeEndPoint; private: QString m_name; //!< Unique identifier in a device set used for sorting may change depending on relative position in device set diff --git a/sdrbase/maincore.h b/sdrbase/maincore.h index 41546bf68..37ca9d563 100644 --- a/sdrbase/maincore.h +++ b/sdrbase/maincore.h @@ -29,7 +29,6 @@ #include "export.h" #include "settings/mainsettings.h" #include "util/message.h" -#include "pipes/messagepipeslegacy.h" #include "pipes/messagepipes.h" #include "pipes/datapipes.h" #include "channel/channelapi.h" @@ -577,26 +576,26 @@ public: MESSAGE_CLASS_DECLARATION public: - const PipeEndPoint *getPipeSource() const { return m_pipeSource; } + const QObject *getPipeSource() const { return m_pipeSource; } QByteArray getPacket() const { return m_packet; } QDateTime getDateTime() const { return m_dateTime; } - static MsgPacket* create(const PipeEndPoint *pipeSource, QByteArray packet) + static MsgPacket* create(const QObject *pipeSource, QByteArray packet) { return new MsgPacket(pipeSource, packet, QDateTime::currentDateTime()); } - static MsgPacket* create(const PipeEndPoint *pipeSource, QByteArray packet, QDateTime dateTime) + static MsgPacket* create(const QObject *pipeSource, QByteArray packet, QDateTime dateTime) { return new MsgPacket(pipeSource, packet, dateTime); } private: - const PipeEndPoint *m_pipeSource; + const QObject *m_pipeSource; QByteArray m_packet; QDateTime m_dateTime; - MsgPacket(const PipeEndPoint *pipeSource, QByteArray packet, QDateTime dateTime) : + MsgPacket(const QObject *pipeSource, QByteArray packet, QDateTime dateTime) : Message(), m_pipeSource(pipeSource), m_packet(packet), @@ -658,19 +657,19 @@ public: MESSAGE_CLASS_DECLARATION public: - const PipeEndPoint *getPipeSource() const { return m_pipeSource; } + const QObject *getPipeSource() const { return m_pipeSource; } SWGSDRangel::SWGStarTrackerDisplaySettings *getSWGStarTrackerDisplaySettings() const { return m_swgStarTrackerDisplaySettings; } - static MsgStarTrackerDisplaySettings* create(const PipeEndPoint *pipeSource, SWGSDRangel::SWGStarTrackerDisplaySettings *swgStarTrackerDisplaySettings) + static MsgStarTrackerDisplaySettings* create(const QObject *pipeSource, SWGSDRangel::SWGStarTrackerDisplaySettings *swgStarTrackerDisplaySettings) { return new MsgStarTrackerDisplaySettings(pipeSource, swgStarTrackerDisplaySettings); } private: - const PipeEndPoint *m_pipeSource; + const QObject *m_pipeSource; SWGSDRangel::SWGStarTrackerDisplaySettings *m_swgStarTrackerDisplaySettings; - MsgStarTrackerDisplaySettings(const PipeEndPoint *pipeSource, SWGSDRangel::SWGStarTrackerDisplaySettings *swgStarTrackerDisplaySettings) : + MsgStarTrackerDisplaySettings(const QObject *pipeSource, SWGSDRangel::SWGStarTrackerDisplaySettings *swgStarTrackerDisplaySettings) : Message(), m_pipeSource(pipeSource), m_swgStarTrackerDisplaySettings(swgStarTrackerDisplaySettings) @@ -681,19 +680,19 @@ public: MESSAGE_CLASS_DECLARATION public: - const PipeEndPoint *getPipeSource() const { return m_pipeSource; } + const QObject *getPipeSource() const { return m_pipeSource; } SWGSDRangel::SWGStarTrackerDisplayLoSSettings *getSWGStarTrackerDisplayLoSSettings() const { return m_swgStarTrackerDisplayLoSSettings; } - static MsgStarTrackerDisplayLoSSettings* create(const PipeEndPoint *pipeSource, SWGSDRangel::SWGStarTrackerDisplayLoSSettings *swgStarTrackerDisplayLoSSettings) + static MsgStarTrackerDisplayLoSSettings* create(const QObject *pipeSource, SWGSDRangel::SWGStarTrackerDisplayLoSSettings *swgStarTrackerDisplayLoSSettings) { return new MsgStarTrackerDisplayLoSSettings(pipeSource, swgStarTrackerDisplayLoSSettings); } private: - const PipeEndPoint *m_pipeSource; + const QObject *m_pipeSource; SWGSDRangel::SWGStarTrackerDisplayLoSSettings *m_swgStarTrackerDisplayLoSSettings; - MsgStarTrackerDisplayLoSSettings(const PipeEndPoint *pipeSource, SWGSDRangel::SWGStarTrackerDisplayLoSSettings *swgStarTrackerDisplayLoSSettings) : + MsgStarTrackerDisplayLoSSettings(const QObject *pipeSource, SWGSDRangel::SWGStarTrackerDisplayLoSSettings *swgStarTrackerDisplayLoSSettings) : Message(), m_pipeSource(pipeSource), m_swgStarTrackerDisplayLoSSettings(swgStarTrackerDisplayLoSSettings) @@ -737,7 +736,6 @@ public: void removeFeatureInstance(Feature *feature); void clearFeatures(FeatureSet *featureSet); // pipes - MessagePipesLegacy& getMessagePipesLegacy() { return m_messagePipesLegacy; } MessagePipes& getMessagePipes() { return m_messagePipes; } DataPipes& getDataPipes() { return m_dataPipes; } @@ -771,7 +769,6 @@ private: QMap m_channelsMap; //!< Channel to device set map QMap m_featuresMap; //!< Feature to feature set map PluginManager* m_pluginManager; - MessagePipesLegacy m_messagePipesLegacy; MessagePipes m_messagePipes; DataPipes m_dataPipes; diff --git a/sdrbase/pipes/messagepipeslegacy.cpp b/sdrbase/pipes/messagepipeslegacy.cpp deleted file mode 100644 index 6d9355bba..000000000 --- a/sdrbase/pipes/messagepipeslegacy.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2020 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 . // -/////////////////////////////////////////////////////////////////////////////////// - -#include - -#include "util/messagequeue.h" - -#include "messagepipeslegacygcworker.h" -#include "messagepipeslegacy.h" -#include "pipeendpoint.h" - -MessagePipesLegacy::MessagePipesLegacy() -{ - m_gcWorker = new MessagePipesLegacyGCWorker(); - m_gcWorker->setC2FRegistrations( - m_registrations.getMutex(), - m_registrations.getElements(), - m_registrations.getConsumers() - ); - m_gcWorker->moveToThread(&m_gcThread); - startGC(); -} - -MessagePipesLegacy::~MessagePipesLegacy() -{ - if (m_gcWorker->isRunning()) { - stopGC(); - } -} - -MessageQueue *MessagePipesLegacy::registerChannelToFeature(const PipeEndPoint *source, PipeEndPoint *dest, const QString& type) -{ - qDebug("MessagePipesLegacy::registerChannelToFeature: %p %p %s", source, dest, qPrintable(type)); - return m_registrations.registerProducerToConsumer(source, dest, type); -} - -MessageQueue *MessagePipesLegacy::unregisterChannelToFeature(const PipeEndPoint *source, PipeEndPoint *dest, const QString& type) -{ - qDebug("MessagePipesLegacy::unregisterChannelToFeature: %p %p %s", source, dest, qPrintable(type)); - MessageQueue *messageQueue = m_registrations.unregisterProducerToConsumer(source, dest, type); - m_gcWorker->addMessageQueueToDelete(messageQueue); - return messageQueue; -} - -QList* MessagePipesLegacy::getMessageQueues(const PipeEndPoint *source, const QString& type) -{ - //qDebug("MessagePipesLegacy::getMessageQueues: %p %s", source, qPrintable(type)); - return m_registrations.getElements(source, type); -} - -void MessagePipesLegacy::startGC() -{ - qDebug("MessagePipesLegacy::startGC"); - m_gcWorker->startWork(); - m_gcThread.start(); -} - -void MessagePipesLegacy::stopGC() -{ - qDebug("MessagePipesLegacy::stopGC"); - m_gcWorker->stopWork(); - m_gcThread.quit(); - m_gcThread.wait(); -} diff --git a/sdrbase/pipes/messagepipeslegacy.h b/sdrbase/pipes/messagepipeslegacy.h deleted file mode 100644 index 562e582a8..000000000 --- a/sdrbase/pipes/messagepipeslegacy.h +++ /dev/null @@ -1,59 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2020 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 . // -/////////////////////////////////////////////////////////////////////////////////// - -#ifndef SDRBASE_PIPES_MESSAGEPIPESLEGACY_H_ -#define SDRBASE_PIPES_MESSAGEPIPESLEGACY_H_ - -#include -#include -#include -#include -#include - -#include "export.h" - -#include "messagepipeslegacycommon.h" -#include "elementpipesregistrations.h" - -class PipeEndPoint; -class MessagePipesLegacyGCWorker; -class MessageQueue; - -class SDRBASE_API MessagePipesLegacy : public QObject -{ - Q_OBJECT -public: - MessagePipesLegacy(); - MessagePipesLegacy(const MessagePipesLegacy&) = delete; - MessagePipesLegacy& operator=(const MessagePipesLegacy&) = delete; - ~MessagePipesLegacy(); - - // FIXME: Names of these functions should probably change, as we now support channel or feature at either end - MessageQueue *registerChannelToFeature(const PipeEndPoint *source, PipeEndPoint *dest, const QString& type); - MessageQueue *unregisterChannelToFeature(const PipeEndPoint *source, PipeEndPoint *dest, const QString& type); - QList* getMessageQueues(const PipeEndPoint *source, const QString& type); - -private: - ElementPipesRegistrations m_registrations; - QThread m_gcThread; //!< Garbage collector thread - MessagePipesLegacyGCWorker *m_gcWorker; //!< Garbage collector - - void startGC(); //!< Start garbage collector - void stopGC(); //!< Stop garbage collector -}; - -#endif // SDRBASE_PIPES_MESSAGEPIPESLEGACY_H_ diff --git a/sdrbase/pipes/messagepipeslegacycommon.cpp b/sdrbase/pipes/messagepipeslegacycommon.cpp deleted file mode 100644 index 984a452d5..000000000 --- a/sdrbase/pipes/messagepipeslegacycommon.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2020 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 . // -/////////////////////////////////////////////////////////////////////////////////// - -#include "messagepipeslegacycommon.h" - -MESSAGE_CLASS_DEFINITION(MessagePipesLegacyCommon::MsgReportChannelDeleted, Message) diff --git a/sdrbase/pipes/messagepipeslegacycommon.h b/sdrbase/pipes/messagepipeslegacycommon.h deleted file mode 100644 index 42f3b9600..000000000 --- a/sdrbase/pipes/messagepipeslegacycommon.h +++ /dev/null @@ -1,61 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2020 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 . // -/////////////////////////////////////////////////////////////////////////////////// - -#ifndef SDRBASE_PIPES_MESSAGEPIPESLEGACYCOMON_H_ -#define SDRBASE_PIPES_MESSAGEPIPESLEGACYCOMON_H_ - -#include -#include -#include - -#include "export.h" -#include "util/message.h" -#include "elementpipescommon.h" - -class PipeEndPoint; -class MessageQueue; - -class SDRBASE_API MessagePipesLegacyCommon -{ -public: - typedef ElementPipesCommon::RegistrationKey ChannelRegistrationKey; - - /** Send this message to stakeholders when the garbage collector finds that a channel was deleted */ - class SDRBASE_API MsgReportChannelDeleted : public Message { - MESSAGE_CLASS_DECLARATION - - public: - const MessageQueue *getMessageQueue() const { return m_messageQueue; } - const ChannelRegistrationKey& getChannelRegistrationKey() const { return m_channelRegistrationKey; } - - static MsgReportChannelDeleted* create(const MessageQueue *messageQueue, const ChannelRegistrationKey& channelRegistrationKey) { - return new MsgReportChannelDeleted(messageQueue, channelRegistrationKey); - } - - private: - const MessageQueue *m_messageQueue; - ChannelRegistrationKey m_channelRegistrationKey; - - MsgReportChannelDeleted(const MessageQueue *messageQueue, const ChannelRegistrationKey& channelRegistrationKey) : - Message(), - m_messageQueue(messageQueue), - m_channelRegistrationKey(channelRegistrationKey) - { } - }; -}; - -#endif // SDRBASE_PIPES_MESSAGEPIPESLEGACYCOMON_H_ diff --git a/sdrbase/pipes/messagepipeslegacygcworker.cpp b/sdrbase/pipes/messagepipeslegacygcworker.cpp deleted file mode 100644 index f05c65bc3..000000000 --- a/sdrbase/pipes/messagepipeslegacygcworker.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2020 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 . // -/////////////////////////////////////////////////////////////////////////////////// - -#include "channel/channelapi.h" -#include "feature/feature.h" -#include "util/messagequeue.h" -#include "maincore.h" -#include "messagepipeslegacycommon.h" -#include "messagepipeslegacygcworker.h" - -bool MessagePipesLegacyGCWorker::MessagePipesGC::existsProducer(const PipeEndPoint *pipeEndPoint) -{ - return MainCore::instance()->existsChannel((const ChannelAPI *)pipeEndPoint) - || MainCore::instance()->existsFeature((const Feature *)pipeEndPoint); -} - -bool MessagePipesLegacyGCWorker::MessagePipesGC::existsConsumer(const PipeEndPoint *pipeEndPoint) -{ - return MainCore::instance()->existsChannel((const ChannelAPI *)pipeEndPoint) - || MainCore::instance()->existsFeature((const Feature *)pipeEndPoint); -} - -void MessagePipesLegacyGCWorker::MessagePipesGC::sendMessageToConsumer( - const MessageQueue *, - MessagePipesLegacyCommon::ChannelRegistrationKey, - PipeEndPoint *) -{ -} - -MessagePipesLegacyGCWorker::MessagePipesLegacyGCWorker() : - m_running(false) -{} - -MessagePipesLegacyGCWorker::~MessagePipesLegacyGCWorker() -{} - -void MessagePipesLegacyGCWorker::startWork() -{ - connect(&m_gcTimer, SIGNAL(timeout()), this, SLOT(processGC())); - m_gcTimer.start(10000); // collect garbage every 10s - m_running = true; -} - -void MessagePipesLegacyGCWorker::stopWork() -{ - m_running = false; - m_gcTimer.stop(); - disconnect(&m_gcTimer, SIGNAL(timeout()), this, SLOT(processGC())); -} - -void MessagePipesLegacyGCWorker::addMessageQueueToDelete(MessageQueue *messageQueue) -{ - if (messageQueue) - { - m_gcTimer.start(10000); // restart GC to make sure deletion is postponed - m_messagePipesGC.addElementToDelete(messageQueue); - } -} - -void MessagePipesLegacyGCWorker::processGC() -{ - // qDebug("MessagePipesLegacyGCWorker::processGC"); - m_messagePipesGC.processGC(); -} diff --git a/sdrbase/pipes/messagepipeslegacygcworker.h b/sdrbase/pipes/messagepipeslegacygcworker.h deleted file mode 100644 index 309b13125..000000000 --- a/sdrbase/pipes/messagepipeslegacygcworker.h +++ /dev/null @@ -1,69 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2020 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 . // -/////////////////////////////////////////////////////////////////////////////////// - -#ifndef SDRBASE_PIPES_MESSAGEPIPESLEGACYGCWORKER_H_ -#define SDRBASE_PIPES_MESSAGEPIPESLEGACYGCWORKER_H_ - -#include -#include - -#include "export.h" - -#include "messagepipeslegacycommon.h" -#include "elementpipesgc.h" - -class QMutex; - -class SDRBASE_API MessagePipesLegacyGCWorker : public QObject -{ - Q_OBJECT -public: - MessagePipesLegacyGCWorker(); - ~MessagePipesLegacyGCWorker(); - - void setC2FRegistrations( - QMutex *c2fMutex, - QMap> *c2fQueues, - QMap> *c2fPipeEndPoints - ) - { - m_messagePipesGC.setRegistrations(c2fMutex, c2fQueues, c2fPipeEndPoints); - } - - void startWork(); - void stopWork(); - void addMessageQueueToDelete(MessageQueue *messageQueue); - bool isRunning() const { return m_running; } - -private: - class MessagePipesGC : public ElementPipesGC - { - private: - virtual bool existsProducer(const PipeEndPoint *pipeEndPoint); - virtual bool existsConsumer(const PipeEndPoint *pipeEndPoint); - virtual void sendMessageToConsumer(const MessageQueue *messageQueue, MessagePipesLegacyCommon::ChannelRegistrationKey key, PipeEndPoint *pipeEndPoint); - }; - - MessagePipesGC m_messagePipesGC; - bool m_running; - QTimer m_gcTimer; - -private slots: - void processGC(); //!< Collect garbage -}; - -#endif // SDRBASE_PIPES_MESSAGEPIPESLEGACYGCWORKER_H_ diff --git a/sdrbase/pipes/pipeendpoint.cpp b/sdrbase/pipes/pipeendpoint.cpp deleted file mode 100644 index 9a3ba38eb..000000000 --- a/sdrbase/pipes/pipeendpoint.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2021 Jon Beniston, M7RCE // -// // -// 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 . // -/////////////////////////////////////////////////////////////////////////////////// - -#include - -#include -#include - -#include "dsp/dspengine.h" -#include "device/deviceset.h" -#include "channel/channelapi.h" -#include "feature/featureset.h" -#include "feature/feature.h" -#include "maincore.h" - -#include "pipeendpoint.h" - -MESSAGE_CLASS_DEFINITION(PipeEndPoint::MsgReportPipes, Message) - -QList PipeEndPoint::updateAvailablePipeSources(QString pipeName, QStringList pipeTypes, QStringList pipeURIs, PipeEndPoint *destination) -{ - MainCore *mainCore = MainCore::instance(); - MessagePipesLegacy& messagePipes = mainCore->getMessagePipesLegacy(); - std::vector& deviceSets = mainCore->getDeviceSets(); - QHash availablePipes; - - // Source is a channel - int deviceIndex = 0; - for (std::vector::const_iterator it = deviceSets.begin(); it != deviceSets.end(); ++it, deviceIndex++) - { - DSPDeviceSourceEngine *deviceSourceEngine = (*it)->m_deviceSourceEngine; - DSPDeviceSinkEngine *deviceSinkEngine = (*it)->m_deviceSinkEngine; - - if (deviceSourceEngine || deviceSinkEngine) - { - for (int chi = 0; chi < (*it)->getNumberOfChannels(); chi++) - { - ChannelAPI *channel = (*it)->getChannelAt(chi); - int i = pipeURIs.indexOf(channel->getURI()); - - if (i >= 0) - { - if (!availablePipes.contains(channel)) - { - MessageQueue *messageQueue = messagePipes.registerChannelToFeature(channel, destination, pipeName); - if (MainCore::instance()->existsFeature((const Feature *)destination)) - { - // Destination is feature - Feature *featureDest = (Feature *)destination; - QObject::connect( - messageQueue, - &MessageQueue::messageEnqueued, - featureDest, - [=](){ featureDest->handlePipeMessageQueue(messageQueue); }, - Qt::QueuedConnection - ); - } - else - { - // Destination is a channel - // Can't use Qt::QueuedConnection because ChannelAPI isn't a QObject - ChannelAPI *channelDest = (ChannelAPI *)destination; - QObject::connect( - messageQueue, - &MessageQueue::messageEnqueued, - [=](){ channelDest->handlePipeMessageQueue(messageQueue); } - ); - } - } - - AvailablePipeSource availablePipe = - AvailablePipeSource{ - deviceSinkEngine != nullptr ? AvailablePipeSource::TX : AvailablePipeSource::RX, - deviceIndex, - chi, - channel, - pipeTypes.at(i) - }; - availablePipes[channel] = availablePipe; - } - } - } - } - - // Source is a feature - std::vector& featureSets = mainCore->getFeatureeSets(); - int featureIndex = 0; - for (std::vector::const_iterator it = featureSets.begin(); it != featureSets.end(); ++it, featureIndex++) - { - for (int fi = 0; fi < (*it)->getNumberOfFeatures(); fi++) - { - Feature *feature = (*it)->getFeatureAt(fi); - int i = pipeURIs.indexOf(feature->getURI()); - - if (i >= 0) - { - if (!availablePipes.contains(feature)) - { - MessageQueue *messageQueue = messagePipes.registerChannelToFeature(feature, destination, pipeName); - if (MainCore::instance()->existsFeature((const Feature *)destination)) - { - // Destination is feature - Feature *featureDest = (Feature *)destination; - QObject::connect( - messageQueue, - &MessageQueue::messageEnqueued, - featureDest, - [=](){ featureDest->handlePipeMessageQueue(messageQueue); }, - Qt::QueuedConnection - ); - } - else - { - // Destination is a channel - // Can't use Qt::QueuedConnection because ChannelAPI isn't a QObject - ChannelAPI *channelDest = (ChannelAPI *)destination; - QObject::connect( - messageQueue, - &MessageQueue::messageEnqueued, - [=](){ channelDest->handlePipeMessageQueue(messageQueue); } - ); - } - } - - AvailablePipeSource availablePipe = - AvailablePipeSource{ - AvailablePipeSource::Feature, - featureIndex, - fi, - feature, - pipeTypes.at(i) - }; - availablePipes[feature] = availablePipe; - } - } - } - - QList availablePipeList; - QHash::iterator it = availablePipes.begin(); - - for (; it != availablePipes.end(); ++it) { - availablePipeList.push_back(*it); - } - return availablePipeList; -} - -PipeEndPoint *PipeEndPoint::getPipeEndPoint(const QString name, const QList &availablePipeSources) -{ - QRegExp re("([TRF])([0-9]+):([0-9]+) ([a-zA-Z0-9]+)"); - if (re.exactMatch(name)) - { - QString type = re.capturedTexts()[1]; - int setIndex = re.capturedTexts()[2].toInt(); - int index = re.capturedTexts()[3].toInt(); - QString id = re.capturedTexts()[4]; - - QListIterator itr(availablePipeSources); - while (itr.hasNext()) - { - AvailablePipeSource p = itr.next(); - if ((p.m_setIndex == setIndex) && (p.m_index == index) && (id == p.m_id)) { - return p.m_source; - } - } - } - else - { - qDebug() << "PipeEndPoint::getPipeEndPoint: " << name << " is malformed"; - } - return nullptr; -} diff --git a/sdrbase/pipes/pipeendpoint.h b/sdrbase/pipes/pipeendpoint.h deleted file mode 100644 index 5de230b09..000000000 --- a/sdrbase/pipes/pipeendpoint.h +++ /dev/null @@ -1,100 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2021 Jon Beniston, M7RCE // -// // -// Parent for ChannelAPI and Features, where either can be used. // -// // -// 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 . // -/////////////////////////////////////////////////////////////////////////////////// - -#ifndef SDRBASE_PIPES_PIPEENDPOINT_H_ -#define SDRBASE_PIPES_PIPEENDPOINT_H_ - -#include -#include -#include - -#include "util/message.h" -#include "export.h" - -class Feature; - -class SDRBASE_API PipeEndPoint { -public: - - // Used by pipe sinks (channels or features) to record details about available pipe sources (channels or features) - struct AvailablePipeSource - { - enum {RX, TX, Feature} m_type; - int m_setIndex; - int m_index; - PipeEndPoint *m_source; - QString m_id; - - AvailablePipeSource() = default; - AvailablePipeSource(const AvailablePipeSource&) = default; - AvailablePipeSource& operator=(const AvailablePipeSource&) = default; - friend bool operator==(const AvailablePipeSource &lhs, const AvailablePipeSource &rhs) - { - return (lhs.m_type == rhs.m_type) - && (lhs.m_setIndex == rhs.m_setIndex) - && (lhs.m_source == rhs.m_source) - && (lhs.m_id == rhs.m_id); - } - - QString getTypeName() const - { - QStringList typeNames = {"R", "T", "F"}; - return typeNames[m_type]; - } - - // Name for use in GUI combo boxes and WebAPI - QString getName() const - { - QString type; - - return QString("%1%2:%3 %4").arg(getTypeName()) - .arg(m_setIndex) - .arg(m_index) - .arg(m_id); - } - }; - - class SDRBASE_API MsgReportPipes : public Message { - MESSAGE_CLASS_DECLARATION - - public: - QList& getAvailablePipes() { return m_availablePipes; } - - static MsgReportPipes* create() { - return new MsgReportPipes(); - } - - private: - QList m_availablePipes; - - MsgReportPipes() : - Message() - {} - }; - - -protected: - - // Utility functions for pipe sinks to manage list of sources - QList updateAvailablePipeSources(QString pipeName, QStringList pipeTypes, QStringList pipeURIs, PipeEndPoint *destination); - PipeEndPoint *getPipeEndPoint(const QString name, const QList &availablePipeSources); - -}; - -#endif // SDRBASE_PIPES_PIPEENDPOINT_H_