Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Services/TargetManagement/handler_shootback_target.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

185 lines
5.9 KiB
C++
Executable File

/**
* Handler ShootbackTargets (L400)
* $Id$
* $HeadURL$
* $Author$
* Created by N. Thoden, NLE, 06.04.2020
*/
#include "main_handler.h"
#include <utility>
#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())
{
TRACE_LOG() << Q_FUNC_INFO << " START";
TRACE_LOG() << Q_FUNC_INFO << " END";
}
//--------------------------------------------------------------------------
HandlerShootbackTarget::~HandlerShootbackTarget()
{
TRACE_LOG() << Q_FUNC_INFO << " START";
TRACE_LOG() << Q_FUNC_INFO << " END";
}
//--------------------------------------------------------------------------
bool HandlerShootbackTarget::init()
{
TRACE_LOG() << Q_FUNC_INFO << " 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() << "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() << ret();
bRet = false;
return;
}
m_objectMap.insert(ifs->getId(), ifs);
};
if (!m_mainHandler->db()->select(cb) || !bRet)
{
ERROR_LOG() << "Error reading data from database!";
return false;
}
DEBUG_LOG() << "m_objectMap.size() = " << m_objectMap.size();
return true;
}
ObjectShootbackTarget *HandlerShootbackTarget::dataForTargetParticipantId(int targetParticipantId) const
{
for (ObjectShootbackTarget *item : std::as_const(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() << 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() << Q_FUNC_INFO << " 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() << Q_FUNC_INFO << " END";
return ret;
}
//--------------------------------------------------------------------------
void HandlerShootbackTarget::onShootbackTargetRemoveRequest(const rti::core::SampleIdentity &cookie,
const Core::RemoveElementRequest &request)
{
TRACE_LOG() << Q_FUNC_INFO << " 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() << 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;
}