Files
qt-migration-legatus/qt5-before/dlbo/Lts/Viewer/SituationMap/Symbology/result_watcher.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

171 lines
4.3 KiB
C++

/**
* @RDE_HEADER@
* Class ResultWatcherBase, ResultWatcher
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
// Own
#include "advanced_symbology_export.h"
#include "symbol_dictionary_types.h"
#include <SymbologyImpl/advanced_symbology_logging.h>
// Qt
#include <QObject>
//----------------------------------------------------------------------------
namespace AdvancedSymbology
{
//----------------------------------------------------------------------------
// - ResultWatcherBase (containing the Q_OBJECT for signal/slot)
// - ResultWatcher (containing template)
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
// ResultWatcherBase (containing the Q_OBJECT for signal/slot)
//----------------------------------------------------------------------------
/**
* @brief The ResultWatcherBase class is a simple base class of ResultWatcher
* and contain the signal resultReady, since a template class can`t.
*/
class ADVANCED_SYMBOLOGY_EXPORT ResultWatcherBase : public QObject
{
Q_OBJECT
public:
///< Constructor
explicit ResultWatcherBase(QObject *parent = nullptr)
: QObject(parent)
{}
///< Destructor
~ResultWatcherBase() = default;
Q_SIGNALS:
/// Signal emits when result is ready
void resultReady();
protected Q_SLOTS:
void onResultReadyInternal()
{
// to avoid emitting signal twice:
if (! m_alreadyEmitted)
emit resultReady();
m_alreadyEmitted = true;
}
protected:
bool m_alreadyEmitted = false;
};
//----------------------------------------------------------------------------
// ResultWatcher (containing template)
//----------------------------------------------------------------------------
/**
* @brief The ResultWatcher class takes a result and will emit resultReady exactly one time.
*
* \section secResultWatcherExample Using the ResultWatcher
* Here is an example of using the ResultWatcher
*
* \code
* AdvancedSymbology::SymbolDictionary &dict = AdvancedSymbology::SymbolDictionary::dictionary(AdvancedSymbology::MIL2525D);
*
* AdvancedSymbology::SymbolResultWatcher symbolResultWatcher;
*
* // FIRST connect:
* connect(&symbolResultWatcher, &AdvancedSymbology::SymbolResultWatcher::resultReady, this, [](){
*
* QSharedPointer<AdvancedSymbology::SymbolResult> symResult = symbolResultWatcher.symbolResult();
* if (! symResult)
* return; // should NEVER happen! (Which object should have triggered the signal???)
*
* if (this->m_targetObject)
* {
* this->m_targetObject->setImage(symResult->symbolImage().image());
* }
* });
*
* // SECOND setResult (starting the asynchronous operation)
* symbolResultWatcher.setSymbolResult( dict.findSymbol("mySidc") );
* \endcode
*
* There is an convenience class: SymbolResultWatcherComboxBox
*
* @note
* Template classes can not contain signals why this is moved to the base class ResultWatcherBase.
*
*/
template <typename RESULT_TYPE>
class ResultWatcher : public ResultWatcherBase
{
public:
///< Constructor
explicit ResultWatcher(QObject *parent = nullptr)
: ResultWatcherBase(parent)
{}
///< Destructor
virtual ~ResultWatcher() = default;
bool resultIsValid() const
{
return ! m_result.isNull();
}
void cancel()
{
m_result.clear();
}
protected:
QSharedPointer<RESULT_TYPE> result() const
{
return m_result;
}
void setResult(const QSharedPointer<RESULT_TYPE> &result)
{
// 2017-11-13, N.Thoden :
// With rev 36928 the SymbolResult of two identical request (identical SymbolDataToRender)
// will shared ONE SymbolResult!
// This szenario happens while showing a snapshot.
// So we have to disconnect explicitly:
// make sure, that we won`t be called by the 'old' object:
// so disconnect:
if (m_result)
m_result->disconnect(this);
// : 2017-11-13, N.Thoden
m_result = result;
m_alreadyEmitted = false;
if (m_result)
{
// Handle race condition:
// 1. connect
connect(m_result.data(), &RESULT_TYPE::resultReadyInternal, this, &ResultWatcher::onResultReadyInternal);
// 2. maybe result was ready before?
if (m_result->isResultReady())
onResultReadyInternal();
}
}
QSharedPointer<RESULT_TYPE> m_result;
};
} // namespace AdvancedSymbology