Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
roswrap::ServiceServerLink Class Reference

Handles a connection to a service. If it's a non-persistent client, automatically disconnects when its first service call has finished. More...

#include <service_server_link.h>

Inheritance diagram for roswrap::ServiceServerLink:
Inheritance graph
[legend]

Classes

struct  CallInfo
 

Public Types

typedef std::map< std::string, std::string > M_string
 

Public Member Functions

bool call (const SerializedMessage &req, SerializedMessage &resp)
 Blocking call the service this client is connected to. More...
 
const ConnectionPtrgetConnection () const
 
const std::string & getRequestMD5Sum () const
 
const std::string & getResponseMD5Sum () const
 
const std::string & getServiceName () const
 
bool initialize (const ConnectionPtr &connection)
 
bool isPersistent () const
 Returns whether this is a persistent connection. More...
 
bool isValid () const
 Returns whether this client is still valid, ie. its connection has not been dropped. More...
 
 ServiceServerLink (const std::string &service_name, bool persistent, const std::string &request_md5sum, const std::string &response_md5sum, const M_string &header_values)
 
virtual ~ServiceServerLink ()
 

Private Types

typedef std::shared_ptr< CallInfoCallInfoPtr
 
typedef std::queue< CallInfoPtrQ_CallInfo
 

Private Member Functions

void callFinished ()
 Called when the currently queued call has finished. Clears out the current call, notifying it that it has finished, then calls processNextCall() More...
 
void cancelCall (const CallInfoPtr &info)
 Cancel a queued call, notifying it that it has failed. More...
 
void clearCalls ()
 Clear all calls, notifying them that they've failed. More...
 
void onConnectionDropped (const ConnectionPtr &conn)
 
bool onHeaderReceived (const ConnectionPtr &conn, const Header &header)
 
void onHeaderWritten (const ConnectionPtr &conn)
 
void onRequestWritten (const ConnectionPtr &conn)
 
void onResponse (const ConnectionPtr &conn, const boost::shared_array< uint8_t > &buffer, uint32_t size, bool success)
 
void onResponseOkAndLength (const ConnectionPtr &conn, const boost::shared_array< uint8_t > &buffer, uint32_t size, bool success)
 
void processNextCall ()
 Pops the next call off the queue if one is available. If this is a non-persistent connection and the queue is empty it will also drop the connection. More...
 

Private Attributes

Q_CallInfo call_queue_
 
std::mutex call_queue_mutex_
 
ConnectionPtr connection_
 
CallInfoPtr current_call_
 
bool dropped_
 
M_string extra_outgoing_header_values_
 
bool header_read_
 
bool header_written_
 
bool persistent_
 
std::string request_md5sum_
 
std::string response_md5sum_
 
std::string service_name_
 

Detailed Description

Handles a connection to a service. If it's a non-persistent client, automatically disconnects when its first service call has finished.

Definition at line 59 of file service_server_link.h.

Member Typedef Documentation

◆ CallInfoPtr

typedef std::shared_ptr<CallInfo> roswrap::ServiceServerLink::CallInfoPtr
private

Definition at line 77 of file service_server_link.h.

◆ M_string

typedef std::map<std::string, std::string> roswrap::ServiceServerLink::M_string

Definition at line 81 of file service_server_link.h.

◆ Q_CallInfo

Definition at line 78 of file service_server_link.h.

Constructor & Destructor Documentation

◆ ServiceServerLink()

roswrap::ServiceServerLink::ServiceServerLink ( const std::string &  service_name,
bool  persistent,
const std::string &  request_md5sum,
const std::string &  response_md5sum,
const M_string header_values 
)

◆ ~ServiceServerLink()

virtual roswrap::ServiceServerLink::~ServiceServerLink ( )
virtual

Member Function Documentation

◆ call()

bool roswrap::ServiceServerLink::call ( const SerializedMessage req,
SerializedMessage resp 
)

Blocking call the service this client is connected to.

If there is already a call happening in another thread, this will queue up the call and still block until it has finished.

◆ callFinished()

void roswrap::ServiceServerLink::callFinished ( )
private

Called when the currently queued call has finished. Clears out the current call, notifying it that it has finished, then calls processNextCall()

◆ cancelCall()

void roswrap::ServiceServerLink::cancelCall ( const CallInfoPtr info)
private

Cancel a queued call, notifying it that it has failed.

◆ clearCalls()

void roswrap::ServiceServerLink::clearCalls ( )
private

Clear all calls, notifying them that they've failed.

◆ getConnection()

const ConnectionPtr& roswrap::ServiceServerLink::getConnection ( ) const
inline

Definition at line 97 of file service_server_link.h.

◆ getRequestMD5Sum()

const std::string& roswrap::ServiceServerLink::getRequestMD5Sum ( ) const
inline

Definition at line 100 of file service_server_link.h.

◆ getResponseMD5Sum()

const std::string& roswrap::ServiceServerLink::getResponseMD5Sum ( ) const
inline

Definition at line 101 of file service_server_link.h.

◆ getServiceName()

const std::string& roswrap::ServiceServerLink::getServiceName ( ) const
inline

Definition at line 99 of file service_server_link.h.

◆ initialize()

bool roswrap::ServiceServerLink::initialize ( const ConnectionPtr connection)

◆ isPersistent()

bool roswrap::ServiceServerLink::isPersistent ( ) const
inline

Returns whether this is a persistent connection.

Definition at line 95 of file service_server_link.h.

◆ isValid()

bool roswrap::ServiceServerLink::isValid ( ) const

Returns whether this client is still valid, ie. its connection has not been dropped.

◆ onConnectionDropped()

void roswrap::ServiceServerLink::onConnectionDropped ( const ConnectionPtr conn)
private

◆ onHeaderReceived()

bool roswrap::ServiceServerLink::onHeaderReceived ( const ConnectionPtr conn,
const Header header 
)
private

◆ onHeaderWritten()

void roswrap::ServiceServerLink::onHeaderWritten ( const ConnectionPtr conn)
private

◆ onRequestWritten()

void roswrap::ServiceServerLink::onRequestWritten ( const ConnectionPtr conn)
private

◆ onResponse()

void roswrap::ServiceServerLink::onResponse ( const ConnectionPtr conn,
const boost::shared_array< uint8_t > &  buffer,
uint32_t  size,
bool  success 
)
private

◆ onResponseOkAndLength()

void roswrap::ServiceServerLink::onResponseOkAndLength ( const ConnectionPtr conn,
const boost::shared_array< uint8_t > &  buffer,
uint32_t  size,
bool  success 
)
private

◆ processNextCall()

void roswrap::ServiceServerLink::processNextCall ( )
private

Pops the next call off the queue if one is available. If this is a non-persistent connection and the queue is empty it will also drop the connection.

Member Data Documentation

◆ call_queue_

Q_CallInfo roswrap::ServiceServerLink::call_queue_
private

Definition at line 149 of file service_server_link.h.

◆ call_queue_mutex_

std::mutex roswrap::ServiceServerLink::call_queue_mutex_
private

Definition at line 150 of file service_server_link.h.

◆ connection_

ConnectionPtr roswrap::ServiceServerLink::connection_
private

Definition at line 139 of file service_server_link.h.

◆ current_call_

CallInfoPtr roswrap::ServiceServerLink::current_call_
private

Definition at line 152 of file service_server_link.h.

◆ dropped_

bool roswrap::ServiceServerLink::dropped_
private

Definition at line 154 of file service_server_link.h.

◆ extra_outgoing_header_values_

M_string roswrap::ServiceServerLink::extra_outgoing_header_values_
private

Definition at line 145 of file service_server_link.h.

◆ header_read_

bool roswrap::ServiceServerLink::header_read_
private

Definition at line 147 of file service_server_link.h.

◆ header_written_

bool roswrap::ServiceServerLink::header_written_
private

Definition at line 146 of file service_server_link.h.

◆ persistent_

bool roswrap::ServiceServerLink::persistent_
private

Definition at line 141 of file service_server_link.h.

◆ request_md5sum_

std::string roswrap::ServiceServerLink::request_md5sum_
private

Definition at line 142 of file service_server_link.h.

◆ response_md5sum_

std::string roswrap::ServiceServerLink::response_md5sum_
private

Definition at line 143 of file service_server_link.h.

◆ service_name_

std::string roswrap::ServiceServerLink::service_name_
private

Definition at line 140 of file service_server_link.h.


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


sick_scan_xd
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Fri Oct 25 2024 02:47:15