Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Common/LtsSession/lts_session_manager.cpp
T
torstenandCopilot b774f4035c Qt6 Migration: DDS-Stubs, Logger-Fixes, Export-Header Korrekturen
- NGL_ADD_LIBRARY2: 87 CMakeLists.txt konvertiert für Export-Header Generierung
- 44 Export-Header Include-Pfade korrigiert (_export.h)
- 81 DDS-Stub-Header generiert (*_dtc.h, *_fts.h, *_dts.h, *_ftc.h)
- INGLLogger: Duplikat gelöscht, m_logger Member entfernt, variadische Makros
- Q_FUNC_INFO Redefinition behoben (Qt6 definiert bereits)
- FATAL_LOG Makro hinzugefügt
- InfrastructureManagement DDS-Stubs (ism.hpp, ism_enums.hpp, ism_ftc.h)
- FilterManagement DDS-Stubs (flt_ftc.h, flt_dts.h)
- AreaEffectSimulation DDS-Stubs (aes.hpp, aes_enums.hpp)
- SymbolAppearance Klasse vollständig definiert mit content() Methode
- BuildingComponentFilter Klasse definiert mit Copy-Konstruktor
- Ftc Factory: nullptr Return (abstract class)
- AesFilter Klasse in aes.hpp hinzugefügt
- Dtc Klasse in ppm.hpp mit participantChanged Signal
- AesType Enum: alle 15 At* Werte definiert
- AesEffectState_def: EsReceived hinzugefügt
- DataModification Enum: eAdded/eModified/eRemoved
- function_reply_object.h → core_types.h Include-Pfad (72 Dateien)
- Enum-Class-Streaming Template-Operator in INGLLogger.h
- ism_mounting_point.h: QImage → QtGui/QImage, QGuiApplication/QScreen
- ism_data_plugin_interface.h: QSet Include, Include-Reihenfolge
- QRegExp → QRegularExpression in tpm_js_parser.cpp
- .underlying() Aufrufe zu direktem Enum-Vergleich korrigiert
- Include-Pfade: aes.hpp in symbol_appearance_settings_impl.h und aes_display_filter_impl.h

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-08-19 06:06:24 +02:00

241 lines
5.9 KiB
C++
Executable File

