YARP
Yet Another Robot Platform
TcpRosStream Class Reference

#include <tcpros_carrier/TcpRosStream.h>

+ Inheritance diagram for TcpRosStream:

Public Member Functions

 TcpRosStream (TwoWayStream *delegate, bool sender, bool reply, bool service, int raw, const char *kind)
 
virtual ~TcpRosStream ()
 
yarp::os::InputStreamgetInputStream () override
 Get an InputStream to read from. More...
 
yarp::os::OutputStreamgetOutputStream () override
 Get an OutputStream to write to. More...
 
const yarp::os::ContactgetLocalAddress () const override
 Get the address of the local side of the stream. More...
 
const yarp::os::ContactgetRemoteAddress () const override
 Get the address of the remote side of the stream. More...
 
bool isOk () const override
 Check if the stream is ok or in an error state. More...
 
void reset () override
 Reset the stream. More...
 
void close () override
 Terminate the stream. More...
 
void beginPacket () override
 Mark the beginning of a logical packet. More...
 
void endPacket () override
 Mark the end of a logical packet (see beginPacket). More...
 
void write (const yarp::os::Bytes &b) override
 Write a block of bytes to the stream. More...
 
yarp::conf::ssize_t read (yarp::os::Bytes &b) override
 Read a block of data from the stream. More...
 
void interrupt () override
 Interrupt the stream. More...
 
void updateKind (const char *kind, bool sender, bool reply)
 
- Public Member Functions inherited from yarp::os::TwoWayStream
virtual ~TwoWayStream ()
 Destructor. More...
 
- Public Member Functions inherited from yarp::os::InputStream
 InputStream ()
 Constructor. More...
 
virtual ~InputStream ()
 Destructor. More...
 
virtual void check ()
 Perform maintenance actions, if needed. More...
 
virtual int read ()
 Read and return a single byte. More...
 
virtual yarp::conf::ssize_t read (Bytes &b, size_t offset, yarp::conf::ssize_t len)
 Read a block of data from the stream. More...
 
virtual yarp::conf::ssize_t partialRead (yarp::os::Bytes &b)
 Like read, but solicit partial responses. More...
 
virtual bool setReadTimeout (double timeout)
 Set activity timeout. More...
 
std::string readLine (const char terminal='\n', bool *success=nullptr)
 Read a block of text terminated with a specific marker (or EOF). More...
 
yarp::conf::ssize_t readFull (Bytes &b)
 Keep reading until buffer is full. More...
 
yarp::conf::ssize_t readDiscard (size_t len)
 Read and discard a fixed number of bytes. More...
 
virtual bool setReadEnvelopeCallback (readEnvelopeCallbackType callback, void *data)
 Install a callback that the InputStream will have to call when the envelope is read from a message in carriers that cannot be escaped. More...
 
- Public Member Functions inherited from yarp::os::OutputStream
virtual ~OutputStream ()
 Destructor. More...
 
virtual void write (char ch)
 Write a single byte to the stream. More...
 
virtual void write (const Bytes &b, int offset, int len)
 Write a block of bytes to the stream. More...
 
virtual void flush ()
 Make sure all pending write operations are finished. More...
 
virtual void writeLine (const char *data, int len)
 Write some text followed by a line feed. More...
 
virtual bool setWriteTimeout (double timeout)
 Set activity timeout. More...
 
virtual bool setTypeOfService (int tos)
 
virtual int getTypeOfService ()
 

Static Public Member Functions

static std::map< std::string, std::string > rosToKind ()
 
static std::string rosToKind (const char *rosname)
 
static bool configureTwiddler (yarp::wire_rep_utils::WireTwiddler &twiddler, const char *txt, const char *prompt, bool sender, bool reply)
 

Additional Inherited Members

- Public Types inherited from yarp::os::InputStream
typedef void(* readEnvelopeCallbackType) (void *, const yarp::os::Bytes &envelope)
 Callback type for setting the envelope from a message in carriers that cannot be escaped. More...
 

Detailed Description

Definition at line 23 of file TcpRosStream.h.

Constructor & Destructor Documentation

◆ TcpRosStream()

TcpRosStream::TcpRosStream ( TwoWayStream *  delegate,
bool  sender,
bool  reply,
bool  service,
int  raw,
const char *  kind 
)
inline

