- training_area_telegrams.cpp: Fixed QJsonObject initializer syntax (Qt6 requires {{}} not ({}))
- training_area_telegrams.cpp: Fixed fromJson() methods to access m_* members directly
- training_area_telegrams.cpp: Fixed brace mismatches in multiple toJson() methods
- training_area_telegrams.h: Changed Header struct to public members for consistency
- tx_mixin.cpp: Fixed getEquipmentNumber() template for direct member access
- lts_coordinate.cpp: Added missing #include <iomanip>
- MIGRATION_STATUS.md: Added migration progress tracking document
C++17 constraint enforced due to RTI Connext DDS 7.7.0 incompatibility with C++20+
Build status: BUILD_RTI=OFF successful (0 errors, warnings only)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
120 lines
3.0 KiB
C++
120 lines
3.0 KiB
C++
|
|
|
|
#pragma once
|
|
|
|
#ifdef REQUEST_HELPER_WITH_GUI
|
|
#include "ltsutilsdds_export.h"
|
|
#define LTSUTILSGUIDDS_INTERNAL_EXPORT LTSUTILSGUIDDS_EXPORT
|
|
#else
|
|
#include "ltsutilsdds_export.h"
|
|
#define LTSUTILSGUIDDS_INTERNAL_EXPORT LTSUTILSDDS_EXPORT
|
|
#endif
|
|
|
|
#include <Core/core_types.h>
|
|
#include <QtCore/QObject>
|
|
#include <QtCore/QPair>
|
|
#include <QtCore/QVector>
|
|
#include <functional>
|
|
#include <optional>
|
|
|
|
// BUILD_RTI wird immer definiert sein (ON oder OFF)
|
|
// Type alias für FunctionReply - immer Core::FunctionReply verwenden
|
|
// Bei BUILD_RTI=ON wird in der .cpp auf dds::core::Reference gecastet
|
|
using FunctionReplyType = Core::FunctionReply;
|
|
|
|
namespace LtsUtils
|
|
{
|
|
|
|
class LTSUTILSGUIDDS_INTERNAL_EXPORT RequestHelper : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
static bool s_debug;
|
|
|
|
explicit RequestHelper(
|
|
QObject* parent = nullptr, bool quiet = false,
|
|
|
|
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 FunctionReplyType& baseReply)>& baseReplyHandler = nullptr);
|
|
bool startRequests();
|
|
|
|
bool
|
|
startSingleRequest(const std::function<int64_t(void)>& requestFunction,
|
|
const std::function<void(const FunctionReplyType& baseReply)>& baseReplyHandler = nullptr);
|
|
|
|
void startSingleBackgroundRequest(
|
|
const std::function<int64_t()>& requestFunction,
|
|
const std::function<void(const FunctionReplyType& baseReply)>& baseReplyHandler = nullptr);
|
|
|
|
void startBackgroundRequests();
|
|
|
|
bool requestReply(const FunctionReplyType& baseReply);
|
|
bool requestReply(const Core::FunctionReplyObject& replyObject);
|
|
|
|
bool hasRequests() const
|
|
{
|
|
return !m_requestFunctions.isEmpty();
|
|
}
|
|
|
|
int getRepliedId() const
|
|
{
|
|
return m_repliedId;
|
|
}
|
|
|
|
QString getErrorString() const
|
|
{
|
|
return m_errorString;
|
|
}
|
|
|
|
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 FunctionReplyType&)>>;
|
|
|
|
QVector<RequestFunctionContainer> m_requestFunctions;
|
|
bool m_failed;
|
|
int m_repliedId;
|
|
std::function<void(const FunctionReplyType&)> 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 FunctionReplyType* baseReply);
|
|
|
|
signals:
|
|
void signalNextRequest();
|
|
void signalQuitLoop();
|
|
void signalSuccess();
|
|
void signalFailed();
|
|
|
|
private slots:
|
|
void slotNextRequest();
|
|
};
|
|
|
|
} // namespace LtsUtils
|