Interface class to enable non-templated subscriptions with ROS subscriptions from derived SubscriptionHandler instances through dynamic down-casting.
More...
#include <SubscriptionInterface.hpp>
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.
◆ SubscriptionInterface()
modulo_core::communication::SubscriptionInterface::SubscriptionInterface |
( |
std::shared_ptr< MessagePairInterface > | message_pair = nullptr | ) |
|
|
explicit |
Constructor with the message pair.
- Parameters
-
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.
◆ get_handler()
template<typename MsgT >
std::shared_ptr< SubscriptionHandler< MsgT > > modulo_core::communication::SubscriptionInterface::get_handler |
( |
bool | validate_pointer = true | ) |
|
|
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.
- Template Parameters
-
PubT | The ROS publisher type |
MsgT | The ROS message type |
- Exceptions
-
- Parameters
-
validate_pointer | If true, throw an exception when down-casting fails |
- Returns
- A pointer to a derived SubscriptionHandler instance of the desired type, or a null pointer if down-casting failed and validate_pointer was set to false.
Definition at line 74 of file SubscriptionInterface.hpp.
◆ get_message_pair()
std::shared_ptr< MessagePairInterface > modulo_core::communication::SubscriptionInterface::get_message_pair |
( |
| ) |
const |
|
nodiscard |
◆ set_message_pair()
void modulo_core::communication::SubscriptionInterface::set_message_pair |
( |
const std::shared_ptr< MessagePairInterface > & | message_pair | ) |
|
◆ message_pair_
std::shared_ptr<MessagePairInterface> modulo_core::communication::SubscriptionInterface::message_pair_ |
|
protected |
The documentation for this class was generated from the following files: