rclcpp
master
C++ ROS Client Library API
|
Go to the documentation of this file.
15 #ifndef RCLCPP__LOANED_MESSAGE_HPP_
16 #define RCLCPP__LOANED_MESSAGE_HPP_
31 template<
typename MessageT,
typename AllocatorT = std::allocator<
void>>
35 using MessageAllocator =
typename MessageAllocatorTraits::allocator_type;
67 void * message_ptr =
nullptr;
70 rosidl_typesupport_cpp::get_message_type_support_handle<MessageT>(),
75 message_ =
static_cast<MessageT *
>(message_ptr);
79 "Currently used middleware can't loan messages. Local allocator will be used.");
145 error_logger,
"rcl_deallocate_loaned_message failed: %s", rcl_get_error_string().str);
207 msg_ptr->~MessageT();
208 allocator.deallocate(msg_ptr, 1);
225 #endif // RCLCPP__LOANED_MESSAGE_HPP_
std::unique_ptr< MessageT, std::function< void(MessageT *)> > release()
Release ownership of the ROS message instance.
Definition: loaned_message.hpp:194
std::shared_ptr< rcl_publisher_t > get_publisher_handle()
Get the rcl publisher handle.
rcl_ret_t rcl_borrow_loaned_message(const rcl_publisher_t *publisher, const rosidl_message_type_support_t *type_support, void **ros_message)
LoanedMessage(LoanedMessage< MessageT > &&other)
Move semantic for RVO.
Definition: loaned_message.hpp:113
Logger get_logger(const std::string &name)
Return a named logger.
Definition: loaned_message.hpp:32
MessageT * message_
Definition: loaned_message.hpp:215
This header provides the get_node_base_interface() template function.
Definition: allocator_common.hpp:24
MessageAllocator message_allocator_
Definition: loaned_message.hpp:217
virtual ~LoanedMessage()
Destructor of the LoanedMessage class.
Definition: loaned_message.hpp:131
bool is_valid() const
Validate if the message was correctly allocated.
Definition: loaned_message.hpp:164
typename std::allocator_traits< Alloc >::template rebind_traits< T > AllocRebind
Definition: allocator_common.hpp:30
Definition: publisher_base.hpp:56
const rclcpp::PublisherBase & pub_
Definition: loaned_message.hpp:213
MessageT & get() const
Access the ROS message instance.
Definition: loaned_message.hpp:177
bool can_loan_messages() const
Check if publisher instance can loan messages.
LoanedMessage(const rclcpp::PublisherBase &pub, std::allocator< MessageT > allocator)
Constructor of the LoanedMessage class.
Definition: loaned_message.hpp:59
#define RCLCPP_INFO_ONCE(logger,...)
Definition: logging.hpp:551
void throw_from_rcl_error(rcl_ret_t ret, const std::string &prefix="", const rcl_error_state_t *error_state=nullptr, void(*reset_error)()=rcl_reset_error)
Throw a C++ std::exception which was created based on an rcl error.
rcl_ret_t rcl_return_loaned_message_from_publisher(const rcl_publisher_t *publisher, void *loaned_message)
LoanedMessage(const rclcpp::PublisherBase *pub, std::shared_ptr< std::allocator< MessageT >> allocator)
Constructor of the LoanedMessage class.
Definition: loaned_message.hpp:106
#define RCLCPP_ERROR(logger,...)
Definition: logging.hpp:1398