Skip to content

Commit

Permalink
Implementation of DataWriter::get_type() (eProsima#2101)
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Ponz Segrelles <eduardoponz@eprosima.com>
Signed-off-by: Samuel Wilhelmsson <samuel@halodi.com>
  • Loading branch information
EduPonz authored and SamuelWHalodi committed Oct 4, 2021
1 parent 783a4ec commit 3a831b2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/cpp/fastdds/publisher/DataWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
21 changes: 21 additions & 0 deletions test/unittest/dds/publisher/DataWriterTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit 3a831b2

Please sign in to comment.