Class Message
Defined in File message.hpp
Inheritance Relationships
Derived Types
public ros_babel_fish::ArrayMessageBase
(Class ArrayMessageBase)public ros_babel_fish::CompoundMessage
(Class CompoundMessage)public ros_babel_fish::ValueMessage< T >
(Template Class ValueMessage)
Class Documentation
-
class Message
Message representation used by BabelFish. Wraps the memory of an actual type erased ROS2 message. Changes will affect the message that can be sent using the ROS runtime.
Subclassed by ros_babel_fish::ArrayMessageBase, ros_babel_fish::CompoundMessage, ros_babel_fish::ValueMessage< T >
Public Functions
-
virtual ~Message()
-
inline MessageType type() const
-
template<typename T>
inline T value() const Convenience method to obtain the content of a ValueMessage as the given type. A type conversion is done if the type doesn’t match exactly. If the target type can not fit the source type, a warning is printed.
- Template Parameters:
T – The type as which the value is retrieved
- Throws:
BabelFishException – If the message is not a ValueMessage
BabelFishException – If the type of the ValueMessage can not be casted to a different type which is the case for bool, std::string, ros::Time and ros::Duration
- Returns:
The value casted to the given type T
-
template<typename T>
inline T &as() Convenience method that casts the message to the given type. Example:
Message &msg = getMessage(); CompoundMessage &compound = msg.as<CompoundMessage>();
- Template Parameters:
T – Target type
- Throws:
BabelFishException – If the message can not be casted to the target type
- Returns:
Message casted to the target type as reference
-
template<typename T>
inline const T &as() const Convenience method that casts the message to the given type. Example:
Message &msg = getMessage(); CompoundMessage &compound = msg.as<CompoundMessage>();
- Template Parameters:
T – Target type
- Throws:
BabelFishException – If the message can not be casted to the target type
- Returns:
Message casted to the target type as reference
-
bool isTime() const
- Returns:
True if this message is a builtin_interfaces/Time message and can be cast to rclcpp::Time using the value method.
-
bool isDuration() const
- Returns:
True if this message is a builtin_interfaces/Duration message and can be cast to rclcpp::Duration using the value method.
-
virtual Message &operator[](const std::string &key)
Convenience method to access the child with the given key of a CompoundMessage.
- Parameters:
key – The name or path of the child
- Throws:
BabelFishException – If child access by key is not supported.
- Returns:
The child message accessed by the given key
-
virtual const Message &operator[](const std::string &key) const
Convenience method to access the child with the given key of a CompoundMessage.
- Parameters:
key – The name or path of the child
- Throws:
BabelFishException – If child access by key is not supported.
- Returns:
The child message accessed by the given key
-
bool operator==(const char *c) const
-
bool operator==(const wchar_t *c) const
-
template<>
bool value() const
Protected Functions
-
inline virtual void onMoved()
-
inline unsigned char *data_ptr()
-
inline const unsigned char *data_ptr() const
Friends
- friend class CompoundMessage
- friend class CompoundArrayMessage_
-
virtual ~Message()