Simple specification of the minimum functions needed from input streams. More...
#include <yarp/os/InputStream.h>
Public Types | |
typedef void(* | readEnvelopeCallbackType) (void *, const yarp::os::Bytes &envelope) |
Callback type for setting the envelope from a message in carriers that cannot be escaped. | |
Public Member Functions | |
InputStream () | |
Constructor. | |
virtual | ~InputStream () |
Destructor. | |
virtual void | check () |
Perform maintenance actions, if needed. | |
virtual int | read () |
Read and return a single byte. | |
virtual yarp::conf::ssize_t | read (Bytes &b, size_t offset, yarp::conf::ssize_t len) |
Read a block of data from the stream. | |
virtual yarp::conf::ssize_t | read (yarp::os::Bytes &b)=0 |
Read a block of data from the stream. | |
virtual yarp::conf::ssize_t | partialRead (yarp::os::Bytes &b) |
Like read, but solicit partial responses. | |
virtual void | close ()=0 |
Terminate the stream. | |
virtual void | interrupt () |
Interrupt the stream. | |
virtual bool | isOk () const =0 |
Check if the stream is ok or in an error state. | |
virtual bool | setReadTimeout (double timeout) |
Set activity timeout. | |
std::string | readLine (const char terminal='\n', bool *success=nullptr) |
Read a block of text terminated with a specific marker (or EOF). | |
yarp::conf::ssize_t | readFull (Bytes &b) |
Keep reading until buffer is full. | |
yarp::conf::ssize_t | readDiscard (size_t len) |
Read and discard a fixed number of bytes. | |
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. | |
Simple specification of the minimum functions needed from input streams.
The streams could be TCP, UDP, MCAST, ...
Definition at line 24 of file InputStream.h.
typedef void(* yarp::os::InputStream::readEnvelopeCallbackType) (void *, const yarp::os::Bytes &envelope) |
Callback type for setting the envelope from a message in carriers that cannot be escaped.
Definition at line 124 of file InputStream.h.
|
default |
Constructor.
|
virtualdefault |
Destructor.
|
virtual |
Perform maintenance actions, if needed.
This method is called frequently by YARP when a stream is being accessed. By default, it does nothing.
Definition at line 16 of file InputStream.cpp.
Terminate the stream.
Implemented in BayerCarrier, HumanStream, MjpegStream, MpiBcastStream, MpiP2PStream, ShmemHybridStream, UnixSockTwoWayStream, WebSocketStream, yarp::os::impl::DgramTwoWayStream, yarp::os::impl::LocalCarrierStream, yarp::os::impl::NameserTwoWayStream, yarp::os::impl::SocketTwoWayStream, yarp::os::StringInputStream, yarp::os::NullStream, and MpiStream.
|
virtual |
Interrupt the stream.
If the stream is currently in a blocked state, it must be unblocked.
Reimplemented in HumanStream, MjpegStream, MpiStream, ShmemHybridStream, UnixSockTwoWayStream, WebSocketStream, yarp::os::impl::DgramTwoWayStream, yarp::os::impl::LocalCarrierStream, and yarp::os::impl::SocketTwoWayStream.
Definition at line 42 of file InputStream.cpp.
Check if the stream is ok or in an error state.
Implemented in BayerCarrier, HumanStream, MjpegStream, MpiStream, ShmemHybridStream, UnixSockTwoWayStream, WebSocketStream, yarp::os::impl::DgramTwoWayStream, yarp::os::impl::LocalCarrierStream, yarp::os::impl::NameserTwoWayStream, yarp::os::impl::SocketTwoWayStream, yarp::os::StringInputStream, and yarp::os::NullStream.
|
virtual |
Like read, but solicit partial responses.
Reimplemented in yarp::os::impl::SocketTwoWayStream.
Definition at line 37 of file InputStream.cpp.
|
virtual |
Read and return a single byte.
Should block and wait for data. By default, this calls read(Bytes& b) to do its work.
Reimplemented in yarp::os::StringInputStream.
Definition at line 20 of file InputStream.cpp.
|
virtual |
Read a block of data from the stream.
Should block and wait for data. By default, this calls read(Bytes& b) to do its work.
[out] | b | the block of data to read to |
offset | an offset within the block to start at | |
len | the number of bytes to read |
Reimplemented in yarp::os::StringInputStream.
Definition at line 31 of file InputStream.cpp.
|
pure virtual |
Read a block of data from the stream.
Should block and wait for data.
b[out] | the block of data to read to |
Implemented in HumanStream, yarp::os::impl::SocketTwoWayStream, yarp::os::StringInputStream, yarp::os::NullStream, BayerCarrier, H264Stream, MjpegStream, MpiBcastStream, MpiP2PStream, ShmemHybridStream, UnixSockTwoWayStream, yarp::os::impl::DgramTwoWayStream, yarp::os::impl::LocalCarrierStream, yarp::os::impl::NameserTwoWayStream, MpiBcastStream, MpiP2PStream, MpiStream, yarp::os::StringInputStream, and WebSocketStream.
yarp::conf::ssize_t InputStream::readDiscard | ( | size_t | len | ) |
Read and discard a fixed number of bytes.
Definition at line 112 of file InputStream.cpp.
yarp::conf::ssize_t InputStream::readFull | ( | Bytes & | b | ) |
Keep reading until buffer is full.
Definition at line 96 of file InputStream.cpp.
Read a block of text terminated with a specific marker (or EOF).
Definition at line 54 of file InputStream.cpp.
|
virtual |
Install a callback that the InputStream will have to call when the envelope is read from a message in carriers that cannot be escaped.
callback | the callback to execute |
data | a pointer that should be passed as first parameter to the callback function |
callback
was installed. Reimplemented in MjpegStream.
Definition at line 123 of file InputStream.cpp.
Set activity timeout.
Support for this is optional. 0 = wait forever.
Reimplemented in yarp::os::impl::SocketTwoWayStream.
Definition at line 46 of file InputStream.cpp.