Gazebo Transport

API Reference

14.0.0
SubscriptionHandler< T > Class Template Reference

It creates a subscription handler for a specific protobuf message. 'T' is the Protobuf message type that will be used for this particular handler. More...

#include <SubscriptionHandler.hh>

Public Member Functions

 SubscriptionHandler (const std::string &_nUuid, const SubscribeOptions &_opts=SubscribeOptions())
 
const std::shared_ptr< ProtoMsgCreateMsg (const std::string &_data, const std::string &) const
 Create a specific protobuf message given its serialized data.
 
bool RunLocalCallback (const ProtoMsg &_msg, const MessageInfo &_info)
 Executes the local callback registered for this handler.
 
void SetCallback (const MsgCallback< T > &_cb)
 Set the callback for this handler.
 
std::string TypeName ()
 Get the type of the messages from which this subscriber handler is subscribed.
 
- Public Member Functions inherited from ISubscriptionHandler
 ISubscriptionHandler (const std::string &_nUuid, const SubscribeOptions &_opts=SubscribeOptions())
 Constructor.
 
virtual ~ISubscriptionHandler ()=default
 Destructor.
 
- Public Member Functions inherited from SubscriptionHandlerBase
 SubscriptionHandlerBase (const std::string &_nUuid, const SubscribeOptions &_opts=SubscribeOptions())
 Constructor.
 
virtual ~SubscriptionHandlerBase ()=default
 Destructor.
 
std::string HandlerUuid () const
 Get the unique UUID of this handler.
 
bool IgnoreLocalMessages () const
 Return whether local messages are ignored or not.
 
std::string NodeUuid () const
 Get the node UUID.
 

Additional Inherited Members

- Protected Member Functions inherited from SubscriptionHandlerBase
bool UpdateThrottling ()
 Check if message subscription is throttled. If so, verify whether the callback should be executed or not.
 
- Protected Attributes inherited from SubscriptionHandlerBase
std::string hUuid
 Unique handler's UUID.
 
Timestamp lastCbTimestamp
 Timestamp of the last callback executed.
 
SubscribeOptions opts
 Subscribe options.
 
double periodNs
 If throttling is enabled, the minimum period for receiving a message in nanoseconds.
 

Detailed Description

template<typename T>
class gz::transport::SubscriptionHandler< T >

It creates a subscription handler for a specific protobuf message. 'T' is the Protobuf message type that will be used for this particular handler.

Constructor & Destructor Documentation

◆ SubscriptionHandler()

template<typename T >
SubscriptionHandler ( const std::string _nUuid,
const SubscribeOptions _opts = SubscribeOptions() 
)
inlineexplicit

Member Function Documentation

◆ CreateMsg()

template<typename T >
const std::shared_ptr< ProtoMsg > CreateMsg ( const std::string _data,
const std::string _type 
) const
inlinevirtual

Create a specific protobuf message given its serialized data.

Parameters
[in]_dataThe serialized data.
[in]_typeThe data type.
Returns
Pointer to the specific protobuf message.

Implements ISubscriptionHandler.

References std::endl().

◆ RunLocalCallback()

template<typename T >
bool RunLocalCallback ( const ProtoMsg _msg,
const MessageInfo _info 
)
inlinevirtual

Executes the local callback registered for this handler.

Parameters
[in]_msgProtobuf message received.
[in]_infoMessage information (e.g.: topic name).
Returns
True when success, false otherwise.

Implements ISubscriptionHandler.

References std::endl(), and SubscriptionHandlerBase::UpdateThrottling().

◆ SetCallback()

template<typename T >
void SetCallback ( const MsgCallback< T > &  _cb)
inline

Set the callback for this handler.

Parameters
[in]_cbThe callback with the following parameters:

◆ TypeName()

template<typename T >
std::string TypeName ( )
inlinevirtual

Get the type of the messages from which this subscriber handler is subscribed.

Returns
String representation of the message type.

Implements SubscriptionHandlerBase.


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