Skip to content

Commit

Permalink
Removed destroy method leftovers and Sonar lint
Browse files Browse the repository at this point in the history
  • Loading branch information
f4exb committed Aug 27, 2024
1 parent 704eb40 commit 5d0fa7f
Show file tree
Hide file tree
Showing 131 changed files with 524 additions and 627 deletions.
49 changes: 24 additions & 25 deletions plugins/channelmimo/beamsteeringcwmod/beamsteeringcwmod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ BeamSteeringCWMod::BeamSteeringCWMod(DeviceAPI *deviceAPI) :
m_thread(nullptr),
m_basebandSource(nullptr),
m_running(false),
m_guiMessageQueue(nullptr),
m_frequencyOffset(0),
m_basebandSampleRate(48000)
{
Expand All @@ -62,7 +61,7 @@ BeamSteeringCWMod::BeamSteeringCWMod(DeviceAPI *deviceAPI) :
this,
&BeamSteeringCWMod::networkManagerFinished
);
startSources();
BeamSteeringCWMod::startSources();
}

BeamSteeringCWMod::~BeamSteeringCWMod()
Expand All @@ -77,7 +76,7 @@ BeamSteeringCWMod::~BeamSteeringCWMod()

m_deviceAPI->removeChannelSinkAPI(this);
m_deviceAPI->removeMIMOChannel(this);
stopSources();
BeamSteeringCWMod::stopSources();
}

