Abstract base class that allows abstraction of the transport type, eg. TCP, shared memory, UDP... More...
#include <transport.h>
Public Types | |
typedef boost::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. | |
virtual void | disableRead ()=0 |
Disable reading on this transport. Allows derived classes to, for example, disable read polling for asynchronous sockets. | |
virtual void | disableWrite ()=0 |
Disable writing on this transport. Allows derived classes to, for example, disable write polling for asynchronous sockets. | |
virtual void | enableRead ()=0 |
Enable reading on this transport. Allows derived classes to, for example, enable read polling for asynchronous sockets. | |
virtual void | enableWrite ()=0 |
Enable writing on this transport. Allows derived classes to, for example, enable write polling for asynchronous sockets. | |
virtual std::string | getTransportInfo ()=0 |
Returns a string description of both the type of transport and who the transport is connected to. | |
virtual const char * | getType ()=0 |
Return a string that details the type of transport (Eg. TCPROS) | |
virtual void | parseHeader (const Header &header) |
Provides an opportunity for transport-specific options to come in through the header. | |
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. | |
virtual bool | requiresHeader () |
Returns a boolean to indicate if the transport mechanism is reliable or not. | |
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. | |
void | setReadCallback (const Callback &cb) |
Set the function to call when there is data available to be read by this transport. | |
void | setWriteCallback (const Callback &cb) |
Set the function to call when there is space available to write on this transport. | |
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. | |
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. | |
bool | isOnlyLocalhostAllowed () const |
returns true if this transport is only allowed to talk to localhost | |
Protected Attributes | |
Callback | disconnect_cb_ |
Callback | read_cb_ |
Callback | write_cb_ |
Private Attributes | |
std::vector< std::string > | allowed_hosts_ |
bool | only_localhost_allowed_ |
Abstract base class that allows abstraction of the transport type, eg. TCP, shared memory, UDP...
Definition at line 55 of file transport.h.
typedef boost::function<void(const TransportPtr&)> ros::Transport::Callback |
Definition at line 105 of file transport.h.
Definition at line 52 of file transport.cpp.
virtual ros::Transport::~Transport | ( | ) | [inline, virtual] |
Definition at line 59 of file transport.h.
virtual void ros::Transport::close | ( | ) | [pure virtual] |
Close this transport. Once this call has returned, writing on this transport should always return an error.
Implemented in ros::TransportTCP, and ros::TransportUDP.
virtual void ros::Transport::disableRead | ( | ) | [pure virtual] |
Disable reading on this transport. Allows derived classes to, for example, disable read polling for asynchronous sockets.
Implemented in ros::TransportTCP, and ros::TransportUDP.
virtual void ros::Transport::disableWrite | ( | ) | [pure virtual] |
Disable writing on this transport. Allows derived classes to, for example, disable write polling for asynchronous sockets.
Implemented in ros::TransportTCP, and ros::TransportUDP.
virtual void ros::Transport::enableRead | ( | ) | [pure virtual] |
Enable reading on this transport. Allows derived classes to, for example, enable read polling for asynchronous sockets.
Implemented in ros::TransportTCP, and ros::TransportUDP.
virtual void ros::Transport::enableWrite | ( | ) | [pure virtual] |
Enable writing on this transport. Allows derived classes to, for example, enable write polling for asynchronous sockets.
Implemented in ros::TransportTCP, and ros::TransportUDP.
virtual std::string ros::Transport::getTransportInfo | ( | ) | [pure virtual] |
Returns a string description of both the type of transport and who the transport is connected to.
Implemented in ros::TransportTCP, and ros::TransportUDP.
virtual const char* ros::Transport::getType | ( | ) | [pure virtual] |
Return a string that details the type of transport (Eg. TCPROS)
Implemented in ros::TransportTCP, and ros::TransportUDP.
bool ros::Transport::isHostAllowed | ( | const std::string & | host | ) | const [protected] |
returns true if the transport is allowed to connect to the host passed to it.
Definition at line 107 of file transport.cpp.
bool ros::Transport::isOnlyLocalhostAllowed | ( | ) | const [inline, protected] |
returns true if this transport is only allowed to talk to localhost
Definition at line 147 of file transport.h.
virtual void ros::Transport::parseHeader | ( | const Header & | header | ) | [inline, virtual] |
Provides an opportunity for transport-specific options to come in through the header.
Reimplemented in ros::TransportTCP.
Definition at line 132 of file transport.h.
virtual int32_t ros::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.
buffer | Buffer to read from |
size | Size, in bytes, to read |
Implemented in ros::TransportTCP, and ros::TransportUDP.
virtual bool ros::Transport::requiresHeader | ( | ) | [inline, virtual] |
Returns a boolean to indicate if the transport mechanism is reliable or not.
Reimplemented in ros::TransportUDP.
Definition at line 127 of file transport.h.
void ros::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 109 of file transport.h.
void ros::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 113 of file transport.h.
void ros::Transport::setWriteCallback | ( | const Callback & | cb | ) | [inline] |
Set the function to call when there is space available to write on this transport.
Definition at line 117 of file transport.h.
virtual int32_t ros::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.
buffer | Buffer to write from |
size | Size, in bytes, to write |
Implemented in ros::TransportTCP, and ros::TransportUDP.
std::vector<std::string> ros::Transport::allowed_hosts_ [private] |
Definition at line 151 of file transport.h.
Callback ros::Transport::disconnect_cb_ [protected] |
Definition at line 135 of file transport.h.
bool ros::Transport::only_localhost_allowed_ [private] |
Definition at line 150 of file transport.h.
Callback ros::Transport::read_cb_ [protected] |
Definition at line 136 of file transport.h.
Callback ros::Transport::write_cb_ [protected] |
Definition at line 137 of file transport.h.