diff --git a/msg/templates/urtps/Publisher.cpp.em b/msg/templates/urtps/Publisher.cpp.em index 2ff5d28a0d..78fb9c00dd 100644 --- a/msg/templates/urtps/Publisher.cpp.em +++ b/msg/templates/urtps/Publisher.cpp.em @@ -76,9 +76,15 @@ except AttributeError: #include "@(topic)_Publisher.h" -@(topic)_Publisher::@(topic)_Publisher() : mp_participant(nullptr), mp_publisher(nullptr) {} +@(topic)_Publisher::@(topic)_Publisher() + : mp_participant(nullptr), + mp_publisher(nullptr) +{ } -@(topic)_Publisher::~@(topic)_Publisher() { Domain::removeParticipant(mp_participant);} +@(topic)_Publisher::~@(topic)_Publisher() +{ + Domain::removeParticipant(mp_participant); +} bool @(topic)_Publisher::init() { @@ -149,19 +155,7 @@ void @(topic)_Publisher::PubListener::onPublicationMatched(Publisher* pub, Match } } -@[if fastrtps_version <= 1.7]@ -@[ if ros2_distro]@ - void @(topic)_Publisher::publish(@(package)::msg::dds_::@(topic)_* st) -@[ else]@ - void @(topic)_Publisher::publish(@(topic)_* st) -@[ end if]@ -@[else]@ -@[ if ros2_distro]@ - void @(topic)_Publisher::publish(@(package)::msg::@(topic)* st) -@[ else]@ - void @(topic)_Publisher::publish(@(topic)* st) -@[ end if]@ -@[end if]@ +void @(topic)_Publisher::publish(@(topic)_msg_t* st) { mp_publisher->write(st); } diff --git a/msg/templates/urtps/Publisher.h.em b/msg/templates/urtps/Publisher.h.em index cb95a74520..29b22266b6 100644 --- a/msg/templates/urtps/Publisher.h.em +++ b/msg/templates/urtps/Publisher.h.em @@ -77,6 +77,24 @@ except AttributeError: using namespace eprosima::fastrtps; using namespace eprosima::fastrtps::rtps; +@[if fastrtps_version <= 1.7]@ +@[ if ros2_distro]@ +using @(topic)_msg_t = @(package)::msg::dds_::@(topic)_; +using @(topic)_msg_datatype = @(package)::msg::dds_::@(topic)_PubSubType; +@[ else]@ +using @(topic)_msg_t = @(topic)_; +using @(topic)_msg_datatype = @(topic)_PubSubType; +@[ end if]@ +@[else]@ +@[ if ros2_distro]@ +using @(topic)_msg_t = @(package)::msg::@(topic); +using @(topic)_msg_datatype = @(package)::msg::@(topic)PubSubType; +@[ else]@ +using @(topic)_msg_t = @(topic); +using @(topic)_msg_datatype = @(topic)PubSubType; +@[ end if]@ +@[end if]@ + class @(topic)_Publisher { public: @@ -84,19 +102,7 @@ public: virtual ~@(topic)_Publisher(); bool init(); void run(); -@[if fastrtps_version <= 1.7]@ -@[ if ros2_distro]@ - void publish(@(package)::msg::dds_::@(topic)_* st); -@[ else]@ - void publish(@(topic)_* st); -@[ end if]@ -@[else]@ -@[ if ros2_distro]@ - void publish(@(package)::msg::@(topic)* st); -@[ else]@ - void publish(@(topic)* st); -@[ end if]@ -@[end if]@ + void publish(@(topic)_msg_t* st); private: Participant *mp_participant; Publisher *mp_publisher; @@ -109,19 +115,7 @@ private: void onPublicationMatched(Publisher* pub, MatchingInfo& info); int n_matched; } m_listener; -@[if fastrtps_version <= 1.7]@ -@[ if ros2_distro]@ - @(package)::msg::dds_::@(topic)_PubSubType @(topic)DataType; -@[ else]@ - @(topic)_PubSubType @(topic)DataType; -@[ end if]@ -@[else]@ -@[ if ros2_distro]@ - @(package)::msg::@(topic)PubSubType @(topic)DataType; -@[ else]@ - @(topic)PubSubType @(topic)DataType; -@[ end if]@ -@[end if]@ + @(topic)_msg_datatype @(topic)DataType; }; #endif // _@(topic)__PUBLISHER_H_