Definition at line 43 of file TcpRosStream.h.

◆ ~TcpRosStream()

virtual TcpRosStream::~TcpRosStream ( )
inlinevirtual

Definition at line 64 of file TcpRosStream.h.

Member Function Documentation

◆ beginPacket()

void TcpRosStream::beginPacket ( )
inlineoverridevirtual

Mark the beginning of a logical packet.

This is a unit that should be treated in an atomic fashion by YARP. If any part is corrupted, the whole should be dropped.

Implements yarp::os::TwoWayStream.

Definition at line 95 of file TcpRosStream.h.

◆ close()

void TcpRosStream::close ( )
inlineoverridevirtual

Terminate the stream.

Implements yarp::os::InputStream.

Definition at line 91 of file TcpRosStream.h.

◆ configureTwiddler()

static bool TcpRosStream::configureTwiddler ( yarp::wire_rep_utils::WireTwiddler twiddler,
const char *  txt,
const char *  prompt,
bool  sender,
bool  reply 
)
static

◆ endPacket()

void TcpRosStream::endPacket ( )
inlineoverridevirtual

Mark the end of a logical packet (see beginPacket).

Implements yarp::os::TwoWayStream.

Definition at line 100 of file TcpRosStream.h.

◆ getInputStream()

yarp::os::InputStream& TcpRosStream::getInputStream ( )
inlineoverridevirtual

Get an InputStream to read from.

Returns
the InputStream associated with this object.

Implements yarp::os::TwoWayStream.

Definition at line 71 of file TcpRosStream.h.

◆ getLocalAddress()

const yarp::os::Contact& TcpRosStream::getLocalAddress ( ) const
inlineoverridevirtual

Get the address of the local side of the stream.

Returns
the address of the local side of the stream. The address will be tagged as invalid if the stream is not set up.

Implements yarp::os::TwoWayStream.

Definition at line 75 of file TcpRosStream.h.

◆ getOutputStream()

yarp::os::OutputStream& TcpRosStream::getOutputStream ( )
inlineoverridevirtual

Get an OutputStream to write to.

Returns
the InputStream associated with this object.

Implements yarp::os::TwoWayStream.

Definition at line 72 of file TcpRosStream.h.

◆ getRemoteAddress()

const yarp::os::Contact& TcpRosStream::getRemoteAddress ( ) const
inlineoverridevirtual

Get the address of the remote side of the stream.

Returns
the address of the remote side of the stream. The address will be tagged as invalid if the stream is not set up.

Implements yarp::os::TwoWayStream.

Definition at line 79 of file TcpRosStream.h.

◆ interrupt()

void TcpRosStream::interrupt ( )
inlineoverridevirtual

Interrupt the stream.

If the stream is currently in a blocked state, it must be unblocked.

Reimplemented from yarp::os::InputStream.

Definition at line 110 of file TcpRosStream.h.

◆ isOk()

bool TcpRosStream::isOk ( ) const
inlineoverridevirtual

Check if the stream is ok or in an error state.

Returns
true iff the stream is ok

Implements yarp::os::InputStream.

Definition at line 83 of file TcpRosStream.h.

◆ read()

yarp::conf::ssize_t TcpRosStream::read ( yarp::os::Bytes b)
overridevirtual

Read a block of data from the stream.

Should block and wait for data.

Parameters
b[out]the block of data to read to
Returns
the number of bytes read, or -1 upon error

Implements yarp::os::InputStream.

Definition at line 26 of file TcpRosStream.cpp.

◆ reset()

void TcpRosStream::reset ( )
inlineoverridevirtual

Reset the stream.

Implements yarp::os::TwoWayStream.

Definition at line 87 of file TcpRosStream.h.

◆ rosToKind() [1/2]

static std::map<std::string, std::string> TcpRosStream::rosToKind ( )
static

◆ rosToKind() [2/2]

static std::string TcpRosStream::rosToKind ( const char *  rosname)
static

◆ updateKind()

void TcpRosStream::updateKind ( const char *  kind,
bool  sender,
bool  reply 
)

◆ write()

void TcpRosStream::write ( const yarp::os::Bytes b)
overridevirtual

Write a block of bytes to the stream.

Parameters
bthe bytes to write

Implements yarp::os::OutputStream.

Definition at line 141 of file TcpRosStream.cpp.


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