From 3a831b2e73c8ec093672c828ba17e5d1783815bd Mon Sep 17 00:00:00 2001 From: Eduardo Ponz Segrelles Date: Mon, 9 Aug 2021 07:15:08 +0200 Subject: [PATCH] Implementation of DataWriter::get_type() (#2101) Signed-off-by: Eduardo Ponz Segrelles Signed-off-by: Samuel Wilhelmsson --- src/cpp/fastdds/publisher/DataWriter.cpp | 5 +++++ .../dds/publisher/DataWriterTests.cpp | 21 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/cpp/fastdds/publisher/DataWriter.cpp b/src/cpp/fastdds/publisher/DataWriter.cpp index 115bce70da3..0c19d0b7b23 100644 --- a/src/cpp/fastdds/publisher/DataWriter.cpp +++ b/src/cpp/fastdds/publisher/DataWriter.cpp @@ -177,6 +177,11 @@ InstanceHandle_t DataWriter::get_instance_handle() const return impl_->get_instance_handle(); } +TypeSupport DataWriter::get_type() const +{ + return impl_->get_type(); +} + ReturnCode_t DataWriter::set_qos( const DataWriterQos& qos) { diff --git a/test/unittest/dds/publisher/DataWriterTests.cpp b/test/unittest/dds/publisher/DataWriterTests.cpp index 009b8c3d43f..d75174c9caf 100644 --- a/test/unittest/dds/publisher/DataWriterTests.cpp +++ b/test/unittest/dds/publisher/DataWriterTests.cpp @@ -179,6 +179,27 @@ class BoundedTopicDataTypeMock : public TopicDataType }; +TEST(DataWriterTests, get_type) +{ + DomainParticipant* participant = + DomainParticipantFactory::get_instance()->create_participant(0, PARTICIPANT_QOS_DEFAULT); + ASSERT_NE(participant, nullptr); + + Publisher* publisher = participant->create_publisher(PUBLISHER_QOS_DEFAULT); + ASSERT_NE(publisher, nullptr); + + TypeSupport type(new TopicDataTypeMock()); + type.register_type(participant); + + Topic* topic = participant->create_topic("footopic", type.get_type_name(), TOPIC_QOS_DEFAULT); + ASSERT_NE(topic, nullptr); + + DataWriter* datawriter = publisher->create_datawriter(topic, DATAWRITER_QOS_DEFAULT); + ASSERT_NE(datawriter, nullptr); + + ASSERT_EQ(type, datawriter->get_type()); +} + TEST(DataWriterTests, ChangeDataWriterQos) { DomainParticipant* participant =