Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Tools/DataSampleReceiver/main.cpp
T
Berrux Kana 3f7beb3c7e Qt6 migration: build fixes for Groups 10/11 + missing plugin modules
Continue the Qt5->Qt6 migration so the LTS Projects (Group 10) and LTS
Application (Group 11) compile, link, and ctest runs.

Qt5->Qt6 API migration (resolves removed/deprecated Qt6 APIs) across Lts
Tools and Apps, e.g. QAction->QActionGroup, QAbstractSocket::errorOccurred,
Qt::SkipEmptyParts, QRandomGenerator, QInputDevice::DeviceType,
QRegularExpression, QLatin1Literal->QStringLiteral, and the SampleModel
m_description->description rename.

CMake build fixes:
- CMakeLists.txt: add Lts/Common to CMAKE_AUTOMOC_INCLUDE_DIRECTORIES so moc
  resolves Q_INTERFACES(ProjectPlugin::Plugin) for the migrated Projects.
- cmake/NGLMacros.cmake: NGL_COMPILE_RESOURCES - replace return() (which aborts
  the calling CMakeLists.txt) with an if/else/endif.
- OpApp/THP: guard the ArcGISQt5Hack link with $<IF:$<TARGET_EXISTS:...>> (the
  target is absent when the SituationMap viewer is stubbed); matches
  CentralEffectSimulation.
- LtsSession: prefer the in-tree svcCoreClient target over a FIND_LIBRARY in
  /usr/local/lib.
- CnrProxyTester/DotMatrixDisplay: set AUTOUIC_SEARCH_PATHS for the ui/ subdir.
- TopicDiscover: link NGLLogger.

Export-header visibility stubs (expand the empty *_EXPORT macro to
__attribute__((visibility("default"))); the build sets -fvisibility=hidden and
these stubs shadow the CMake-generated header):
- include/LtsProjectionWorkstation/ltsprojectionworkstation_export.h (fixes
  undefined reference to LtsProjectionWorkstation::getInstance /
  setProjectionOperatorPreset)
- include/LtsSession/ltssession_export.h, include/LtsUtilsGuiDds/ltsutilsguidds_export.h (same pattern)

New plugin modules (copied from legacy) so LtsAppDescriptorChecker finds the
gui:3 IIDs referenced by the Projects' apps.json:
- TakeHomePackageManager/OldTHP              gui:3:tpm.man, gui:3:tpm.usb
- PresentationManagement/.../ScriptEditor   gui:3:pre.script.edit
- Timeline/Gui/EventTimelineClassic         gui:3:tln.view

new_docker_build.sh: correct group targets to the actual CMake target names,
guard LtsReportDisplay on BUILD_CODIFICATION, and skip modules unavailable in
the prebuilt image (AsmWorkstationCertifier/botan2, TrajectoryWidget,
VideoImport, thp_viewer/VLC).
2026-10-05 10:49:34 +02:00

144 lines
4.4 KiB
C++
Executable File

