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. More... | |
Public Member Functions | |
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 | read (yarp::os::Bytes &b)=0 |
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 void | close ()=0 |
Terminate the stream. More... | |
virtual void | interrupt () |
Interrupt the stream. More... | |
virtual bool | isOk () const =0 |
Check if the stream is ok or in an error state. 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... | |
Simple specification of the minimum functions needed from input streams.
The streams could be TCP, UDP, MCAST, ...
Definition at line 28 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 128 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 19 of file InputStream.cpp.
|
pure virtual |
Terminate the stream.
Implemented in MpiStream, yarp::wire_rep_utils::WireTwiddlerReader, yarp::os::NullStream, yarp::os::StringInputStream, yarp::os::impl::SocketTwoWayStream, yarp::os::impl::NameserTwoWayStream, yarp::os::impl::LocalCarrierStream, yarp::os::impl::DgramTwoWayStream, XmlRpcStream, UnixSockTwoWayStream, TcpRosStream, ShmemHybridStream, MpiP2PStream, MpiBcastStream, MjpegStream, HumanStream, and BayerCarrier.
|
virtual |
Interrupt the stream.
If the stream is currently in a blocked state, it must be unblocked.
Reimplemented in yarp::os::impl::SocketTwoWayStream, yarp::os::impl::LocalCarrierStream, yarp::os::impl::DgramTwoWayStream, XmlRpcStream, UnixSockTwoWayStream, TcpRosStream, ShmemHybridStream, MpiStream, MjpegStream, and HumanStream.
Definition at line 45 of file InputStream.cpp.
|
pure virtual |
Check if the stream is ok or in an error state.
Implemented in yarp::wire_rep_utils::WireTwiddlerReader, yarp::os::NullStream, yarp::os::StringInputStream, yarp::os::impl::SocketTwoWayStream, yarp::os::impl::NameserTwoWayStream, yarp::os::impl::LocalCarrierStream, yarp::os::impl::DgramTwoWayStream, XmlRpcStream, UnixSockTwoWayStream, TcpRosStream, ShmemHybridStream, MpiStream, MjpegStream, HumanStream, and BayerCarrier.
|
virtual |
Like read, but solicit partial responses.
Reimplemented in yarp::os::impl::SocketTwoWayStream.
Definition at line 40 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, MpiP2PStream, MpiBcastStream, yarp::os::StringInputStream, and yarp::os::StringInputStream.
Definition at line 23 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 |
Definition at line 34 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 MpiStream, yarp::wire_rep_utils::WireTwiddlerReader, yarp::os::impl::NameserTwoWayStream, yarp::os::impl::LocalCarrierStream, yarp::os::impl::DgramTwoWayStream, XmlRpcStream, UnixSockTwoWayStream, TcpRosStream, ShmemHybridStream, MpiP2PStream, MpiBcastStream, MjpegStream, H264Stream, BayerCarrier, yarp::os::NullStream, yarp::os::StringInputStream, yarp::os::impl::SocketTwoWayStream, and HumanStream.
yarp::conf::ssize_t InputStream::readDiscard | ( | size_t | len | ) |
Read and discard a fixed number of bytes.
Definition at line 115 of file InputStream.cpp.
yarp::conf::ssize_t InputStream::readFull | ( | Bytes & | b | ) |
Keep reading until buffer is full.
Definition at line 99 of file InputStream.cpp.
std::string InputStream::readLine | ( | const char | terminal = '\n' , |
bool * | success = nullptr |
||
) |
Read a block of text terminated with a specific marker (or EOF).
Definition at line 57 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 126 of file InputStream.cpp.
|
virtual |
Set activity timeout.
Support for this is optional. 0 = wait forever.
Reimplemented in yarp::os::impl::SocketTwoWayStream.
Definition at line 49 of file InputStream.cpp.