add a publish method with the const MessageT * signature (#307)

This commit is contained in:
William Woodall 2017-02-27 18:48:01 -08:00 committed by GitHub
parent dc6b15983a
commit ce146cfdba
2 changed files with 18 additions and 0 deletions

View file

@ -261,6 +261,15 @@ public:
return this->publish(unique_msg); return this->publish(unique_msg);
} }
virtual void
publish(const MessageT * msg)
{
if (!msg) {
throw std::runtime_error("msg argument is nullptr");
}
return this->publish(*msg);
}
std::shared_ptr<MessageAlloc> get_allocator() const std::shared_ptr<MessageAlloc> get_allocator() const
{ {
return message_allocator_; return message_allocator_;

View file

@ -125,6 +125,15 @@ public:
rclcpp::publisher::Publisher<MessageT, Alloc>::publish(msg); rclcpp::publisher::Publisher<MessageT, Alloc>::publish(msg);
} }
virtual void
publish(const MessageT * msg)
{
if (!msg) {
throw std::runtime_error("msg argument is nullptr");
}
this->publish(*msg);
}
/// LifecyclePublisher pulish function /// LifecyclePublisher pulish function
/** /**
* The publish function checks whether the communication * The publish function checks whether the communication