Modulo 5.0.0
Loading...
Searching...
No Matches
Public Member Functions | List of all members
modulo_core::communication::PublisherHandler< PubT, MsgT > Class Template Reference

The PublisherHandler handles different types of ROS publishers to activate, deactivate and publish data with those publishers. More...

#include <PublisherHandler.hpp>

Inheritance diagram for modulo_core::communication::PublisherHandler< PubT, MsgT >:
modulo_core::communication::PublisherInterface

Public Member Functions

 PublisherHandler (PublisherType type, std::shared_ptr< PubT > publisher)
 Constructor with the publisher type and the pointer to the ROS publisher.
 
 ~PublisherHandler () override
 Destructor to explicitly reset the publisher pointer.
 
virtual void activate () override
 Activate ROS publisher of a derived PublisherHandler instance through the PublisherInterface pointer.
 
virtual void deactivate () override
 Deactivate ROS publisher of a derived PublisherHandler instance through the PublisherInterface pointer.
 
void publish () override
 Publish the data stored in the message pair through the ROS publisher of a derived PublisherHandler instance through the PublisherInterface pointer.
 
void publish (const MsgT &message) const
 Publish the ROS message through the ROS publisher.
 
std::shared_ptr< PublisherInterfacecreate_publisher_interface (const std::shared_ptr< MessagePairInterface > &message_pair)
 Create a PublisherInterface instance from the current PublisherHandler.
 
- Public Member Functions inherited from modulo_core::communication::PublisherInterface
 PublisherInterface (PublisherType type, std::shared_ptr< MessagePairInterface > message_pair=nullptr)
 Constructor with the message type and message pair.
 
 PublisherInterface (const PublisherInterface &publisher)=default
 Copy constructor from another PublisherInterface.
 
virtual ~PublisherInterface ()=default
 Default virtual destructor.
 
template<typename PubT , typename MsgT >
std::shared_ptr< PublisherHandler< PubT, MsgT > > get_handler (bool validate_pointer=true)
 Get a pointer to a derived PublisherHandler instance from a PublisherInterface pointer.
 
std::shared_ptr< MessagePairInterfaceget_message_pair () const
 Get the pointer to the message pair of the PublisherInterface.
 
void set_message_pair (const std::shared_ptr< MessagePairInterface > &message_pair)
 Set the pointer to the message pair of the PublisherInterface.
 
PublisherType get_type () const
 Get the type of the publisher interface.
 

Additional Inherited Members

- Protected Attributes inherited from modulo_core::communication::PublisherInterface
std::shared_ptr< MessagePairInterfacemessage_pair_
 The pointer to the stored MessagePair instance.
 

Detailed Description

template<typename PubT, typename MsgT>
class modulo_core::communication::PublisherHandler< PubT, MsgT >

The PublisherHandler handles different types of ROS publishers to activate, deactivate and publish data with those publishers.

Template Parameters
PubTThe ROS publisher type
MsgTThe ROS message type of the ROS publisher

Definition at line 19 of file PublisherHandler.hpp.

Constructor & Destructor Documentation

◆ PublisherHandler()

template<typename PubT , typename MsgT >
modulo_core::communication::PublisherHandler< PubT, MsgT >::PublisherHandler ( PublisherType  type,
std::shared_ptr< PubT >  publisher 
)

Constructor with the publisher type and the pointer to the ROS publisher.

Parameters
typeThe publisher type
publisherThe pointer to the ROS publisher

Definition at line 69 of file PublisherHandler.hpp.

◆ ~PublisherHandler()

template<typename PubT , typename MsgT >
modulo_core::communication::PublisherHandler< PubT, MsgT >::~PublisherHandler ( )
override

Destructor to explicitly reset the publisher pointer.

Definition at line 73 of file PublisherHandler.hpp.

Member Function Documentation

◆ activate()

template<typename PubT , typename MsgT >
void modulo_core::communication::PublisherHandler< PubT, MsgT >::activate ( )
inlineoverridevirtual

Activate ROS publisher of a derived PublisherHandler instance through the PublisherInterface pointer.

This throws an InvalidPointerCastException if the PublisherInterface does not point to a valid PublisherHandler instance or if the type of the message pair does not match the type of the PublisherHandler instance.

See also
PublisherInterface::get_handler
Exceptions
modulo_core::exceptions::NullPointerExceptionif the message pair pointer is null

Reimplemented from modulo_core::communication::PublisherInterface.

Definition at line 78 of file PublisherHandler.hpp.

◆ create_publisher_interface()

template<typename PubT , typename MsgT >
std::shared_ptr< PublisherInterface > modulo_core::communication::PublisherHandler< PubT, MsgT >::create_publisher_interface ( const std::shared_ptr< MessagePairInterface > &  message_pair)
inline

Create a PublisherInterface instance from the current PublisherHandler.

Parameters
message_pairThe message pair of the PublisherInterface

Definition at line 135 of file PublisherHandler.hpp.

◆ deactivate()

template<typename PubT , typename MsgT >
void modulo_core::communication::PublisherHandler< PubT, MsgT >::deactivate ( )
inlineoverridevirtual

Deactivate ROS publisher of a derived PublisherHandler instance through the PublisherInterface pointer.

This throws an InvalidPointerCastException if the PublisherInterface does not point to a valid PublisherHandler instance or if the type of the message pair does not match the type of the PublisherHandler instance.

See also
PublisherInterface::get_handler
Exceptions
modulo_core::exceptions::NullPointerExceptionif the message pair pointer is null

Reimplemented from modulo_core::communication::PublisherInterface.

Definition at line 92 of file PublisherHandler.hpp.

◆ publish() [1/2]

template<typename PubT , typename MsgT >
void modulo_core::communication::PublisherHandler< PubT, MsgT >::publish ( )
inlineoverridevirtual

Publish the data stored in the message pair through the ROS publisher of a derived PublisherHandler instance through the PublisherInterface pointer.

This throws an InvalidPointerCastException if the PublisherInterface does not point to a valid PublisherHandler instance or if the type of the message pair does not match the type of the PublisherHandler instance.

See also
PublisherInterface::get_handler
Exceptions
modulo_core::exceptions::CoreExceptionif the publishing failed for some reason (translation, null pointer, pointer cast, ...)

Reimplemented from modulo_core::communication::PublisherInterface.

Definition at line 106 of file PublisherHandler.hpp.

◆ publish() [2/2]

template<typename PubT , typename MsgT >
void modulo_core::communication::PublisherHandler< PubT, MsgT >::publish ( const MsgT &  message) const

Publish the ROS message through the ROS publisher.

Parameters
messageThe ROS message to publish
Exceptions
modulo_core::exceptions::NullPointerExceptionif the publisher pointer is null

Definition at line 122 of file PublisherHandler.hpp.


The documentation for this class was generated from the following file: