Gazebo Transport

API Reference

11.4.1
SubscriptionHandler< ProtoMsg > Class Reference

Specialized template when the user prefers a callbacks that accepts a generic google::protobuf::message instead of a specific type. 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 &_type) const
 Create a specific protobuf message given its serialized data. More...
 
bool RunLocalCallback (const ProtoMsg &_msg, const MessageInfo &_info)
 Executes the local callback registered for this handler. More...
 
void SetCallback (const MsgCallback< ProtoMsg > &_cb)
 Set the callback for this handler. More...
 
std::string TypeName ()
 Get the type of the messages from which this subscriber handler is subscribed. More...
 
- Public Member Functions inherited from ISubscriptionHandler
 ISubscriptionHandler (const std::string &_nUuid, const SubscribeOptions &_opts=SubscribeOptions())
 Constructor. More...
 
virtual ~ISubscriptionHandler ()=default
 Destructor. More...
 
- Public Member Functions inherited from SubscriptionHandlerBase
 SubscriptionHandlerBase (const std::string &_nUuid, const SubscribeOptions &_opts=SubscribeOptions())
 Constructor. More...
 
virtual ~SubscriptionHandlerBase ()=default
 Destructor. More...
 
std::string HandlerUuid () const
 Get the unique UUID of this handler. More...
 
std::string NodeUuid () const
 Get the node UUID. More...
 

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. More...
 
- Protected Attributes inherited from SubscriptionHandlerBase
std::string hUuid
 Unique handler's UUID. More...
 
Timestamp lastCbTimestamp
 Timestamp of the last callback executed. More...
 
SubscribeOptions opts
 Subscribe options. More...
 
double periodNs
 If throttling is enabled, the minimum period for receiving a message in nanoseconds. More...
 

Detailed Description

Specialized template when the user prefers a callbacks that accepts a generic google::protobuf::message instead of a specific type.

Constructor & Destructor Documentation

◆ SubscriptionHandler()

SubscriptionHandler ( const std::string _nUuid,
const SubscribeOptions _opts = SubscribeOptions() 
)
inlineexplicit

Member Function Documentation

◆ CreateMsg()

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(), and shared_ptr< T >::reset().

◆ RunLocalCallback()

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()

void SetCallback ( const MsgCallback< ProtoMsg > &  _cb)
inline

Set the callback for this handler.

Parameters
[in]_cbThe callback.

◆ TypeName()

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.

References ignition::transport::kGenericMessageType.


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