Files
qt-migration-legatus/qt5-before/dlbo/Lts/Services/AudioVideoManagement/import_handler.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

139 lines
3.8 KiB
C++

/**
* @RDE_HEADER@
* ImportHandler
* $Id$
* $HeadURL$
* $Author$
* Created by Astrid Müller, Christian Fröbel, SLSE, 2017-12-12
*/
#include "import_handler.h"
#include "exercise_handler.h"
#include <AssetManagement/asm.hpp>
#include <AssetManagement/asm_enums.hpp>
#include <AssetManagement/asm_dtc.h>
#include <ngldb/dbtransaction.h>
#include <QtGlobal>
using namespace AudioVideoManagement;
namespace
{
Database::AvmDeviceConfig toDb(const ExerciseContext &context, const AssetManagement::Asset &asset)
{
Database::AvmDeviceConfig deviceConfig;
deviceConfig.context = context.toString();
deviceConfig.type = QStringLiteral("IMPORT_VIDEO_CHANNEL");
deviceConfig.name = QStringLiteral("ECRS");
deviceConfig.controller = QString::fromStdString(asset.name());
deviceConfig.definition = QStringLiteral("recording=ECRS@EXCAVS01");
return deviceConfig;
}
} // anonymous namespace
namespace AudioVideoManagement
{
ImportHandler *ImportHandler::create(ExerciseHandler *exerciseHandler, DatabaseInterface *db, AssetManagement::Interface::Dtc *asmDtc)
{
Q_ASSERT(exerciseHandler);
ImportHandler *newHandler = new ImportHandler(exerciseHandler->context(), db, asmDtc);
connect(exerciseHandler, &ExerciseHandler::contextActivated, newHandler, &ImportHandler::onContextActivated);
connect(exerciseHandler, &ExerciseHandler::contextDeactivated, newHandler, &ImportHandler::onContextDeactivated);
connect(asmDtc, &AssetManagement::Interface::Dtc::assetChanged, newHandler, &ImportHandler::onAssetChanged);
return newHandler;
}
ImportHandler::ImportHandler(const ExerciseContext &context, DatabaseInterface *db, AssetManagement::Interface::Dtc *asmDtc)
: m_context(context)
, m_db(db)
, m_asmDtc(asmDtc)
{
Q_ASSERT(db);
Q_ASSERT(asmDtc);
}
void ImportHandler::onContextActivated()
{
m_isActive = true;
DBTransaction transaction(m_db->database());
// This can possibly cause a race condition. It can happen that for an asset we just retrieved
// we immediatly get an onAssetChanged() notification with eAdded.
auto cb = [this] (const AssetManagement::Asset &asset) { onAssetChanged(asset, DataModification::eAdded); };
m_asmDtc->assets(cb);
transaction.commit();
}
void ImportHandler::onContextDeactivated()
{
DBTransaction transaction(m_db->database());
for (const auto &idAndDeviceConfig: m_deviceConfigs)
m_db->removeAvmDeviceConfig(idAndDeviceConfig.second.id);
m_deviceConfigs.clear();
transaction.commit();
m_isActive = false;
}
void ImportHandler::onAssetChanged(const AssetManagement::Asset &asset, DataModification modType)
{
if (!m_isActive)
return;
if (asset.assetTypeId() != AssetManagement::AssetType::Workstation)
return;
// Guard against a possible race condition, see comments in onContextActivated().
auto found = m_deviceConfigs.find(asset.id());
if (found != m_deviceConfigs.end())
return;
switch (modType)
{
case DataModification::eAdded:
addToDb(asset);
break;
case DataModification::eRemoved:
// This is not a regular use case.
// But it can happen when the services are stopped.
removeFromDb(asset);
break;
case DataModification::eModified:
// Assets are read-only.
Q_ASSERT(false);
}
}
void ImportHandler::addToDb(const AssetManagement::Asset &asset)
{
Database::AvmDeviceConfig newConfig = ::toDb(m_context, asset);
m_db->insert(newConfig);
auto insertResult = m_deviceConfigs.insert({asset.id(), newConfig});
Q_ASSERT(insertResult.second);
emit avDbReloadNeeded();
}
void ImportHandler::removeFromDb(const AssetManagement::Asset &asset)
{
auto found = m_deviceConfigs.find(asset.id());
Q_ASSERT(found != m_deviceConfigs.end());
m_db->removeAvmDeviceConfig(found->second.id);
m_deviceConfigs.erase(found);
emit avDbReloadNeeded();
}
} // namespace AudioVideoManagement