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

185 lines
6.0 KiB
C++

/**
* Handler ShootbackTargets (L400)
* $Id$
* $HeadURL$
* $Author$
* Created by N. Thoden, NLE, 06.04.2020
*/
#include "main_handler.h"
#include "handler_target_area_assignment.h"
#include "handler_shootback_target.h"
#include "object_shootback_target.h"
using namespace TargetManagement;
//--------------------------------------------------------------------------
HandlerShootbackTarget::HandlerShootbackTarget(MainHandler *mainHandler)
: QObject(mainHandler)
, ShootbackTargetModifyRequestHandler(mainHandler->dds()->ftsTgt())
, ShootbackTargetRemoveRequestHandler(mainHandler->dds()->ftsTgt())
, m_mainHandler(mainHandler)
, m_dtsTgt(m_mainHandler->dds()->dtsTgt())
, m_logger(getLogger("HandlerShootbackTarget"))
{
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
}
//--------------------------------------------------------------------------
HandlerShootbackTarget::~HandlerShootbackTarget()
{
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
}
//--------------------------------------------------------------------------
bool HandlerShootbackTarget::init()
{
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
// connect(m_dtcTab.get(), &TrainingAreaBase::Interface::Dtc::targetDataChanged,
// this, &HandlerShootbackTarget::onTargetDataChanged);
bool bRet = true;
// create objects
auto cb = [this, &bRet](const Database::TgtShootbackTarget & data)
{
DEBUG_LOG(m_logger) << "Reading from DB ShootbackTarget with id = " << data.id;
ObjectShootbackTarget *ifs(new ObjectShootbackTarget(m_mainHandler));
Core::FunctionReplyObject ret = ifs->createObject(ObjectShootbackTarget::toDdsData(data));
if (ret.error())
{
delete ifs;
ERROR_LOG(m_logger) << ret();
bRet = false;
return;
}
m_objectMap.insert(ifs->getId(), ifs);
};
if (!m_mainHandler->db()->select(cb) || !bRet)
{
ERROR_LOG(m_logger) << "Error reading data from database!";
return false;
}
DEBUG_LOG(m_logger) << "m_objectMap.size() = " << m_objectMap.size();
return true;
}
ObjectShootbackTarget *HandlerShootbackTarget::dataForTargetParticipantId(int targetParticipantId) const
{
for (ObjectShootbackTarget *item : qAsConst(m_objectMap))
{
if (!item)
continue;
if (item->getTargetParticipantId() == targetParticipantId)
return item;
} // for
return nullptr;
}
int HandlerShootbackTarget::targetDataIdForTargetParticipantId(int targetParticipantId) const
{
ObjectShootbackTarget *target = dataForTargetParticipantId(targetParticipantId);
if (!target)
return -1;
return target->getId();
}
//--------------------------------------------------------------------------
void HandlerShootbackTarget::onShootbackTargetModifyRequest(const rti::core::SampleIdentity &cookie,
const ShootbackTarget &request)
{
const auto ret = shootbackTargetModifyRequest(request);
if (ret.error())
WARNING_LOG(m_logger) << ret();
else
emit objectChanged(ret.id(), false); // For ShootbackController
m_mainHandler->dds()->ftsTgt()->shootbackTargetModifyReply(cookie, ret);
}
//--------------------------------------------------------------------------
Core::FunctionReplyObject HandlerShootbackTarget::shootbackTargetModifyRequest(const ShootbackTarget &request)
{
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
// modify
if (request.id() > 0)
{
ObjectShootbackTarget *ifs = m_objectMap.value(request.id());
if (!ifs)
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "ShootbackTarget with id %1 not found")).arg(request.id());
// since the attribute 'visibleParticipants' is *not* part of the db,
// ignore request.visibleParticipants and use the value of the current memory:
ShootbackTarget copy = request;
copy.visibleParticipants(ifs->getData().visibleParticipants());
return ifs->updateObject(copy);
}
// create
ObjectShootbackTarget *ifs(new ObjectShootbackTarget(m_mainHandler));
auto ret = ifs->createObject(request);
if (ret.error())
{
delete ifs;
ifs = nullptr;
}
else
m_objectMap.insert(ifs->getId(), ifs);
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
return ret;
}
//--------------------------------------------------------------------------
void HandlerShootbackTarget::onShootbackTargetRemoveRequest(const rti::core::SampleIdentity &cookie,
const Core::RemoveElementRequest &request)
{
TRACE_LOG(m_logger) << LOGFUNCTION << " request=" << request;
Core::FunctionReplyObject ret;
ObjectShootbackTarget *ifs = m_objectMap.value(request.id());
if (ifs == nullptr)
{
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "ShootbackTarget with id %1 not found")).arg(request.id());
m_mainHandler->dds()->ftsTgt()->shootbackTargetRemoveReply(cookie, ret);
return;
}
// // referenced by an assignment?
// if (m_mainHandler->handlerTargetAreaAssignment() &&
// m_mainHandler->handlerTargetAreaAssignment()->isTargetDataIdUsedInAny(request.id()))
// {
// ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "ShootbackTarget with id %1 is used.")).arg(request.id());
// m_mainHandler->dds()->ftsTgt()->shootbackTargetRemoveReply(cookie, ret);
// return;
// }
// if (m_mainHandler->dds()->topicLockMaster()->isLocked(ifs->getData(), m_mainHandler->exerciseId()))
// {
// ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "ShootbackTarget '%1' is used by another user!")).arg(ifs->getName());
// m_mainHandler->dds()->ftsTgt()->ShootbackTargetRemoveReply(cookie, ret);
// return;
// }
ret = ifs->removeObject();
if (ret.error())
ERROR_LOG(m_logger) << ret();
else
{
// delete Object
delete ifs;
m_objectMap.remove(request.id());
}
m_mainHandler->dds()->ftsTgt()->shootbackTargetRemoveReply(cookie, ret);
// For ShootbackController
if (!ret.error())
emit objectChanged(request.id(), true);
return;
}