#include "lts_session_manager.h"
#include "lts_session.h"
#include <NGLLogger/NGLLoggerBootstrap.h>
#include <LtsPluginManager/lts_plugin_loader.h>
#include <LtsPluginManager/lts_plugin_manager.h>
#include <LtsWidgets/lts_wait_dialog.h>
#include <LtsSession/lts_session_data.h>
#include <PluginInterfaces/data_plugin_interface.h>
#include <PluginInterfaces/gui_plugin_interface.h>
#include <DDS/DDSConnector/dds_connector.h>
#include <QDebug>
namespace LtsSession
{
LtsSessionManager::LtsSessionManager()
: QObject()
, m_appId(LtsAppDescriptor::App::Login)
, m_headless(false)
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("LtsSession.Manager"))
{}
LtsSessionManager::~LtsSessionManager()
{
for (auto i = m_sessionMap.begin(); i != m_sessionMap.end(); ++i)
{
LtsSession *session = i.value();
session->setInactive();
session->deleteLater();
}
}
bool LtsSessionManager::init(const DdsConnectionParams &connParams,
const QVector<LtsPluginManager::AppPluginInstance> &dataPluginList,
const QVector<LtsPluginManager::AppPluginInstance> &guiPluginList,
LtsAppDescriptor::App appId,
const QString &workspaceId,
bool headless,
bool hidden)
{
m_dataPluginList = dataPluginList;
m_guiPluginList = guiPluginList;
m_appId = appId;
m_headless = headless;
bool bHasBaseLayout = connParams.exerciseId > 0;
LtsSession *session = createSession(connParams, bHasBaseLayout, true, hidden);
session->setWorkspaceId(workspaceId);
return session;
}
QVector<LtsSession *> LtsSessionManager::sessions()
{
return m_sessionMap.values().toVector();
}
void LtsSessionManager::softQuit()
{
for (auto i = m_sessionMap.begin(); i != m_sessionMap.end(); ++i)
{
LtsSession *session = *i;
session->aboutToClose();
session->setInactive();
session->deleteLater();
}
m_sessionMap.clear();
emit hideAllOtherBLWs(nullptr);
QMetaObject::invokeMethod(this, &LtsSessionManager::signalQuit, Qt::QueuedConnection);
}
LtsSession *LtsSessionManager::createSession(const DdsConnectionParams &connParams,
bool hasBaseLayout,
bool payloads,
bool hidden)
{
LtsSession *session = getSession(connParams.partitionType, connParams.partitionId);
if (session != nullptr)
{
WARNING_LOG() << "Tried to create a Session that already exists";
return nullptr;
}
session = new LtsSession(this);
connect(session, &LtsSession::signalQuit,
this, &LtsSessionManager::signalQuit);
connect(session, &LtsSession::signalClose,
this, &LtsSessionManager::slotCloseSession, Qt::QueuedConnection);
connect(session, &LtsSession::signalLogout,
this, &LtsSessionManager::signalLogout);
connect(session, &LtsSession::signalInitializationAborted,
this, &LtsSessionManager::signalInitializationAborted);
connect(session, &LtsSession::hideAllOtherBLWs,
this, &LtsSessionManager::hideAllOtherBLWs);
connect(session, &LtsSession::taskSwitch,
this, &LtsSessionManager::taskSwitch);
#ifdef LTS_DEBUG
connect(session, &LtsSession::signalStillAlive,
this, [this]()
{
LtsSession *session = qobject_cast<LtsSession *>(sender());
for (auto i = m_sessionMap.constBegin(); i != m_sessionMap.constEnd(); ++i)
{
if (i.value() == session)
return;
}
WARNING_LOG() << "Previously deleted Session " << session->partitionId() << "/"
<< session->partitionType() << " is still alive!";
});
#endif
if (hasBaseLayout)
session->setBaseLayoutVisible();
if (payloads)
session->setPayloadsEnabled();
m_sessionMap[SessionKey(connParams.partitionType, connParams.partitionId)] = session;
LtsSession *globSession = getSession(IDL::PartitionType::Global, 0);
if (globSession && globSession->ddsConnector() && globSession->domainId() == connParams.domainId)
{
dds::domain::DomainParticipant dp = globSession->ddsConnector()->getDomainParticipant();
if (!session->init(dp, connParams, m_dataPluginList, m_guiPluginList))
{
session->deleteLater();
return nullptr;
}
}
else
{
if (!session->init(connParams, m_dataPluginList, m_guiPluginList, hidden))
{
session->deleteLater();
return nullptr;
}
}
if (session->isInitializationDone())
QMetaObject::invokeMethod(this, &LtsSessionManager::signalInitializationFinished,
Qt::QueuedConnection);
else
connect(session, &LtsSession::signalDoneInitializingSession,
this, &LtsSessionManager::signalInitializationFinished,
Qt::QueuedConnection);
return session;
}
void LtsSessionManager::slotCloseSession()
{
LtsSession *session = qobject_cast<LtsSession *>(QObject::sender());
if (!session)
{
FATAL_LOG(m_logger) << "LtsSessionManager: slot called without object - so it cannot be deleted from the session list!";
return;
}
bool found = false;
for (auto i = m_sessionMap.begin(); i != m_sessionMap.end(); ++i)
{
if (i.value() == session)
{
const auto key = i.key();
session->aboutToClose();
session->setInactive();
session->deleteLater();
m_sessionMap.remove(key);
found = true;
break;
}
}
if (!found)
FATAL_LOG(m_logger) << "LtsSessionManager: Cannot find Session in map!";
emit hideAllOtherBLWs(nullptr);
if (m_sessionMap.isEmpty())
emit signalQuit();
}
LtsSession *LtsSessionManager::getSession(IDL::PartitionType partitionType, int partitionId)
{
auto it = m_sessionMap.find(SessionKey(partitionType, partitionId));
if (it != m_sessionMap.end())
return it.value();
return nullptr;
}
}