- 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>
143 lines
3.9 KiB
C++
Executable File
143 lines
3.9 KiB
C++
Executable File
|
|
|
|
|
|
#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() << "IN GenericDataWriter::create ("
|
|
<< DDS::topic_type_name<TopicType>::value()
|
|
<< ")";
|
|
|
|
if (participant == nullptr)
|
|
{
|
|
ERROR_LOG() << "Participant not available, aborting. ";
|
|
return false;
|
|
}
|
|
|
|
if (m_ddsTopic != nullptr)
|
|
{
|
|
ERROR_LOG() << "Type '"
|
|
<< DDS::topic_type_name<TopicType>::value()
|
|
<< "' already created";
|
|
return false;
|
|
}
|
|
|
|
try {
|
|
|
|
DEBUG_LOG() << "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() << "Initialisation of "
|
|
<< DDS::topic_type_name<TopicType>::value()
|
|
<< " failed ";
|
|
return false;
|
|
}
|
|
|
|
}
|
|
catch ( const dds::core::Exception &ex )
|
|
{
|
|
ERROR_LOG() << ex.what();
|
|
return false;
|
|
}
|
|
|
|
DEBUG_LOG() << "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() << "IN write ("
|
|
<< DDS::topic_type_name<TopicType>::value()
|
|
<< ") ";
|
|
|
|
if (m_dataWriter == nullptr) {
|
|
ERROR_LOG() << "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() << "IN remove ("
|
|
<< DDS::topic_type_name<TopicType>::value()
|
|
<< ") ";
|
|
|
|
if (m_dataWriter == nullptr) {
|
|
ERROR_LOG() << "No dataWriter initialised ";
|
|
return false;
|
|
}
|
|
const dds::core::InstanceHandle ih = m_dataWriter.lookup_instance(data);
|
|
if (ih.is_nil()) {
|
|
if (errorMsgIfNotExists)
|
|
ERROR_LOG() << "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;
|
|
};
|
|
|
|
}
|