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>
149 lines
4.2 KiB
C++
149 lines
4.2 KiB
C++
/**
|
|
* @RDE_HEADER@
|
|
* * GenericDataWriter (including GenericDataWriterBase)
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <dds/pub/DataWriter.hpp>
|
|
#include <dds/sub/SampleInfo.hpp>
|
|
#include <dds/topic/find.hpp>
|
|
#include <dds/topic/Topic.hpp>
|
|
|
|
#include <DDS/Generic/generic_logger.h>
|
|
#include <DDS/Generic/generic_base.h>
|
|
|
|
namespace DDSGeneric
|
|
{
|
|
|
|
template <typename TOPICTYPE>
|
|
class GenericDataWriter final
|
|
{
|
|
public:
|
|
using TopicType = TOPICTYPE;
|
|
using DataWriter = dds::pub::DataWriter<TopicType>;
|
|
using DataTopic = dds::topic::Topic<TopicType>;
|
|
|
|
GenericDataWriter()
|
|
: m_dataWriter(nullptr)
|
|
, m_ddsTopic(nullptr)
|
|
, m_logger(DDS::getLogger(DDS::topic_type_name<TopicType>::value(), DDS::DataType::DATA_WRITER))
|
|
{}
|
|
|
|
bool create(const dds::domain::DomainParticipant &participant,
|
|
const dds::pub::Publisher &ddsPublisher,
|
|
const std::string &topicName = DDS::Helper::getShortTopicName(DDS::topic_type_name<TopicType>::value()))
|
|
{
|
|
DEBUG_LOG(m_logger) << "IN GenericDataWriter::create ("
|
|
<< DDS::topic_type_name<TopicType>::value()
|
|
<< ")";
|
|
|
|
if (participant == nullptr)
|
|
{
|
|
ERROR_LOG(m_logger) << "Participant not available, aborting. ";
|
|
return false;
|
|
}
|
|
|
|
if (m_ddsTopic != nullptr)
|
|
{
|
|
ERROR_LOG(m_logger) << "Type '"
|
|
<< DDS::topic_type_name<TopicType>::value()
|
|
<< "' already created";
|
|
return false;
|
|
}
|
|
|
|
try {
|
|
|
|
DEBUG_LOG(m_logger) << "Creating write topic " << topicName << " with type: "
|
|
<< DDS::topic_type_name<TopicType>::value();
|
|
|
|
m_ddsTopic = dds::topic::find<DataTopic>(participant, topicName);
|
|
if (m_ddsTopic == nullptr)
|
|
m_ddsTopic = DataTopic(participant, topicName);
|
|
|
|
m_dataWriter = DataWriter(ddsPublisher,
|
|
m_ddsTopic,
|
|
ddsPublisher.default_datawriter_qos());
|
|
|
|
if (m_dataWriter == nullptr)
|
|
{
|
|
ERROR_LOG(m_logger) << "Initialisation of "
|
|
<< DDS::topic_type_name<TopicType>::value()
|
|
<< " failed ";
|
|
return false;
|
|
}
|
|
|
|
}
|
|
catch ( const dds::core::Exception &ex )
|
|
{
|
|
ERROR_LOG(m_logger) << ex.what();
|
|
return false;
|
|
}
|
|
|
|
DEBUG_LOG(m_logger) << "dataWriter created ("
|
|
<< DDS::topic_type_name<TopicType>::value()
|
|
<< ")";
|
|
|
|
return true;
|
|
}
|
|
|
|
bool write(const TopicType &data,
|
|
const dds::core::optional<dds::sub::SampleInfo> &si = dds::core::optional<dds::sub::SampleInfo>())
|
|
{
|
|
DEBUG_LOG(m_logger) << "IN write ("
|
|
<< DDS::topic_type_name<TopicType>::value()
|
|
<< ") ";
|
|
|
|
if (m_dataWriter == nullptr) {
|
|
ERROR_LOG(m_logger) << "No dataWriter initialised ";
|
|
return false;
|
|
}
|
|
|
|
if (si.is_set())
|
|
{
|
|
rti::pub::WriteParams writeParams;
|
|
rti::core::SampleIdentity sampleIdentity(si.get()->source_guid(), si.get()->publication_sequence_number());
|
|
writeParams.related_sample_identity(sampleIdentity);
|
|
|
|
m_dataWriter->write(data, writeParams);
|
|
} else {
|
|
m_dataWriter.write(data);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool remove(const TopicType &data, bool errorMsgIfNotExists = true)
|
|
{
|
|
DEBUG_LOG(m_logger) << "IN remove ("
|
|
<< DDS::topic_type_name<TopicType>::value()
|
|
<< ") ";
|
|
|
|
if (m_dataWriter == nullptr) {
|
|
ERROR_LOG(m_logger) << "No dataWriter initialised ";
|
|
return false;
|
|
}
|
|
const dds::core::InstanceHandle ih = m_dataWriter.lookup_instance(data);
|
|
if (ih.is_nil()) {
|
|
if (errorMsgIfNotExists)
|
|
ERROR_LOG(m_logger) << "Could not find instance for topic "
|
|
<< DDS::topic_type_name<TopicType>::value()
|
|
<< " for unregistering!";
|
|
return false;
|
|
}
|
|
m_dataWriter.dispose_instance(ih);
|
|
return true;
|
|
}
|
|
|
|
DataWriter dataWriter() const { return m_dataWriter; }
|
|
|
|
private:
|
|
DataWriter m_dataWriter;
|
|
DataTopic m_ddsTopic;
|
|
NGL::INGLLogger &m_logger;
|
|
};
|
|
|
|
} // Namespace DDSGeneric
|