Clean up stale comments and blank lines in FTC/FTS and nglapplication unit-test

Drop the Qt6-migration explanatory comments (rtiddsgen setter notes,
Log4Qt/BUILDING_NGLLOGGER notes, the INTERFACE-to-STATIC note, the
return_loan comment block) and the stray blank lines. No code changes:
this is the state the last full green run (build + 22/22 ctest +
coverage + DEB) was built from.
This commit is contained in:
berrux-dev committed 2026-11-21 09:25:55 +01:00
1 parent e8d7aa7bd6
commit b1662eddfa
10 files changed
+3 -104

No files matched your search

@@ -4,10 +4,7 @@
# $Author$
#
# ddsftc - Changed from INTERFACE to STATIC library to fix source path issues
# When INTERFACE libraries provide sources, CMake compiles them in the consuming
# target's directory context, causing path resolution issues with relative paths
ADD_LIBRARY(ddsftc STATIC
${CMAKE_CURRENT_SOURCE_DIR}/generic_ftc.h
${CMAKE_CURRENT_SOURCE_DIR}/generic_ftc.cpp
@@ -1,6 +1,4 @@
#include "abstract_requester.h"
Request2::Request2():QObject(){}
@@ -1,10 +1,8 @@
#pragma once
#include <ddsftccore_export.h>
#include <QtCore/QObject>
class DDSFTCCORE_EXPORT Request2 : public QObject
{
Q_OBJECT
@@ -9,7 +9,6 @@
#pragma once
#include <DDS/Core/core.hpp>
#include <future>
class Request2;
@@ -20,11 +20,9 @@
#include <QObject>
#include <QMetaMethod>
#include <QTimer>
#include <queue>
#include <future>
namespace FTC
{
template <class C>
@@ -114,7 +112,6 @@ public:
preInit();
}
~GenericFtcImpl()
{
Q_ASSERT(!m_dying);
@@ -154,8 +151,6 @@ public:
}
}
struct ClassicRequest
{
connext::WriteSample<RequestTopic> sample;
@@ -164,14 +159,12 @@ public:
int uniqueId = 0;
};
bool requestDataClassic(const RequestTopic &requestTopic,
const char *replySlot,
const char *errorSlot,
int &uniqueId) override
{
Q_ASSERT(!m_dying);
ClassicRequest request;
if (!checkSlots(request, replySlot, errorSlot))
return false;
@@ -180,19 +173,14 @@ public:
uniqueId = request.uniqueId;
createThread();
{
std::lock_guard<std::mutex> l(m_requestMutex);
m_classicRequests.push(request);
}
runThread();
return true;
}
template<typename ReplyTopic>
struct ModernRequest
{
@@ -201,14 +189,11 @@ public:
Request2 *requestWatcher;
};
std::future<ReplyTopic> requestDataModern(const RequestTopic &requestTopic, Request2 *requestWatcher) override
{
Q_ASSERT(!m_dying);
std::promise<ReplyTopic> promise;
std::future<ReplyTopic> future = promise.get_future();
connext::WriteSample<RequestTopic> sample;
sample.set_data(requestTopic);
@@ -220,7 +205,6 @@ public:
}
runThread();
return future;
}
@@ -231,36 +215,28 @@ private:
return QString::fromUtf8(TopicNameHelper::functionTopicName());
}
int partitionId() const override
{
return m_partitionId;
}
QString partitionType() const override
{
return QString::fromStdString(m_partitionType);
}
std::unique_ptr<connext::Requester<RequestTopic, ReplyTopic> > requester; // in-thread!
void cleanupThread() override // in-thread!
{
// called in-thread while thread is preparing to immediately shut down (after this call) and cleans everything that was created also in-thread
requester.reset();
}
void threadDone() override
{
// called after the thread is done and before any new threads may be created
// that's why there's no need to lock the mutex here
// NOTE: not called on ctor!
// NOTE: no need to lock as there is no thread anymore at this point
for (; !m_modernRequests.empty(); m_modernRequests.pop())
{
ModernRequest<ReplyTopic> &request = m_modernRequests.front();
@@ -278,7 +254,6 @@ private:
}
}
void work() override // in-thread!
{
try
@@ -291,8 +266,7 @@ private:
{
fprintf(stderr, "[!] GenericFtc::work: called while marked as no work available! run? %d (%s)\n", isRun(), threadName().toStdString().c_str());
}
setWorkAvailable(false); // NOTE: no need to lock as we're inside the thread and it is guaranteed that we don't hit the condition wait while writing to the variable
// lock
setWorkAvailable(false);
{
std::lock_guard<std::mutex> l(m_requestMutex);
@@ -371,14 +345,12 @@ private:
}
}
template <typename T, typename std::enable_if<HasStatusFunction<T>::value, int>::type = 0>
static inline bool isInProgress(const connext::Sample<T> &reply)
{
return (reply.data().replyState() == Core::FtReplyState::InProgress);
}
template <typename T, typename std::enable_if<!HasStatusFunction<T>::value, int>::type = 0>
static inline bool isInProgress(const connext::Sample<T> &)
{
@@ -500,10 +472,6 @@ private:
QTimer::singleShot(0, request.requestWatcher, &Request2::finished);
return;
/* No need to call replies.return_loan();
* the destructor takes care of doing it every time replies goes out of scope
*/
}
}
// -------------------------------------------------------------------------------------------------------------
@@ -557,7 +525,6 @@ private:
}
// -------------------------------------------------------------------------------------------------------------
// for classic requests:
QObject *m_objToInform;
int m_uniqueId { 0 };
@@ -53,18 +53,10 @@ void Threading::preInit() const
m_partitionId = partitionId();
m_partitionType = partitionType();
const QString base(QStringLiteral("F%1%2").arg(m_partitionType.left(1)).arg(m_partitionId));
const int baseLen = base.length();
const int maxLen = 16 - 1 - baseLen;
if (maxLen < 1)
{
Q_ASSERT(false);
@@ -96,8 +88,6 @@ void Threading::preInit() const
}
int wordsLeft = words.count();
if (wordsLeft < 1)
{
Q_ASSERT(false);
@@ -124,25 +114,16 @@ void Threading::preInit() const
}
const int maxWordLen = lenRest / wordsLeft;
if (words.isEmpty())
{
Q_ASSERT(false);
break;
}
name += words.takeFirst().left(maxWordLen);
wordsLeft--;
}
const int finalLeft = maxLen - name.size();
if (finalLeft < 0 || (finalLeft > 0 && functionTopicName().length() > maxLen))
{
@@ -157,48 +138,36 @@ void Threading::preInit() const
m_threadName = QStringLiteral("%1%2[%3]").arg(base, name).arg(QRandomGenerator::global()->bounded(0x100000000LL), 8, 16, QLatin1Char('0'));
}
const QString &Threading::threadName() const
{
if (m_threadName.isEmpty())
{
Q_ASSERT(false);
}
return m_threadName;
}
const char *Threading::posixThreadName() const
{
if (m_posixThreadName.empty())
{
m_posixThreadName = threadName().left(15).toStdString();
}
return m_posixThreadName.c_str();
}
void Threading::createThread()
{
if (!isRun())
{
if (m_thread.joinable())
{
m_condition.notify_all();
m_thread.join();
threadDone();
}
m_alreadyThreaded = 0;
setRun(true);
m_thread = std::thread(&Threading::run, this, threadName());
#ifdef Q_OS_LINUX
@@ -213,7 +182,6 @@ void Threading::createThread()
void Threading::runThread()
{
m_used = true;
Q_ASSERT(m_createThreadCalledBefore);
m_createThreadCalledBefore = false;
@@ -243,7 +211,6 @@ void Threading::runThread()
if (workAvailable || working)
{
m_threadLifetime->start();
return;
}
@@ -253,13 +220,10 @@ void Threading::runThread()
if (!run)
{
Q_ASSERT(false);
return;
}
{
std::lock_guard<std::mutex> l(m_conditionMutex);
setRun(false);
@@ -271,7 +235,6 @@ void Threading::runThread()
m_threadLifetime->start();
}
void Threading::run(const QString &threadName)
{
Q_ASSERT(m_alreadyThreaded == 0);
@@ -286,8 +249,6 @@ void Threading::run(const QString &threadName)
{
{
std::unique_lock<std::mutex> conditionLock(m_conditionMutex);
m_condition.wait(conditionLock, [this]{ return (isWorkAvailable() || !isRun()); });
}
@@ -37,26 +37,16 @@ public:
protected:
void preInit() const;
void createThread();
void runThread();
inline bool isRun() const { return (m_run != 0); }
inline void setRun(bool run) { m_run = (run ? 1 : 0); }
inline void setWorkAvailable(bool workAvailable) { m_workAvailable = (workAvailable ? 1 : 0); }
inline bool isWorkAvailable() const { return (m_workAvailable != 0); }
inline void setWorking(bool working) { m_isWorking = (working ? 1 : 0); }
inline bool isWorking() const { return (m_isWorking != 0); }
const QString &threadName() const;
inline const char *posixThreadName() const;
virtual void work() = 0;
virtual QString functionTopicName() const = 0;
virtual int partitionId() const = 0;
@@ -68,7 +58,6 @@ protected:
{
if (!isRun())
{
throw CancelationPointReached();
}
}
@@ -79,7 +68,6 @@ private:
inline bool isCleanupNeeded() const { return (m_cleanupNeeded != 0); }
inline void setCleanupNeeded(bool cleanupNeeded) { m_cleanupNeeded = (cleanupNeeded ? 1 : 0); }
void run(const QString &threadName);
std::unique_ptr<QTimer> m_threadLifetime;
QAtomicInt m_run { 0 };
@@ -13,9 +13,6 @@
#endif
#include <QtCore/QVector>
namespace FTS
{
@@ -63,12 +63,8 @@ private:
void sendReplyState(Core::FtReplyState replyState, const rti::core::SampleIdentity &requestSampleIdentity)
{
connext::WriteSample<ReplyTopic> reply;
// rtiddsgen -stl generates plain public data members, so the reply
// state is assigned directly instead of the old setter call.
reply.data().replyState = replyState;
// FtReplyState doesn't exist anymore with rtiddsgen 7.7 - the
// enum values are directly available in Core::FtReplyState.
bool bLastTelegram = ((replyState != Core::FtReplyState::InProgress) &&
(replyState != Core::FtReplyState::NotStarted));
m_replier->send_reply(reply, requestSampleIdentity, bLastTelegram);
@@ -7,12 +7,10 @@ if (NOT BUILD_TESTING)
endif()
# --- nglapplication: nglcoreapplication logger handler
# --- (Log4Qt-independent; works in the Log4Qt-less (stub) build)
if (TARGET nglcoreapplication)
ADD_EXECUTABLE(nglcoreapplication_unit_test nglcoreapplication_unit_test.cpp)
# NGLLogger.h (the AlreadyCreatedError type thrown by createNGLRootLogger)
# refuses to be included outside the NGLLogger library unless
# BUILDING_NGLLOGGER is defined (same pattern as NGLLogger/CMakeLists.txt)
TARGET_COMPILE_DEFINITIONS(nglcoreapplication_unit_test PRIVATE BUILDING_NGLLOGGER)
TARGET_LINK_LIBRARIES(nglcoreapplication_unit_test
nglcoreapplication