It creates a reply handler for the specific protobuf messages used. 'Req' is a protobuf message type containing the input parameters of the service request. 'Rep' is a protobuf message type that will be filled with the service response. More...
#include <ReqHandler.hh>
Public Member Functions | |
| ReqHandler (const std::string &_nUuid) | |
| std::shared_ptr< Rep > | CreateMsg (const std::string &_data) const | 
| Create a specific protobuf message given its serialized data.   | |
| void | NotifyResult (const std::string &_rep, const bool _result) | 
| Executes the callback registered for this handler and notify a potential requester waiting on a blocking call.   | |
| virtual std::string | RepTypeName () const | 
| Get the message type name used in the service response.   | |
| virtual std::string | ReqTypeName () const | 
| Get the message type name used in the service request.   | |
| bool | Serialize (std::string &_buffer) const | 
| Serialize the Req protobuf message stored.   | |
| void | SetCallback (const std::function< void(const Rep &_rep, const bool _result)> &_cb) | 
| Set the callback for this handler.   | |
| void | SetMessage (const Req *_reqMsg) | 
| Set the REQ protobuf message for this handler.   | |
| void | SetResponse (const Rep *_repMsg) | 
| This function is only used for compatibility with SetResponse() when [REP = google::protobuf::Message]. It shouldn't do anything.   | |
  Public Member Functions inherited from IReqHandler | |
| IReqHandler (const std::string &_nUuid) | |
| Constructor.   | |
| virtual | ~IReqHandler () | 
| Destructor.   | |
| std::string | HandlerUuid () const | 
| Returns the unique handler UUID.   | |
| std::string | NodeUuid () const | 
| Get the node UUID.   | |
| bool | Requested () const | 
| Returns if this service call request has already been requested.   | |
| void | Requested (const bool _value) | 
| Mark the service call as requested (or not).   | |
| std::string | Response () const | 
| Get the service response as raw bytes.   | |
| bool | Result () const | 
| Get the result of the service response.   | |
| 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.   | |
Additional Inherited Members | |
  Public Attributes inherited from IReqHandler | |
| 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 satisfy our request.   | |
  Protected Attributes inherited from IReqHandler | |
| std::condition_variable_any | condition | 
| Condition variable used to wait until a service call REP is available.   | |
| std::unique_ptr< IReqHandlerPrivate > | dataPtr | 
| Private data.   | |
| std::string | rep | 
| Stores the service response as raw bytes.   | |
| bool | result | 
| Stores the result of the service call.   | |
Detailed Description
class gz::transport::ReqHandler< Req, Rep >
It creates a reply handler for the specific protobuf messages used. 'Req' is a protobuf message type containing the input parameters of the service request. 'Rep' is a protobuf message type that will be filled with the service response.
Constructor & Destructor Documentation
◆ ReqHandler()
      
  | 
  inlineexplicit | 
Member Function Documentation
◆ CreateMsg()
      
  | 
  inline | 
Create a specific protobuf message given its serialized data.
- Parameters
 - 
  
[in] _data The serialized data.  
- Returns
 - Pointer to the specific protobuf message.
 
References std::endl().
Referenced by ReqHandler< Req, Rep >::NotifyResult().
◆ NotifyResult()
      
  | 
  inlinevirtual | 
Executes the callback registered for this handler and notify a potential requester waiting on a blocking call.
- Parameters
 - 
  
[in] _rep Serialized data containing the response coming from the service call responser. [in] _result Contains the result of the service call coming from the service call responser.  
Implements IReqHandler.
References IReqHandler::condition, ReqHandler< Req, Rep >::CreateMsg(), condition_variable_any::notify_one(), IReqHandler::rep, IReqHandler::repAvailable, and IReqHandler::result.
◆ RepTypeName()
      
  | 
  inlinevirtual | 
Get the message type name used in the service response.
- Returns
 - Message type name.
 
Implements IReqHandler.
◆ ReqTypeName()
      
  | 
  inlinevirtual | 
Get the message type name used in the service request.
- Returns
 - Message type name.
 
Implements IReqHandler.
◆ Serialize()
      
  | 
  inlinevirtual | 
Serialize the Req protobuf message stored.
- Parameters
 - 
  
[out] _buffer The serialized data.  
- Returns
 - True if the serialization succeed or false otherwise.
 
Implements IReqHandler.
References std::endl().
◆ SetCallback()
      
  | 
  inline | 
Set the callback for this handler.
- Parameters
 - 
  
[in] _cb The callback with the following parameters: - _rep Protobuf message containing the service response.
 - _result True when the service request was successful or false otherwise.
 
 
◆ SetMessage()
      
  | 
  inline | 
Set the REQ protobuf message for this handler.
- Parameters
 - 
  
[in] _reqMsg Protobuf message containing the input parameters of of the service request.  
References std::endl().
◆ SetResponse()
      
  | 
  inline | 
This function is only used for compatibility with SetResponse() when [REP = google::protobuf::Message]. It shouldn't do anything.
- Parameters
 - 
  
[in] _repMsg Protobuf message containing the variable where the result will be stored.  
The documentation for this class was generated from the following file:
 Public Member Functions inherited from