Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
roswrap::Transport Class Referenceabstract

Abstract base class that allows abstraction of the transport type, eg. TCP, shared memory, UDP... More...

#include <transport.h>

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

Public Types

typedef std::function< void(const TransportPtr &)> Callback
 

Public Member Functions

virtual void close ()=0
 Close this transport. Once this call has returned, writing on this transport should always return an error. More...
 
virtual void disableRead ()=0
 Disable reading on this transport. Allows derived classes to, for example, disable read polling for asynchronous sockets. More...
 
virtual void disableWrite ()=0
 Disable writing on this transport. Allows derived classes to, for example, disable write polling for asynchronous sockets. More...
 
virtual void enableRead ()=0
 Enable reading on this transport. Allows derived classes to, for example, enable read polling for asynchronous sockets. More...
 
virtual void enableWrite ()=0
 Enable writing on this transport. Allows derived classes to, for example, enable write polling for asynchronous sockets. More...
 
virtual std::string getTransportInfo ()=0
 Returns a string description of both the type of transport and who the transport is connected to. More...
 
virtual const char * getType ()=0
 Return a string that details the type of transport (Eg. TCPROS) More...
 
virtual void parseHeader (const Header &header)
 Provides an opportunity for transport-specific options to come in through the header. More...
 
virtual int32_t read (uint8_t *buffer, uint32_t size)=0
 Read a number of bytes into the supplied buffer. Not guaranteed to actually read that number of bytes. More...
 
virtual bool requiresHeader ()
 Returns a boolean to indicate if the transport mechanism is reliable or not. More...
 
void setDisconnectCallback (const Callback &cb)
 Set the function to call when this transport has disconnected, either through a call to close(). Or a disconnect from the remote host. More...
 
void setReadCallback (const Callback &cb)
 Set the function to call when there is data available to be read by this transport. More...
 
void setWriteCallback (const Callback &cb)
 Set the function to call when there is space available to write on this transport. More...
 
 Transport ()
 
virtual int32_t write (uint8_t *buffer, uint32_t size)=0
 Write a number of bytes from the supplied buffer. Not guaranteed to actually write that number of bytes. More...
 
virtual ~Transport ()
 

Protected Member Functions

bool isHostAllowed (const std::string &host) const
 returns true if the transport is allowed to connect to the host passed to it. More...
 
bool isOnlyLocalhostAllowed () const
 returns true if this transport is only allowed to talk to localhost More...
 

Protected Attributes

Callback disconnect_cb_
 
Callback read_cb_
 
Callback write_cb_
 

Private Attributes

std::vector< std::string > allowed_hosts_
 
bool only_localhost_allowed_
 

Detailed Description

Abstract base class that allows abstraction of the transport type, eg. TCP, shared memory, UDP...

Definition at line 56 of file transport.h.

Member Typedef Documentation

◆ Callback

typedef std::function<void(const TransportPtr&)> roswrap::Transport::Callback

Definition at line 106 of file transport.h.

Constructor & Destructor Documentation

◆ Transport()

roswrap::Transport::Transport ( )

◆ ~Transport()

virtual roswrap::Transport::~Transport ( )
inlinevirtual

Definition at line 60 of file transport.h.

Member Function Documentation

◆ close()

virtual void roswrap::Transport::close ( )
pure virtual

Close this transport. Once this call has returned, writing on this transport should always return an error.

Implemented in roswrap::TransportTCP, and roswrap::TransportUDP.

◆ disableRead()

virtual void roswrap::Transport::disableRead ( )
pure virtual

Disable reading on this transport. Allows derived classes to, for example, disable read polling for asynchronous sockets.

Implemented in roswrap::TransportTCP, and roswrap::TransportUDP.

◆ disableWrite()

virtual void roswrap::Transport::disableWrite ( )
pure virtual

Disable writing on this transport. Allows derived classes to, for example, disable write polling for asynchronous sockets.

Implemented in roswrap::TransportTCP, and roswrap::TransportUDP.

◆ enableRead()

virtual void roswrap::Transport::enableRead ( )
pure virtual

