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;
66 void * message_ptr =
nullptr;
69 rosidl_typesupport_cpp::get_message_type_support_handle<MessageT>(),
74 message_ =
static_cast<MessageT *
>(message_ptr);
78 "Currently used middleware can't loan messages. Local allocator will be used.");
175 MessageT &
get()
const 207 #endif // RCLCPP__LOANED_MESSAGE_HPP_ rcl_ret_t rcl_borrow_loaned_message(const rcl_publisher_t *publisher, const rosidl_message_type_support_t *type_support, void **ros_message)
#define rcl_get_error_string
MessageAllocator message_allocator_
Definition: loaned_message.hpp:199
Logger get_logger(const std::string &name)
Return a named logger.
const rclcpp::PublisherBase & pub_
Definition: loaned_message.hpp:195
Definition: publisher_base.hpp:55
This header provides the get_node_base_interface() template function.
Definition: allocator_common.hpp:24
MessageT * message_
Definition: loaned_message.hpp:197
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.
bool can_loan_messages() const
Check if publisher instance can loan messages.
bool is_valid() const
Validate if the message was correctly allocated.
Definition: loaned_message.hpp:162
MessageT * release()
Release ownership of the ROS message instance.
Definition: loaned_message.hpp:187
typename std::allocator_traits< Alloc >::template rebind_traits< T > AllocRebind
Definition: allocator_common.hpp:30
rcl_ret_t rcl_return_loaned_message_from_publisher(const rcl_publisher_t *publisher, void *loaned_message)
#define RCLCPP_ERROR(logger,...)
Definition: logging.hpp:1418
rcl_publisher_t * get_publisher_handle()
Get the rcl publisher handle.
virtual ~LoanedMessage()
Destructor of the LoanedMessage class.
Definition: loaned_message.hpp:129
LoanedMessage(const rclcpp::PublisherBase &pub, std::allocator< MessageT > allocator)
Constructor of the LoanedMessage class.
Definition: loaned_message.hpp:58
#define RCLCPP_INFO_ONCE(logger,...)
Definition: logging.hpp:558
LoanedMessage(LoanedMessage< MessageT > &&other)
Move semantic for RVO.
Definition: loaned_message.hpp:111
LoanedMessage(const rclcpp::PublisherBase *pub, std::shared_ptr< std::allocator< MessageT >> allocator)
Constructor of the LoanedMessage class.
Definition: loaned_message.hpp:104
Definition: loaned_message.hpp:32