Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Common/LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h
T
torstenandCopilot 7173785915 Qt6 Migration: Complete migration with DDS/RTI support and build validation
Major Changes:
- Merged latest Qt5 devel content from dlbo (292 files changed, 7 new dirs)
- Consolidated forward-declarations and include folders
- Removed unneeded modules per Niklas' repo check list

Build System Fixes:
- Fixed CMake VERSION_GREATER syntax in ParticipantManagement/CMakeLists.txt
- Added VLC packages (libvlc-dev, vlc-plugin-base) to docker_build.sh
- Added PostgreSQL dev packages (libpq-dev, postgresql-server-dev-all) to Dockerfile
- Fixed locale warnings (ANSI_X3.4-1968 → C.UTF-8)
- Fixed ArcGIS SDK path warnings when BUILD_ARCGIS=OFF

Code Generation Fixes:
- Fixed IDL enum collisions (PortType→CorePortType/DdsutPortType, PdmEventType)
- Fixed Grantlee template svc_translation.cpp.grantlee:
  - Changed {{ idl_enum.name }}_def:: to {{ idl_enum.name }}::
  - Fixed .underlying() calls for C++11 scoped enums (enum class)
- Removed generated files from repo (moc_*, *_dtc.h, *_ftc.h)

Validation:
- BUILD_RTI=ON: SUCCESS
- BUILD_RTI=OFF: SUCCESS
- C++17 standard maintained for RTI 7.7 compatibility
- Ubuntu 26.04 Docker environment verified

Remaining Warnings (expected):
- BgViewer, KDChart, KDReports, Poppler-Qt6 not found (optional features)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-09-15 18:20:26 +00:00

141 lines
4.7 KiB
C++

/**
* Helper class for simple function topic request handling
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#ifdef REQUEST_HELPER_WITH_GUI
#include <LtsUtilsGuiDds/ltsutilsguidds_export.h>
#define LTSUTILSGUIDDS_INTERNAL_EXPORT LTSUTILSGUIDDS_EXPORT
#else
#include <LtsUtilsGuiDds/ltsutilsdds_export.h>
#define LTSUTILSGUIDDS_INTERNAL_EXPORT LTSUTILSDDS_EXPORT
#endif
#include <DDS/Core/function_reply_object.h>
#include <DDS/Core/core.hpp> // Core::FunctionReply (base reply)
#include <QObject>
#include <QVector>
#include <QPair>
#include <functional>
namespace LtsUtils
{
template<typename T>
dds::core::optional<T> toOptional(T inVal)
{
return inVal != T() ? dds::core::optional<T>(inVal) : dds::core::optional<T>();
}
template<typename T>
dds::core::optional<T> optional()
{
return dds::core::optional<T>();
}
class LTSUTILSGUIDDS_INTERNAL_EXPORT RequestHelper : public QObject // TODO: DOC !!!
{
Q_OBJECT
public:
static bool s_debug;
explicit RequestHelper(QObject *parent = nullptr, bool quiet = false,
// for non-blocking
const std::function<void (void)> &success = [](){},
const std::function<void (void)> &failure = [](){});
~RequestHelper() = default;
bool quiet() const { return m_quiet; }
void setQuiet(bool quiet) { m_quiet = quiet; }
void addRequest(const std::function<int64_t()> &requestFunction,
const std::function<void(const Core::FunctionReply &baseReply)> &baseReplyHandler = nullptr);
bool startRequests(); // blocks!
// do not throw a message if this method fails, as this method does this already // blocks!
bool startSingleRequest(const std::function<int64_t(void)> &requestFunction,
const std::function<void(const Core::FunctionReply &baseReply)> &baseReplyHandler = nullptr // for replies that return a custom FunctionReply, which has to be handled >>after successful execution<<
);
// non-blocking !
/**
* @brief startSingleBackgroundRequest << you cannot reuse this request helper after using background requests! Only use if your REALLY need it.
* @param requestFunction
* @param baseReplyHandler
*/
void startSingleBackgroundRequest(const std::function<int64_t()> &requestFunction,
const std::function<void(const Core::FunctionReply &baseReply)> &baseReplyHandler = nullptr);
/**
* @brief startBackgroundRequests << you cannot reuse this request helper after using background requests! Only use if your REALLY need it.
*/
void startBackgroundRequests(); // non-blocking !
bool requestReply(const Core::FunctionReply &baseReply); // if you have a custom FunctionReply, pass the base ptr
bool requestReply(const Core::FunctionReplyObject &replyObject);
/**
* @brief hasRequests are requests is added?
* @return True if a request is added, otherwise false
*/
bool hasRequests() const { return !m_requestFunctions.isEmpty(); }
/**
* @brief getRepliedId returns the Return-ID of the ReplyObject you gave to the method 'requestReply' - which is mostly the ID for the new Table Entry (Unique ID)
* @return the Return-ID or -1 on error (not set)
*/
int getRepliedId() const { return m_repliedId; }
/**
* @brief getErrorString returns the error string set by an ftc reply
* @return
*/
QString getErrorString() const { return m_errorString; }
/**
* @brief setCustomWaitMessage changes the default 'Waiting for server reply ...' message with a custom one (NOTE: " ..." is automagically added to the custom text)
* After a request was started, the custom wait message is immediately reset, so that the next call to start a request, shows the default message again
* @param customWaitMessage the wait message to replace the default message with (note that " ..." is added to the text)
*/
void setCustomWaitMessage(const QString &customWaitMessage);
bool failed() const { return m_failed; }
void failure();
private:
using RequestFunctionContainer = QPair<std::function<int64_t()>, std::function<void(const Core::FunctionReply &)>>;
QVector<RequestFunctionContainer> m_requestFunctions;
bool m_failed;
int m_repliedId;
std::function<void(const Core::FunctionReply &)> m_singleRequestCustomFunctionReply;
bool m_quiet;
bool m_blockingCall;
std::function<void (void)> m_successFn;
std::function<void (void)> m_failureFn;
QString m_errorString;
QString m_customWaitMessage;
void done();
bool _requestReply(const Core::FunctionReplyObject &fro, const Core::FunctionReply *baseReply);
signals:
void signalNextRequest();
void signalQuitLoop();
void signalSuccess();
void signalFailed();
private slots:
void slotNextRequest();
};
} // namespace LtsUtils