microRTPS: agent: simplify Publisher code specialization

This commit is contained in:
TSC21
2020-03-11 15:13:07 +00:00
committed by Nuno Marques
parent 296714a00a
commit e9bc675bfa
2 changed files with 29 additions and 41 deletions
+9 -15
View File
@@ -76,9 +76,15 @@ except AttributeError:
#include "@(topic)_Publisher.h" #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() bool @(topic)_Publisher::init()
{ {
@@ -149,19 +155,7 @@ void @(topic)_Publisher::PubListener::onPublicationMatched(Publisher* pub, Match
} }
} }
@[if fastrtps_version <= 1.7]@ void @(topic)_Publisher::publish(@(topic)_msg_t* st)
@[ 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]@
{ {
mp_publisher->write(st); mp_publisher->write(st);
} }
+20 -26
View File
@@ -77,6 +77,24 @@ except AttributeError:
using namespace eprosima::fastrtps; using namespace eprosima::fastrtps;
using namespace eprosima::fastrtps::rtps; 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 class @(topic)_Publisher
{ {
public: public:
@@ -84,19 +102,7 @@ public:
virtual ~@(topic)_Publisher(); virtual ~@(topic)_Publisher();
bool init(); bool init();
void run(); void run();
@[if fastrtps_version <= 1.7]@ void publish(@(topic)_msg_t* st);
@[ 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]@
private: private:
Participant *mp_participant; Participant *mp_participant;
Publisher *mp_publisher; Publisher *mp_publisher;
@@ -109,19 +115,7 @@ private:
void onPublicationMatched(Publisher* pub, MatchingInfo& info); void onPublicationMatched(Publisher* pub, MatchingInfo& info);
int n_matched; int n_matched;
} m_listener; } m_listener;
@[if fastrtps_version <= 1.7]@ @(topic)_msg_datatype @(topic)DataType;
@[ 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]@
}; };
#endif // _@(topic)__PUBLISHER_H_ #endif // _@(topic)__PUBLISHER_H_