mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-30 10:43:34 +08:00
microRTPS: agent: simplify Publisher code specialization
This commit is contained in:
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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_
|
||||||
|
|||||||
Reference in New Issue
Block a user