Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/DDS/DTS/generic_dts_impl.h
T
berrux-dev cfe15c72c4 Merge story/release-validation-scope
Bring the validation-scope line (in-tree Jenkins CI copy, lcov coverage
wiring, step-by-step release-scope README, TetraIF unit tests, the
LogView runtime icon/resource fix, Dockerfile, rpmbuild and the
new_docker_build.sh driver with the DEB output path) on top of the
XmlPatterns branch pruned to the Release 2 scope.

Conflict policy:
- Out-of-scope targets/modules: keep the prune (deletion wins).
- In-scope files that validation had deleted: restored from
  story/release-2-cleanup (the Release 2 closure, with the
  pruned-module guards).
- In-scope sources carrying migration work: XmlPatterns versions
  (Qt XmlPatterns rework on QDomDocument, DDS member and logger
  fixes, first-build fixes).
- Scope-aware CMakeLists (top level, PluginInterfaces, LtsWidgets)
  and .envrc: story/release-2-cleanup / ours versions.
2026-11-16 18:49:14 +01:00

83 lines
2.6 KiB
C++

/**
* @RDE_HEADER@
* DataTopicServers (DTSs) - generic
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include "generic_dts.h"
#include <DDS/Generic/generic_data_writer.h>
#include <DDS/Generic/generic_logger.h>
namespace DTS
{
template <typename DWO_OBJECT> class GenericDtsImpl final : public GenericDts<typename DWO_OBJECT::TopicType>
{
public:
using DataWriterObject = DWO_OBJECT;
using TopicType = typename DWO_OBJECT::TopicType;
using DataWriter = typename dds::pub::DataWriter<TopicType>;
GenericDtsImpl(
const dds::domain::DomainParticipant& domainParticipant, const dds::pub::Publisher& ddsPublisher,
const std::string& topicName = DDS::Helper::getShortTopicName(DDS::topic_type_name<TopicType>::value()))
: m_dataWriterObject(new DataWriterObject()),
m_logger(DDS::getLogger(DDS::topic_type_name<TopicType>::value(), DDS::DataType::DATA_TOPIC_SERVER))
{
Q_ASSERT(domainParticipant != nullptr);
Q_ASSERT(ddsPublisher != nullptr);
m_dataWriterObject->create(domainParticipant, ddsPublisher, topicName);
}
~GenericDtsImpl()
{
delete m_dataWriterObject;
}
bool write(const TopicType& data, const dds::core::optional<dds::sub::SampleInfo>& si =
dds::core::optional<dds::sub::SampleInfo>()) override final
{
DEBUG_LOG(m_logger) << "IN write (" << DDS::topic_type_name<TopicType>::value() << ")";
if (!m_dataWriterObject)
return false;
if (!m_dataWriterObject->write(data, si))
{
ERROR_LOG(m_logger) << "Error writing for " << DDS::topic_type_name<TopicType>::value();
return false;
}
DEBUG_LOG(m_logger) << "TopicData (" << DDS::topic_type_name<TopicType>::value() << ") written";
return true;
}
bool remove(const TopicType& data, bool errorMsgIfNotExists = true) override final
{
DEBUG_LOG(m_logger) << "IN remove (" << DDS::topic_type_name<TopicType>::value() << ")";
if (!m_dataWriterObject)
return false;
if (!m_dataWriterObject->remove(data, errorMsgIfNotExists))
{
if (errorMsgIfNotExists)
ERROR_LOG(m_logger) << "Error removing for " << DDS::topic_type_name<TopicType>::value();
return false;
}
DEBUG_LOG(m_logger) << "TopicData (" << DDS::topic_type_name<TopicType>::value() << ") removed";
return true;
}
private:
DataWriterObject* m_dataWriterObject;
NGL::INGLLogger& m_logger;
};
} // namespace DTS