Modulo 5.0.0
|
Interface class to enable non-templated subscriptions with ROS subscriptions from derived SubscriptionHandler instances through dynamic down-casting. More...
#include <SubscriptionInterface.hpp>
Public Member Functions | |
SubscriptionInterface (std::shared_ptr< MessagePairInterface > message_pair=nullptr) | |
Constructor with the message pair. | |
SubscriptionInterface (const SubscriptionInterface &subscription)=default | |
Copy constructor from another SubscriptionInterface. | |
virtual | ~SubscriptionInterface ()=default |
Default virtual destructor. | |
template<typename MsgT > | |
std::shared_ptr< SubscriptionHandler< MsgT > > | get_handler (bool validate_pointer=true) |
Get a pointer to a derived SubscriptionHandler instance from a SubscriptionInterface pointer. | |
std::shared_ptr< MessagePairInterface > | get_message_pair () const |
Get the pointer to the message pair of the SubscriptionInterface. | |
void | set_message_pair (const std::shared_ptr< MessagePairInterface > &message_pair) |
Set the pointer to the message pair of the SubscriptionInterface. | |
Protected Attributes | |
std::shared_ptr< MessagePairInterface > | message_pair_ |
The pointer to the stored MessagePair instance. | |
Interface class to enable non-templated subscriptions with ROS subscriptions from derived SubscriptionHandler instances through dynamic down-casting.
Definition at line 19 of file SubscriptionInterface.hpp.
|
explicit |
Constructor with the message pair.
message_pair | The pointer to the message pair with the data that should be updated through the subscription |
Definition at line 5 of file SubscriptionInterface.cpp.
|
inline |
Get a pointer to a derived SubscriptionHandler instance from a SubscriptionInterface pointer.
If a SubscriptionInterface pointer is used to address a derived SubscriptionHandler instance, this method will return a pointer to that derived instance through dynamic down-casting. The downcast will fail if the base SubscriptionInterface object has no reference count (if the object is not owned by any pointer), or if the derived object is not a correctly typed instance of a SubscriptionHandler. By default, an InvalidPointerCastException is thrown when the downcast fails. If this validation is disabled by setting the validate_pointer flag to false, it will not throw an exception and instead return a null pointer.
PubT | The ROS publisher type |
MsgT | The ROS message type |
modulo_core::exceptions::InvalidPointerException | if the base SubscriptionInterface object has no reference count and validate_pointer is set to true |
modulo_core::exceptions::InvalidPointerCastException | if the derived object from the dynamic down-casting is not a correctly typed instance of a SubscriptionHandler |
validate_pointer | If true, throw an exception when down-casting fails |
Definition at line 74 of file SubscriptionInterface.hpp.
std::shared_ptr< MessagePairInterface > modulo_core::communication::SubscriptionInterface::get_message_pair | ( | ) | const |
Get the pointer to the message pair of the SubscriptionInterface.
Definition at line 8 of file SubscriptionInterface.cpp.
void modulo_core::communication::SubscriptionInterface::set_message_pair | ( | const std::shared_ptr< MessagePairInterface > & | message_pair | ) |
Set the pointer to the message pair of the SubscriptionInterface.
modulo_core::exceptions::NullPointerException | if the provided message pair pointer is null |
Definition at line 12 of file SubscriptionInterface.cpp.
|
protected |
The pointer to the stored MessagePair instance.
Definition at line 70 of file SubscriptionInterface.hpp.