Deprecate shared ptr publish (#709)
* Deprecate publish methods with shared_ptr signature Signed-off-by: ivanpauno <ivanpauno@ekumenlabs.com> * Corrected with PR comments. Deprecated similar methods in lifecycle publisher Signed-off-by: ivanpauno <ivanpauno@ekumenlabs.com> * Removed reference in unique_ptr publish call Signed-off-by: ivanpauno <ivanpauno@ekumenlabs.com> * Corrected with PR comments. Corrected warning problem in lifecycle_publisher Signed-off-by: ivanpauno <ivanpauno@ekumenlabs.com> * Deprecate publish call taking a raw ptr. Stop deprecating publish methods in LifecyclePublisher. Signed-off-by: ivanpauno <ivanpauno@ekumenlabs.com> * Pleased linter Signed-off-by: ivanpauno <ivanpauno@ekumenlabs.com> * Corrected mac warning Signed-off-by: ivanpauno <ivanpauno@ekumenlabs.com> * Corrected serialized publish methods Signed-off-by: ivanpauno <ivanpauno@ekumenlabs.com> * Avoid windows warning Signed-off-by: ivanpauno <ivanpauno@ekumenlabs.com> * Not deprecate on windows Signed-off-by: ivanpauno <ivanpauno@ekumenlabs.com>
This commit is contained in:
parent
d399fef9c6
commit
385cccc2cc
3 changed files with 88 additions and 37 deletions
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "rclcpp/publisher.hpp"
|
||||
|
||||
|
@ -79,7 +80,7 @@ public:
|
|||
* to the actual rclcpp Publisher base class
|
||||
*/
|
||||
virtual void
|
||||
publish(std::unique_ptr<MessageT, MessageDeleter> & msg)
|
||||
publish(std::unique_ptr<MessageT, MessageDeleter> msg)
|
||||
{
|
||||
if (!enabled_) {
|
||||
RCLCPP_WARN(logger_,
|
||||
|
@ -88,26 +89,7 @@ public:
|
|||
|
||||
return;
|
||||
}
|
||||
rclcpp::Publisher<MessageT, Alloc>::publish(msg);
|
||||
}
|
||||
|
||||
/// LifecyclePublisher publish function
|
||||
/**
|
||||
* The publish function checks whether the communication
|
||||
* was enabled or disabled and forwards the message
|
||||
* to the actual rclcpp Publisher base class
|
||||
*/
|
||||
virtual void
|
||||
publish(const std::shared_ptr<const MessageT> & msg)
|
||||
{
|
||||
if (!enabled_) {
|
||||
RCLCPP_WARN(logger_,
|
||||
"Trying to publish message on the topic '%s', but the publisher is not activated",
|
||||
this->get_topic_name());
|
||||
|
||||
return;
|
||||
}
|
||||
rclcpp::Publisher<MessageT, Alloc>::publish(*msg);
|
||||
rclcpp::Publisher<MessageT, Alloc>::publish(std::move(msg));
|
||||
}
|
||||
|
||||
/// LifecyclePublisher publish function
|
||||
|
@ -129,6 +111,39 @@ public:
|
|||
rclcpp::Publisher<MessageT, Alloc>::publish(msg);
|
||||
}
|
||||
|
||||
/// LifecyclePublisher publish function
|
||||
/**
|
||||
* The publish function checks whether the communication
|
||||
* was enabled or disabled and forwards the message
|
||||
* to the actual rclcpp Publisher base class
|
||||
*/
|
||||
// Skip deprecated attribute in windows, as it raise a warning in template specialization.
|
||||
#if !defined(_WIN32)
|
||||
// Avoid raising a deprecated warning in template specialization in linux.
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
[[deprecated(
|
||||
"publishing an unique_ptr is prefered when using intra process communication."
|
||||
" If using a shared_ptr, use publish(*msg).")]]
|
||||
#endif
|
||||
virtual void
|
||||
publish(const std::shared_ptr<const MessageT> & msg)
|
||||
{
|
||||
if (!enabled_) {
|
||||
RCLCPP_WARN(logger_,
|
||||
"Trying to publish message on the topic '%s', but the publisher is not activated",
|
||||
this->get_topic_name());
|
||||
|
||||
return;
|
||||
}
|
||||
rclcpp::Publisher<MessageT, Alloc>::publish(*msg);
|
||||
}
|
||||
|
||||
// Skip deprecated attribute in windows, as it raise a warning in template specialization.
|
||||
#if !defined(_WIN32)
|
||||
[[deprecated(
|
||||
"Use publish(*msg). Check against nullptr before calling if necessary.")]]
|
||||
#endif
|
||||
virtual void
|
||||
publish(const MessageT * msg)
|
||||
{
|
||||
|
@ -138,6 +153,10 @@ public:
|
|||
this->publish(*msg);
|
||||
}
|
||||
|
||||
#if !defined(_WIN32)
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
virtual void
|
||||
on_activate()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue