All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Public Attributes | Protected Attributes | List of all members
ignition::transport::IReqHandler Class Referenceabstract

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

#include <ignition/transport/ReqHandler.hh>

Inheritance diagram for ignition::transport::IReqHandler:
Inheritance graph
[legend]

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. 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. 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

ignition::transport::IReqHandler::IReqHandler ( const std::string &  _nUuid)
inlineexplicit

Constructor.

Parameters
[in]_nUuidUUID of the node registering the request handler.
virtual ignition::transport::IReqHandler::~IReqHandler ( )
virtualdefault

Destructor.

Member Function Documentation

std::string ignition::transport::IReqHandler::HandlerUuid ( ) const
inline

Returns the unique handler UUID.

Returns
The handler's UUID.
std::string ignition::transport::IReqHandler::NodeUuid ( ) const
inline

Get the node UUID.

Returns
The string representation of the node UUID.
virtual void ignition::transport::IReqHandler::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 ignition::transport::ReqHandler< google::protobuf::Message, google::protobuf::Message >, and ignition::transport::ReqHandler< Req, Rep >.

virtual std::string ignition::transport::IReqHandler::RepTypeName ( ) const
pure virtual

Get the message type name used in the service response.

Returns
Message type name.

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

virtual std::string ignition::transport::IReqHandler::ReqTypeName ( ) const
pure virtual

Get the message type name used in the service request.

Returns
Message type name.

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

bool ignition::transport::IReqHandler::Requested ( ) const
inline

Returns if this service call request has already been requested.

Returns
True when the service call has been requested.
void ignition::transport::IReqHandler::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.
std::string ignition::transport::IReqHandler::Response ( ) const
inline

Get the service response as raw bytes.

Returns
The string containing the service response.
bool ignition::transport::IReqHandler::Result ( ) const
inline

Get the result of the service response.

Returns
The boolean result.
virtual bool ignition::transport::IReqHandler::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 ignition::transport::ReqHandler< google::protobuf::Message, google::protobuf::Message >, and ignition::transport::ReqHandler< Req, Rep >.

template<typename Lock >
bool ignition::transport::IReqHandler::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.

Member Data Documentation

std::condition_variable_any ignition::transport::IReqHandler::condition
protected
std::string ignition::transport::IReqHandler::hUuid
protected

Unique handler's UUID.

std::string ignition::transport::IReqHandler::rep
protected
bool ignition::transport::IReqHandler::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 ignition::transport::ReqHandler< Req, Rep >::NotifyResult(), and ignition::transport::ReqHandler< google::protobuf::Message, google::protobuf::Message >::NotifyResult().

bool ignition::transport::IReqHandler::result
protected

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