Template Class MessageEvent

Class Documentation

template<typename M>
class MessageEvent

Event type for subscriptions, const message_filters::MessageEvent<M const>& can be used in your callback instead of const std::shared_ptr<M const>&.

Useful if you need to retrieve meta-data about the message, such as the full connection header, or the publisher’s node name

Public Types

typedef std::add_const<M>::type ConstMessage
typedef std::remove_const<M>::type Message
typedef std::shared_ptr<Message> MessagePtr
typedef std::shared_ptr<ConstMessage> ConstMessagePtr
typedef std::function<MessagePtr()> CreateFunction

Public Functions

inline MessageEvent()
inline MessageEvent(const MessageEvent<Message> &rhs)
inline MessageEvent(const MessageEvent<ConstMessage> &rhs)
inline MessageEvent(const MessageEvent<Message> &rhs, bool nonconst_need_copy)
inline MessageEvent(const MessageEvent<ConstMessage> &rhs, bool nonconst_need_copy)
inline MessageEvent(const MessageEvent<void const> &rhs, const CreateFunction &create)
inline MessageEvent(const ConstMessagePtr &message)

Todo:

Make this explicit in ROS 2.0. Keep as auto-converting for now to maintain backwards compatibility in some places (message_filters)

inline MessageEvent(const ConstMessagePtr &message, rclcpp::Time receipt_time)
inline MessageEvent(const ConstMessagePtr &message, rclcpp::Time receipt_time, bool nonconst_need_copy, const CreateFunction &create)
inline void init(const ConstMessagePtr &message, rclcpp::Time receipt_time, bool nonconst_need_copy, const CreateFunction &create)
inline void operator=(const MessageEvent<Message> &rhs)
inline void operator=(const MessageEvent<ConstMessage> &rhs)
inline std::shared_ptr<M> getMessage() const

Retrieve the message. If M is const, this returns a reference to it. If M is non const and this event requires it, returns a copy. Note that it caches this copy for later use, so it will only every make the copy once.

inline const std::shared_ptr<ConstMessage> &getConstMessage() const

Retrieve a const version of the message.

inline rclcpp::Time getReceiptTime() const

Returns the time at which this message was received.

inline bool nonConstWillCopy() const
inline bool getMessageWillCopy() const
inline bool operator<(const MessageEvent<M> &rhs)
inline bool operator==(const MessageEvent<M> &rhs)
inline bool operator!=(const MessageEvent<M> &rhs)
inline const CreateFunction &getMessageFactory() const