void BeamSteeringCWMod::setDeviceAPI(DeviceAPI *deviceAPI)
Expand Down Expand Up @@ -194,7 +193,7 @@ void BeamSteeringCWMod::applySettings(const BeamSteeringCWModSettings& settings,
QList<ObjectPipe*> pipes;
MainCore::instance()->getMessagePipes().getMessagePipes(this, "settings", pipes);

if (pipes.size() > 0) {
if (!pipes.empty()) {
sendChannelSettings(pipes, reverseAPIKeys, settings, force);
}

Expand All @@ -205,7 +204,7 @@ void BeamSteeringCWMod::handleInputMessages()
{
Message* message;

while ((message = m_inputMessageQueue.pop()) != 0)
while ((message = m_inputMessageQueue.pop()) != nullptr)
{
if (handleMessage(*message))
{
Expand All @@ -218,14 +217,14 @@ bool BeamSteeringCWMod::handleMessage(const Message& cmd)
{
if (MsgConfigureBeamSteeringCWMod::match(cmd))
{
MsgConfigureBeamSteeringCWMod& cfg = (MsgConfigureBeamSteeringCWMod&) cmd;
auto& cfg = (const MsgConfigureBeamSteeringCWMod&) cmd;
qDebug() << "BeamSteeringCWMod::handleMessage: MsgConfigureBeamSteeringCWMod";
applySettings(cfg.getSettings(), cfg.getForce());
return true;
}
else if (DSPMIMOSignalNotification::match(cmd))
{
DSPMIMOSignalNotification& notif = (DSPMIMOSignalNotification&) cmd;
auto& notif = (const DSPMIMOSignalNotification&) cmd;

qDebug() << "BeamSteeringCWMod::handleMessage: DSPMIMOSignalNotification:"
<< " basebandSampleRate: " << notif.getSampleRate()
Expand Down Expand Up @@ -301,7 +300,7 @@ void BeamSteeringCWMod::validateFilterChainHash(BeamSteeringCWModSettings& setti
void BeamSteeringCWMod::calculateFrequencyOffset()
{
double shiftFactor = HBFilterChainConverter::getShiftFactor(m_settings.m_log2Interp, m_settings.m_filterChainHash);
m_frequencyOffset = m_basebandSampleRate * shiftFactor;
m_frequencyOffset = (int64_t) (m_basebandSampleRate * shiftFactor);
}

int BeamSteeringCWMod::webapiSettingsGet(
Expand Down Expand Up @@ -380,13 +379,13 @@ void BeamSteeringCWMod::webapiUpdateChannelSettings(
settings.m_reverseAPIAddress = *response.getBeamSteeringCwModSettings()->getReverseApiAddress();
}
if (channelSettingsKeys.contains("reverseAPIPort")) {
settings.m_reverseAPIPort = response.getBeamSteeringCwModSettings()->getReverseApiPort();
settings.m_reverseAPIPort = (uint16_t) response.getBeamSteeringCwModSettings()->getReverseApiPort();
}
if (channelSettingsKeys.contains("reverseAPIDeviceIndex")) {
settings.m_reverseAPIDeviceIndex = response.getBeamSteeringCwModSettings()->getReverseApiDeviceIndex();
settings.m_reverseAPIDeviceIndex = (uint16_t) response.getBeamSteeringCwModSettings()->getReverseApiDeviceIndex();
}
if (channelSettingsKeys.contains("reverseAPIChannelIndex")) {
settings.m_reverseAPIChannelIndex = response.getBeamSteeringCwModSettings()->getReverseApiChannelIndex();
settings.m_reverseAPIChannelIndex = (uint16_t) response.getBeamSteeringCwModSettings()->getReverseApiChannelIndex();
}
if (settings.m_channelMarker && channelSettingsKeys.contains("channelMarker")) {
settings.m_channelMarker->updateFrom(channelSettingsKeys, response.getBeamSteeringCwModSettings()->getChannelMarker());
Expand Down Expand Up @@ -429,7 +428,7 @@ void BeamSteeringCWMod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSetti
}
else
{
SWGSDRangel::SWGChannelMarker *swgChannelMarker = new SWGSDRangel::SWGChannelMarker();
auto *swgChannelMarker = new SWGSDRangel::SWGChannelMarker();
settings.m_channelMarker->formatTo(swgChannelMarker);
response.getBeamSteeringCwModSettings()->setChannelMarker(swgChannelMarker);
}
Expand All @@ -443,16 +442,16 @@ void BeamSteeringCWMod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSetti
}
else
{
SWGSDRangel::SWGRollupState *swgRollupState = new SWGSDRangel::SWGRollupState();
auto *swgRollupState = new SWGSDRangel::SWGRollupState();
settings.m_rollupState->formatTo(swgRollupState);
response.getBeamSteeringCwModSettings()->setRollupState(swgRollupState);
}
}
}

void BeamSteeringCWMod::webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const BeamSteeringCWModSettings& settings, bool force)
void BeamSteeringCWMod::webapiReverseSendSettings(const QList<QString>& channelSettingsKeys, const BeamSteeringCWModSettings& settings, bool force)
{
SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
auto *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
webapiFormatChannelSettings(channelSettingsKeys, swgChannelSettings, settings, force);

QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings")
Expand All @@ -463,8 +462,8 @@ void BeamSteeringCWMod::webapiReverseSendSettings(QList<QString>& channelSetting
m_networkRequest.setUrl(QUrl(channelSettingsURL));
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");

QBuffer *buffer = new QBuffer();
buffer->open((QBuffer::ReadWrite));
auto *buffer = new QBuffer();
buffer->open(QBuffer::ReadWrite);
buffer->write(swgChannelSettings->asJson().toUtf8());
buffer->seek(0);

Expand All @@ -477,17 +476,17 @@ void BeamSteeringCWMod::webapiReverseSendSettings(QList<QString>& channelSetting

void BeamSteeringCWMod::sendChannelSettings(
const QList<ObjectPipe*>& pipes,
QList<QString>& channelSettingsKeys,
const QList<QString>& channelSettingsKeys,
const BeamSteeringCWModSettings& settings,
bool force)
bool force) const
{
for (const auto& pipe : pipes)
{
MessageQueue *messageQueue = qobject_cast<MessageQueue*>(pipe->m_element);

if (messageQueue)
{
SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
auto *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
webapiFormatChannelSettings(channelSettingsKeys, swgChannelSettings, settings, force);
MainCore::MsgChannelSettings *msg = MainCore::MsgChannelSettings::create(
this,
Expand All @@ -501,11 +500,11 @@ void BeamSteeringCWMod::sendChannelSettings(
}

void BeamSteeringCWMod::webapiFormatChannelSettings(
QList<QString>& channelSettingsKeys,
const QList<QString>& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings *swgChannelSettings,
const BeamSteeringCWModSettings& settings,
bool force
)
) const
{
swgChannelSettings->setDirection(2); // MIMO sink
swgChannelSettings->setOriginatorChannelIndex(getIndexInDeviceSet());
Expand Down Expand Up @@ -534,20 +533,20 @@ void BeamSteeringCWMod::webapiFormatChannelSettings(

if (settings.m_channelMarker && (channelSettingsKeys.contains("channelMarker") || force))
{
SWGSDRangel::SWGChannelMarker *swgChannelMarker = new SWGSDRangel::SWGChannelMarker();
auto *swgChannelMarker = new SWGSDRangel::SWGChannelMarker();
settings.m_channelMarker->formatTo(swgChannelMarker);
swgBeamSteeringCWSettings->setChannelMarker(swgChannelMarker);
}

if (settings.m_rollupState && (channelSettingsKeys.contains("rollupState") || force))
{
SWGSDRangel::SWGRollupState *swgRollupState = new SWGSDRangel::SWGRollupState();
auto *swgRollupState = new SWGSDRangel::SWGRollupState();
settings.m_rollupState->formatTo(swgRollupState);
swgBeamSteeringCWSettings->setRollupState(swgRollupState);
}
}

void BeamSteeringCWMod::networkManagerFinished(QNetworkReply *reply)
void BeamSteeringCWMod::networkManagerFinished(QNetworkReply *reply) const
{
QNetworkReply::NetworkError replyError = reply->error();

Expand Down
101 changes: 49 additions & 52 deletions plugins/channelmimo/beamsteeringcwmod/beamsteeringcwmod.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,67 +86,64 @@ class BeamSteeringCWMod: public MIMOChannel, public ChannelAPI
qint64 m_centerFrequency;
};

BeamSteeringCWMod(DeviceAPI *deviceAPI);
virtual ~BeamSteeringCWMod();
virtual void destroy() { delete this; }
virtual void setDeviceAPI(DeviceAPI *deviceAPI);
virtual DeviceAPI *getDeviceAPI() { return m_deviceAPI; }

virtual void startSinks() {}
virtual void stopSinks() {}
virtual void startSources(); //!< thread start()
virtual void stopSources(); //!< thread exit() and wait()
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, unsigned int sinkIndex);
virtual void pull(SampleVector::iterator& begin, unsigned int nbSamples, unsigned int sourceIndex);
virtual void pushMessage(Message *msg) { m_inputMessageQueue.push(msg); }
virtual QString getMIMOName() { return objectName(); }

virtual void getIdentifier(QString& id) { id = objectName(); }
virtual QString getIdentifier() const { return objectName(); }
virtual void getTitle(QString& title) { title = "BeamSteeringCWMod"; }
virtual qint64 getCenterFrequency() const { return m_frequencyOffset; }
virtual void setCenterFrequency(qint64) {}
explicit BeamSteeringCWMod(DeviceAPI *deviceAPI);
~BeamSteeringCWMod() final;
void destroy() final { delete this; }
void setDeviceAPI(DeviceAPI *deviceAPI) final;
DeviceAPI *getDeviceAPI() final { return m_deviceAPI; }

void startSinks() final { /* Not used for MIMO */ }
void stopSinks() final { /* Not used for MIMO */ }
void startSources( /* Not used for MIMO */ ) final; //!< thread start()
void stopSources( /* Not used for MIMO */ ) final; //!< thread exit() and wait()
void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, unsigned int sinkIndex) final;
void pull(SampleVector::iterator& begin, unsigned int nbSamples, unsigned int sourceIndex) final;
void pushMessage(Message *msg) final { m_inputMessageQueue.push(msg); }
QString getMIMOName() final { return objectName(); }

void getIdentifier(QString& id) final { id = objectName(); }
QString getIdentifier() const final { return objectName(); }
void getTitle(QString& title) final { title = "BeamSteeringCWMod"; }
qint64 getCenterFrequency() const final { return m_frequencyOffset; }
void setCenterFrequency(qint64) final { /* Not used for MIMO */ }
uint32_t getBasebandSampleRate() const { return m_basebandSampleRate; }

virtual QByteArray serialize() const;
virtual bool deserialize(const QByteArray& data);
QByteArray serialize() const final;
bool deserialize(const QByteArray& data) final;

virtual int getNbSinkStreams() const { return 0; }
virtual int getNbSourceStreams() const { return 2; }
virtual int getStreamIndex() const { return -1; }
int getNbSinkStreams() const final { return 0; }
int getNbSourceStreams() const final { return 2; }
int getStreamIndex() const final { return -1; }

virtual qint64 getStreamCenterFrequency(int streamIndex, bool sinkElseSource) const
qint64 getStreamCenterFrequency(int streamIndex, bool sinkElseSource) const final
{
(void) streamIndex;
(void) sinkElseSource;
return m_frequencyOffset;
}

virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
MessageQueue *getMessageQueueToGUI() { return m_guiMessageQueue; }

virtual int webapiSettingsGet(
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage);
int webapiSettingsGet(
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage) final;

virtual int webapiSettingsPutPatch(
bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage);
int webapiSettingsPutPatch(
bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage) final;

virtual int webapiWorkspaceGet(
SWGSDRangel::SWGWorkspaceInfo& query,
QString& errorMessage);
int webapiWorkspaceGet(
SWGSDRangel::SWGWorkspaceInfo& query,
QString& errorMessage) final;

static void webapiFormatChannelSettings(
SWGSDRangel::SWGChannelSettings& response,
const BeamSteeringCWModSettings& settings);

static void webapiUpdateChannelSettings(
BeamSteeringCWModSettings& settings,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response);
BeamSteeringCWModSettings& settings,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response);

static const char* const m_channelIdURI;
static const char* const m_channelId;
Expand All @@ -161,36 +158,36 @@ class BeamSteeringCWMod: public MIMOChannel, public ChannelAPI
BasebandSampleSink* m_spectrumSink;
BasebandSampleSink* m_scopeSink;
BeamSteeringCWModSettings m_settings;
MessageQueue *m_guiMessageQueue; //!< Input message queue to the GUI

QNetworkAccessManager *m_networkManager;
QNetworkRequest m_networkRequest;

int64_t m_frequencyOffset;
uint32_t m_basebandSampleRate;
int m_count0, m_count1;
int m_count0;
int m_count1;

virtual bool handleMessage(const Message& cmd); //!< Processing of a message. Returns true if message has actually been processed
bool handleMessage(const Message& cmd) final; //!< Processing of a message. Returns true if message has actually been processed
void applySettings(const BeamSteeringCWModSettings& settings, bool force = false);
static void validateFilterChainHash(BeamSteeringCWModSettings& settings);
void calculateFrequencyOffset();
void webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const BeamSteeringCWModSettings& settings, bool force);
void webapiReverseSendSettings(const QList<QString>& channelSettingsKeys, const BeamSteeringCWModSettings& settings, bool force);
void sendChannelSettings(
const QList<ObjectPipe*>& pipes,
QList<QString>& channelSettingsKeys,
const QList<QString>& channelSettingsKeys,
const BeamSteeringCWModSettings& settings,
bool force
);
) const;
void webapiFormatChannelSettings(
QList<QString>& channelSettingsKeys,
const QList<QString>& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings *swgChannelSettings,
const BeamSteeringCWModSettings& settings,
bool force
);
) const;

private slots:
void handleInputMessages();
void networkManagerFinished(QNetworkReply *reply);
void networkManagerFinished(QNetworkReply *reply) const;
};

#endif // INCLUDE_BEAMSTEERINGCWSOURCE_H
Loading

0 comments on commit 5d0fa7f

Please sign in to comment.