35 #ifndef ROSCPP_TRANSPORT_H 36 #define ROSCPP_TRANSPORT_H 39 #include <boost/function.hpp> 40 #include <boost/shared_ptr.hpp> 41 #include <boost/enable_shared_from_this.hpp> 55 class Transport :
public boost::enable_shared_from_this<Transport>
67 virtual int32_t
read(uint8_t* buffer, uint32_t size) = 0;
74 virtual int32_t
write(uint8_t* buffer, uint32_t size) = 0;
97 virtual void close() = 0;
103 virtual const char*
getType() = 0;
105 typedef boost::function<void(const TransportPtr&)>
Callback;
156 #endif // ROSCPP_TRANSPORT_H virtual void close()=0
Close this transport. Once this call has returned, writing on this transport should always return an ...
virtual const char * getType()=0
Return a string that details the type of transport (Eg. TCPROS)
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 byt...
Abstract base class that allows abstraction of the transport type, eg. TCP, shared memory...
void setReadCallback(const Callback &cb)
Set the function to call when there is data available to be read by this transport.
bool isOnlyLocalhostAllowed() const
returns true if this transport is only allowed to talk to localhost
void setWriteCallback(const Callback &cb)
Set the function to call when there is space available to write on this transport.
boost::shared_ptr< Transport > TransportPtr
virtual void enableWrite()=0
Enable writing on this transport. Allows derived classes to, for example, enable write polling for as...
virtual bool requiresHeader()
Returns a boolean to indicate if the transport mechanism is reliable or not.
virtual void disableWrite()=0
Disable writing on this transport. Allows derived classes to, for example, disable write polling for ...
virtual void parseHeader(const Header &header)
Provides an opportunity for transport-specific options to come in through the header.
virtual std::string getTransportInfo()=0
Returns a string description of both the type of transport and who the transport is connected to...
virtual void enableRead()=0
Enable reading on this transport. Allows derived classes to, for example, enable read polling for asy...
bool only_localhost_allowed_
void setDisconnectCallback(const Callback &cb)
Set the function to call when this transport has disconnected, either through a call to close()...
std::vector< std::string > allowed_hosts_
boost::function< void(const TransportPtr &)> Callback
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 void disableRead()=0
Disable reading on this transport. Allows derived classes to, for example, disable read polling for a...
bool isHostAllowed(const std::string &host) const
returns true if the transport is allowed to connect to the host passed to it.