Gazebo Transport

API Reference

12.2.2

Interface class used to manage a request handler. More...

#include <gz/transport/ReqHandler.hh>

Public Member Functions

 IReqHandler (const std::string &_nUuid)
 Constructor. More...
 
virtual ~IReqHandler ()=default
 Destructor. More...
 
std::string HandlerUuid () const
 Returns the unique handler UUID. More...
 
std::string NodeUuid () const
 Get the node UUID. More...
 
virtual void NotifyResult (const std::string &_rep, const bool _result)=0
 Executes the callback registered for this handler and notify a potential requester waiting on a blocking call. More...
 
virtual std::string RepTypeName () const =0
 Get the message type name used in the service response. More...
 
virtual std::string ReqTypeName () const =0
 Get the message type name used in the service request. More...
 
bool Requested () const
 Returns if this service call request has already been requested. More...
 
void Requested (const bool _value)
 Mark the service call as requested (or not). More...
 
std::string Response () const
 Get the service response as raw bytes. More...
 
bool Result () const
 Get the result of the service response. More...
 
virtual bool Serialize (std::string &_buffer) const =0
 Serialize the Req protobuf message stored. More...
 
template<typename Lock >
bool WaitUntil (Lock &_lock, const unsigned int _timeout)
 Block the current thread until the response to the service request is available or until the timeout expires. This method uses a condition variable to notify when the response is available. More...
 

Public Attributes

bool repAvailable
 When there is a blocking service call request, the call can be unlocked when a service call REP is available. This variable captures if we have found a node that can satisty our request. More...
 

Protected Attributes

std::condition_variable_any condition
 Condition variable used to wait until a service call REP is available. More...
 
std::string hUuid
 Unique handler's UUID. More...
 
std::string rep
 Stores the service response as raw bytes. More...
 
bool result
 Stores the result of the service call. More...
 

Detailed Description

Interface class used to manage a request handler.

Constructor & Destructor Documentation

◆ IReqHandler()

IReqHandler ( const std::string _nUuid)
inlineexplicit

Constructor.

Parameters
[in]_nUuidUUID of the node registering the request handler.

◆ ~IReqHandler()

virtual ~IReqHandler ( )
virtualdefault

Destructor.

Member Function Documentation

◆ HandlerUuid()

std::string HandlerUuid ( ) const
inline

Returns the unique handler UUID.

Returns
The handler's UUID.

References IReqHandler::hUuid.

◆ NodeUuid()

std::string NodeUuid ( ) const
inline

Get the node UUID.

Returns
The string representation of the node UUID.

◆ NotifyResult()

virtual void NotifyResult ( const std::string _rep,
const bool  _result 
)
pure virtual

Executes the callback registered for this handler and notify a potential requester waiting on a blocking call.

Parameters
[in]_repSerialized data containing the response coming from the service call responser.
[in]_resultContains the result of the service call coming from the service call responser.

Implemented in ReqHandler< google::protobuf::Message, google::protobuf::Message >, and ReqHandler< Req, Rep >.

◆ RepTypeName()

virtual std::string RepTypeName ( ) const
pure virtual

Get the message type name used in the service response.

Returns
Message type name.

Implemented in ReqHandler< google::protobuf::Message, google::protobuf::Message >, and ReqHandler< Req, Rep >.

◆ ReqTypeName()

virtual std::string ReqTypeName ( ) const
pure virtual

Get the message type name used in the service request.

Returns
Message type name.

Implemented in ReqHandler< google::protobuf::Message, google::protobuf::Message >, and ReqHandler< Req, Rep >.

◆ Requested() [1/2]

bool Requested ( ) const
inline

Returns if this service call request has already been requested.

Returns
True when the service call has been requested.

◆ Requested() [2/2]

void Requested ( const bool  _value)
inline

Mark the service call as requested (or not).

Parameters
[in]_valuetrue when you want to flag this REQ as requested.

◆ Response()

std::string Response ( ) const
inline

Get the service response as raw bytes.

Returns
The string containing the service response.

References IReqHandler::rep.

◆ Result()

bool Result ( ) const
inline

Get the result of the service response.

Returns
The boolean result.

References IReqHandler::result.

◆ Serialize()

virtual bool Serialize ( std::string _buffer) const
pure virtual

Serialize the Req protobuf message stored.

Parameters
[out]_bufferThe serialized data.
Returns
True if the serialization succeed or false otherwise.

Implemented in ReqHandler< google::protobuf::Message, google::protobuf::Message >, and ReqHandler< Req, Rep >.

◆ WaitUntil()

bool WaitUntil ( Lock &  _lock,
const unsigned int  _timeout 
)
inline

Block the current thread until the response to the service request is available or until the timeout expires. This method uses a condition variable to notify when the response is available.

Parameters
[in]_lockLock used to protect the condition variable.
[in]_timeoutMaximum waiting time in milliseconds.
Returns
True if the service call was executed or false otherwise.

References IReqHandler::condition, steady_clock::now(), IReqHandler::repAvailable, and condition_variable_any::wait_until().

Member Data Documentation

◆ condition

std::condition_variable_any condition
protected

Condition variable used to wait until a service call REP is available.

Referenced by ReqHandler< Req, Rep >::NotifyResult(), ReqHandler< google::protobuf::Message, google::protobuf::Message >::NotifyResult(), and IReqHandler::WaitUntil().

◆ hUuid

std::string hUuid
protected

Unique handler's UUID.

Referenced by IReqHandler::HandlerUuid().

◆ rep

◆ repAvailable

bool repAvailable

When there is a blocking service call request, the call can be unlocked when a service call REP is available. This variable captures if we have found a node that can satisty our request.

Referenced by ReqHandler< Req, Rep >::NotifyResult(), ReqHandler< google::protobuf::Message, google::protobuf::Message >::NotifyResult(), and IReqHandler::WaitUntil().

◆ result


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