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

218 lines
5.8 KiB
C++

/**
* @RDE_HEADER@
* $Id$
* $HeadURL$
* $Author$
*/
#include "symbol_table.h"
#include "symbol_reader.h"
#include <QtCore/QDir>
#include <QtCore/QDirIterator>
#include <QtCore/QFile>
#include <NGLLogger/NGLLoggerBootstrap.h>
namespace SymbologyXML
{
SymbolTable::SymbolTable(const char *loggerName)
: logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger(loggerName))
{
DEBUG_LOG(logger) << LOGFUNCTION ;
DEBUG_LOG(logger) << "END " << LOGFUNCTION ;
} // SymbolTable::SymbolTable()
SymbolTable::~SymbolTable()
{
DEBUG_LOG(logger) << LOGFUNCTION ;
clear();
DEBUG_LOG(logger) << "END " << LOGFUNCTION ;
} // SymbolTable::SymbolTable()
bool SymbolTable::loadSymbolFromFile(const QString &filename, bool replace)
{
QFile file(filename);
SymbolReader sr;
Symbol* s = new Symbol();
if ( !sr.read(&file, *s) ) {
ERROR_LOG(logger) << LOGFUNCTION << ": Failed to read xml-symbol '"
<< filename << "'" ;
return false;
}
DEBUG_LOG(logger) << LOGFUNCTION
<< ": id '" << s->id() << "'"
<< " '0x" << std::hex << s->id() << "'"
<< " cP="<< s->getPrimitives().count()
<< " file '" << filename << "'";
if (replace)
m_map.insert(s->id(), s);
else
m_map.insertMulti(s->id(), s);
return true;
} // bool SymbolTable::loadSymbolFromFile(const QString &filename, bool replace)
bool SymbolTable::setDirectory(const QString &directory, const QStringList &nameFilters) {
DEBUG_LOG(logger) << LOGFUNCTION
<< " dir='" << directory << "'";
if (directory.isEmpty())
return true;
QDir dir(directory);
bool result = dir.exists();
if ( !result ) {
ERROR_LOG(logger) << LOGFUNCTION << ": Failed to read dir '"
<< dir.absolutePath().toLatin1().data() << "'"
;
} else {
clear(); // alte Caches aufräumen
m_directory = directory + QLatin1Char('/');
if ( nameFilters.isEmpty() ) {
// No filters, assume that all files should be read
QDirIterator dirIt(directory, QDir::Files|QDir::Readable|QDir::NoDotAndDotDot);
while(dirIt.hasNext()) {
bool bRet = loadSymbolFromFile(dirIt.next());
if( !bRet ) {
result = false;
}
}
} else {
QDirIterator dirIt(directory, nameFilters, QDir::Files|QDir::Readable|QDir::NoDotAndDotDot);
while(dirIt.hasNext()) {
bool bRet = loadSymbolFromFile(dirIt.next());
if( !bRet ) {
result = false;
}
}
}
}
DEBUG_LOG(logger) << "END " << LOGFUNCTION
<< " dir='" << directory << "'"
<< " count=" << this->size();
return result;
} // bool SymbolTable::setDirectory(const QString &directory, const QStringList & nameFilters = QStringList())
bool SymbolTable::updateSymbol(int id, bool replace) {
DEBUG_LOG(logger) << LOGFUNCTION ;
bool bRet = false;
// Der Dateiname muss "symbol_%04d.xml" sein!
QString filename(QString::asprintf("symbol_%04d.xml", id));
bRet = loadSymbolFromFile( m_directory + filename, replace);
DEBUG_LOG(logger) << "END " << LOGFUNCTION ;
return bRet;
} // bool SymbolTable::updateSymbol(int id, bool replace)
Symbol* SymbolTable::value(const int key, Symbol *defaultValue) const
{
DEBUG_LOG(logger) << LOGFUNCTION ;
const QList<Symbol*> &allValues = m_map.values(key);
for (Symbol *symbol : allValues)
{
if (!symbol)
continue;
bool match = symbol->getAffil() == SymbolTypes::AFFIL_UNDEFINED;
match &= symbol->getDimen() == SymbolTypes::DIMEN_UNDEFINED;
match &= symbol->transformed() == false;
if (match)
{
DEBUG_LOG(logger) << "END " << LOGFUNCTION ;
return symbol;
}
}
DEBUG_LOG(logger) << "END " << LOGFUNCTION ;
return m_map.value(key, defaultValue);
} // Symbol SymbolTable::value(const int &key, const Symbol *defaultValue) const
QList<Symbol*> SymbolTable::values(int key) const
{
return m_map.values(key);
} // QList<Symbol*> values(int key) const
Symbol* SymbolTable::operator[](const int &key)
{
DEBUG_LOG(logger) << LOGFUNCTION ;
const QList<Symbol*> &allValues = m_map.values(key);
for (Symbol *symbol : allValues)
{
if (!symbol)
continue;
bool match = symbol->getAffil() == SymbolTypes::AFFIL_UNDEFINED;
match &= symbol->getDimen() == SymbolTypes::DIMEN_UNDEFINED;
match &= symbol->transformed() == false;
if (match)
{
DEBUG_LOG(logger) << "END " << LOGFUNCTION ;
return symbol;
}
}
DEBUG_LOG(logger) << "END " << LOGFUNCTION ;
return m_map[key];
} // Symbol* SymbolTable::operator[](const int &key)
const Symbol* SymbolTable::operator[](const int &key) const
{
DEBUG_LOG(logger) << LOGFUNCTION ;
const QList<Symbol*> &allValues = m_map.values(key);
for (const Symbol *symbol : allValues)
{
if (!symbol)
continue;
bool match = symbol->getAffil() == SymbolTypes::AFFIL_UNDEFINED;
match &= symbol->getDimen() == SymbolTypes::DIMEN_UNDEFINED;
match &= symbol->transformed() == false;
if (match)
{
DEBUG_LOG(logger) << "END " << LOGFUNCTION ;
return symbol;
}
}
DEBUG_LOG(logger) << "END " << LOGFUNCTION ;
return m_map[key];
} // const Symbol* SymbolTable::operator[](const int &key) const
void SymbolTable::rotateAllSymbolPrimitives()
{
DEBUG_LOG(logger) << LOGFUNCTION
<< " m_map.count = " <<m_map.count();
for (Symbol *s : qAsConst(m_map))
s->rotatePrimitives();
DEBUG_LOG(logger) << "END " << LOGFUNCTION ;
} // void SymbolTable::rotateAllSymbolPrimitives()
bool SymbolTable::contains(int key) const
{
return m_map.contains(key);
} // void SymbolTable::contains(int key)
int SymbolTable::size() const
{
return m_map.size();
} // void SymbolTable::size()
void SymbolTable::clear()
{
qDeleteAll(m_map);
m_map.clear();
} // void SymbolTable::clear()
} // namespace SymbologyXML