5#include "modulo_core/communication/MessageType.hpp"
6#include "modulo_core/exceptions.hpp"
11template<
typename MsgT,
typename DataT>
55 template<
typename MsgT,
typename DataT>
56 [[nodiscard]] std::shared_ptr<MessagePair<MsgT, DataT>>
get_message_pair(
bool validate_pointer =
true);
67 template<
typename MsgT,
typename DataT>
68 [[nodiscard]] MsgT
write();
79 template<
typename MsgT,
typename DataT>
80 void read(
const MsgT& message);
92template<
typename MsgT,
typename DataT>
94 std::shared_ptr<MessagePair<MsgT, DataT>> message_pair_ptr;
96 message_pair_ptr = std::dynamic_pointer_cast<MessagePair<MsgT, DataT>>(this->shared_from_this());
97 }
catch (
const std::exception& ex) {
98 if (validate_pointer) {
102 if (message_pair_ptr ==
nullptr && validate_pointer) {
104 "Unable to cast message pair interface to a message pair pointer of requested type");
106 return message_pair_ptr;
109template<
typename MsgT,
typename DataT>
111 return this->
template get_message_pair<MsgT, DataT>()->write_message();
114template<
typename MsgT,
typename DataT>
116 this->
template get_message_pair<MsgT, DataT>()->read_message(message);
Interface class to enable non-templated writing and reading ROS messages from derived MessagePair ins...
virtual ~MessagePairInterface()=default
Default virtual destructor.
std::shared_ptr< MessagePair< MsgT, DataT > > get_message_pair(bool validate_pointer=true)
Get a pointer to a derived MessagePair instance from a MessagePairInterface pointer.
MessageType get_type() const
Get the MessageType of the MessagePairInterface.
MsgT write()
Get the ROS message of a derived MessagePair instance through the MessagePairInterface pointer.
void read(const MsgT &message)
Read a ROS message and set the data of the derived MessagePair instance through the MessagePairInterf...
MessagePairInterface(const MessagePairInterface &message_pair)=default
Copy constructor from another MessagePairInterface.
An exception class to notify if the result of getting an instance of a derived class through dynamic ...
An exception class to notify if an object has no reference count (if the object is not owned by any p...
Modulo Core communication module for handling messages on publication and subscription interfaces.
MessageType
Enum of all supported ROS message types for the MessagePairInterface.