Enable reading on this transport. Allows derived classes to, for example, enable read polling for asynchronous sockets.

Implemented in roswrap::TransportTCP, and roswrap::TransportUDP.

◆ enableWrite()

virtual void roswrap::Transport::enableWrite ( )
pure virtual

Enable writing on this transport. Allows derived classes to, for example, enable write polling for asynchronous sockets.

Implemented in roswrap::TransportTCP, and roswrap::TransportUDP.

◆ getTransportInfo()

virtual std::string roswrap::Transport::getTransportInfo ( )
pure virtual

Returns a string description of both the type of transport and who the transport is connected to.

Implemented in roswrap::TransportTCP, and roswrap::TransportUDP.

◆ getType()

virtual const char* roswrap::Transport::getType ( )
pure virtual

Return a string that details the type of transport (Eg. TCPROS)

Returns
The stringified transport type

Implemented in roswrap::TransportTCP, and roswrap::TransportUDP.

◆ isHostAllowed()

bool roswrap::Transport::isHostAllowed ( const std::string &  host) const
protected

returns true if the transport is allowed to connect to the host passed to it.

◆ isOnlyLocalhostAllowed()

bool roswrap::Transport::isOnlyLocalhostAllowed ( ) const
inlineprotected

returns true if this transport is only allowed to talk to localhost

Definition at line 148 of file transport.h.

◆ parseHeader()

virtual void roswrap::Transport::parseHeader ( const Header header)
inlinevirtual

Provides an opportunity for transport-specific options to come in through the header.

Reimplemented in roswrap::TransportTCP.

Definition at line 133 of file transport.h.

◆ read()

virtual int32_t roswrap::Transport::read ( uint8_t *  buffer,
uint32_t  size 
)
pure virtual

Read a number of bytes into the supplied buffer. Not guaranteed to actually read that number of bytes.

Parameters
bufferBuffer to read from
sizeSize, in bytes, to read
Returns
The number of bytes actually read, or -1 if there was an error

Implemented in roswrap::TransportTCP, and roswrap::TransportUDP.

◆ requiresHeader()

virtual bool roswrap::Transport::requiresHeader ( )
inlinevirtual

Returns a boolean to indicate if the transport mechanism is reliable or not.

Reimplemented in roswrap::TransportUDP.

Definition at line 128 of file transport.h.

◆ setDisconnectCallback()

void roswrap::Transport::setDisconnectCallback ( const Callback cb)
inline

Set the function to call when this transport has disconnected, either through a call to close(). Or a disconnect from the remote host.

Definition at line 110 of file transport.h.

◆ setReadCallback()

void roswrap::Transport::setReadCallback ( const Callback cb)
inline

Set the function to call when there is data available to be read by this transport.

Definition at line 114 of file transport.h.

◆ setWriteCallback()

void roswrap::Transport::setWriteCallback ( const Callback cb)
inline

Set the function to call when there is space available to write on this transport.

Definition at line 118 of file transport.h.

◆ write()

virtual int32_t roswrap::Transport::write ( uint8_t *  buffer,
uint32_t  size 
)
pure virtual

Write a number of bytes from the supplied buffer. Not guaranteed to actually write that number of bytes.

Parameters
bufferBuffer to write from
sizeSize, in bytes, to write
Returns
The number of bytes actually written, or -1 if there was an error

Implemented in roswrap::TransportTCP, and roswrap::TransportUDP.

Member Data Documentation

◆ allowed_hosts_

std::vector<std::string> roswrap::Transport::allowed_hosts_
private

Definition at line 152 of file transport.h.

◆ disconnect_cb_

Callback roswrap::Transport::disconnect_cb_
protected

Definition at line 136 of file transport.h.

◆ only_localhost_allowed_

bool roswrap::Transport::only_localhost_allowed_
private

Definition at line 151 of file transport.h.

◆ read_cb_

Callback roswrap::Transport::read_cb_
protected

Definition at line 137 of file transport.h.

◆ write_cb_

Callback roswrap::Transport::write_cb_
protected

Definition at line 138 of file transport.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