/**
* @RDE_HEADER@
* main (TopicDataGenerator)
* $Id$
* $HeadURL$
* $Author$
*/
#include <nglapplication/nglcoreapplication.h>
#include <NGLLogger/INGLLogger.h>
#include "initialisation.h"
#include <DDS/Generic/generic_base.h>
#include <DDS/Generic/topic_type_plugin.h>
#include <LtsPluginManager/lts_plugin_loader.h>
#include <LtsCommandLineParser/LtsCommandLineParser.h>
#include <QSet>
// static
static QVector<DDSGeneric::TopicDescription> getAvailableTopicTypes() // get topicTypes per plugin mechanism
{
QVector<DDSGeneric::TopicDescription> topicTypeDescs;
LtsPluginManager::LtsPluginLoader::getInstance()->loadPlugins(LtsPluginManager::PluginType::TOPIC_TYPE, [&](const LtsPluginManager::PluginInstance &pi)
{
DDSGeneric::TopicTypePlugin *typePlugin = qobject_cast<DDSGeneric::TopicTypePlugin*>(pi.plugin);
if (!typePlugin)
return false;
QMap<std::string,DDSGeneric::TopicDescription> topics = typePlugin->getDataTopics();
// Qt6: QMap::unite removed; insert() keeps the same "existing keys win" semantics
topics.insert(typePlugin->getFunctionTopics());
QMap<std::string, DDSGeneric::TopicDescription>::iterator it = topics.begin();
for( ; it != topics.end(); ++it)
{
topicTypeDescs.append(it.value());
}
return false; // we don't need the plugins anymore -> unload
});
return topicTypeDescs;
}
class CmdLineParser : public LtsCommandLineParser::LtsCommandLineParser
{
public:
CmdLineParser()
: LtsCommandLineParser()
{
addOption( { QStringList() << QLatin1String("s") << QLatin1String("maxSamples"),
QLatin1String("Default: 0 (infinite loop)"),
QLatin1String("Max Samples"),
QLatin1String("0") } );
addOption( { QStringList() << QLatin1String("t") << QLatin1String("doType"),
QLatin1String("Default: all, can be a list of doTypes, i.e. 1,2,5 (more Infos on doType, use -h)"),
QLatin1String("doType"),
QLatin1String("0") } );
}
int maxSamples() const { return isSet(QLatin1String("s")) ? value(QLatin1String("s")).toInt() : -1; }
QVector<DDSGeneric::TopicDescription> getDoTypes(NGL::INGLLogger &logger) const
{
const QVector<DDSGeneric::TopicDescription> availDataTopics = getAvailableDoTypes();
if (!isSet(QLatin1String("t")))
return availDataTopics;
// Convert list of DoTypes, separated by comma (given by user)
// Qt6: QStringRef/QString::splitRef removed; QStringView::split provides the same tokenization
const QString doTypeStr = value(QLatin1String("t"));
const QList<QStringView> strList = QStringView{doTypeStr}.split(QLatin1Char(','), Qt::SkipEmptyParts);
if (strList.isEmpty())
return availDataTopics;
QVector<DDSGeneric::TopicDescription> vDt;
vDt.reserve(strList.size());
for (const QStringView doTypeView : strList)
{
bool ok = false;
const int doTypeInt = doTypeView.toInt(&ok);
INFO_LOG(logger) << "doType: " << doTypeInt;
if (ok && doTypeInt >= 0 && doTypeInt < availDataTopics.size())
vDt.append(availDataTopics.at(doTypeInt));
else
WARNING_LOG(logger) << doTypeView.toString() << " is not a valid DoType, skipping.. ";
}
return vDt;
}
QVector<DDSGeneric::TopicDescription> getAvailableDoTypes() const
{
return getAvailableTopicTypes();
}
bool init()
{
LtsCommandLineParser::init(false);
if (isSet(QLatin1String("h")))
{
QVector<DDSGeneric::TopicDescription> doTypes = getAvailableDoTypes();
auto it = doTypes.begin();
for(int i=0 ; it != doTypes.end(); ++it, ++i)
fprintf(stdout, "\ndoType(%d): %s ", i, (*it).name.c_str());
fprintf(stdout, "\n\n");
}
return true;
}
};
int main ( int argc, char**argv )
{
NGLCoreApplication app ( argc, argv );
app.createLogger("DataSampleGenerator.main", "log4cxx_tdsr.props");
CmdLineParser options;
if (!options.init())
return -1;
QVector<DDSGeneric::TopicDescription> doTypes = options.getDoTypes(app.baseLogger());
INFO_LOG(app.baseLogger()) << "size vDoTypes: " << doTypes.size();
DataSampleReceiver::Initialisation* initDtcr = new DataSampleReceiver::Initialisation(options.domainId(), options.exerciseId(), doTypes);
if (!initDtcr->init())
return -2;
STARTUP_LOG(app.baseLogger());
app.exec();
delete initDtcr;
SHUTDOWN_LOG(app.baseLogger());
return 0;
}