YARP
Yet Another Robot Platform
yarp::os::impl::StreamConnectionReader Class Reference

Lets Readable objects read from the underlying InputStream associated with the connection between two ports. More...

#include <yarp/os/impl/StreamConnectionReader.h>

+ Inheritance diagram for yarp::os::impl::StreamConnectionReader:

Public Member Functions

 StreamConnectionReader ()
 
virtual ~StreamConnectionReader ()
 
void reset (yarp::os::InputStream &in, TwoWayStream *str, const Route &route, size_t len, bool textMode, bool bareMode=false)
 
void setProtocol (Protocol *protocol)
 
void suppressReply ()
 
bool dropRequested ()
 
virtual bool expectBlock (yarp::os::Bytes &b)
 
virtual std::string expectString (int len)
 
virtual std::string expectLine ()
 
virtual void flushWriter ()
 
virtual void setReference (yarp::os::Portable *obj)
 
bool setSize (size_t len) override
 
size_t getSize () const override
 Checks how much data is available. More...
 
bool pushInt (int x) override
 Store an integer to return on the next call to expectInt() More...
 
std::int8_t expectInt8 () override
 Read a 8-bit integer from the network connection. More...
 
std::int16_t expectInt16 () override
 Read a 16-bit integer from the network connection. More...
 
std::int32_t expectInt32 () override
 Read a 32-bit integer from the network connection. More...
 
std::int64_t expectInt64 () override
 Read a 64-bit integer from the network connection. More...
 
yarp::conf::float32_t expectFloat32 () override
 Read a 32-bit floating point number from the network connection. More...
 
yarp::conf::float64_t expectFloat64 () override
 Read a 64-bit floating point number from the network connection. More...
 
bool expectBlock (char *data, size_t len) override
 Read a block of data from the network connection. More...
 
std::string expectText (const char terminatingChar) override
 Read some text from the network connection. More...
 
bool isTextMode () const override
 Check if the connection is text mode. More...
 
bool isBareMode () const override
 Check if the connection is bare mode. More...
 
bool convertTextMode () override
 Reads in a standard description in text mode, and converts it to a standard description in binary. More...
 
yarp::os::ConnectionWritergetWriter () override
 Gets a way to reply to the message, if possible. More...
 
yarp::os::Contact getRemoteContact () const override
 Gets information about who is supplying the data being read, if that information is available. More...
 
yarp::os::Contact getLocalContact () const override
 Gets information about who is receiving the data, if that information is available. More...
 
bool isValid () const override
 
bool isError () const override
 
bool isActive () const override
 
yarp::os::PortablegetReference () const override
 Get a direct pointer to the object being sent, if possible. More...
 
yarp::os::Bytes readEnvelope () override
 Read a message envelope, if available. More...
 
void requestDrop () override
 Tag the connection to be dropped after the current message. More...
 
const yarp::os::SearchablegetConnectionModifiers () const override
 Access modifiers associated with the connection, if any. More...
 
void setParentConnectionReader (ConnectionReader *parentConnectionReader) override
 Set ConnectionReader to be used for reading the envelope. More...
 
virtual std::string expectString ()
 Read a string from the network connection. More...
 
- Public Member Functions inherited from yarp::os::ConnectionReader
virtual ~ConnectionReader ()
 Destructor. More...
 
virtual int expectInt () final
 Read an integer from the network connection. More...
 
virtual double expectDouble ()
 Read a floating point number from the network connection. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from yarp::os::ConnectionReader
static ConnectionReadercreateConnectionReader (InputStream &is)
 Create an instance of YARP's standard connection reader implementation. More...
 
static bool readFromStream (PortReader &portable, InputStream &is)
 

Detailed Description

Lets Readable objects read from the underlying InputStream associated with the connection between two ports.

Definition at line 40 of file StreamConnectionReader.h.

Constructor & Destructor Documentation

◆ StreamConnectionReader()

StreamConnectionReader::StreamConnectionReader ( )

Definition at line 20 of file StreamConnectionReader.cpp.

◆ ~StreamConnectionReader()

StreamConnectionReader::~StreamConnectionReader ( )
virtual

Definition at line 41 of file StreamConnectionReader.cpp.

Member Function Documentation

◆ convertTextMode()

bool StreamConnectionReader::convertTextMode ( )
overridevirtual

Reads in a standard description in text mode, and converts it to a standard description in binary.

Useful if you only operate on the binary description usually, and just want to permit text mode for command-line interaction. If isTextMode would return false, no conversion is done.

Returns
true if the conversion was possible

Implements yarp::os::ConnectionReader.

Definition at line 286 of file StreamConnectionReader.cpp.

◆ dropRequested()

bool StreamConnectionReader::dropRequested ( )

Definition at line 79 of file StreamConnectionReader.cpp.

◆ expectBlock() [1/2]

bool StreamConnectionReader::expectBlock ( char *  data,
size_t  len 
)
overridevirtual

Read a block of data from the network connection.

Parameters
dataStart of the block of data
lenLength of the block of data
Returns
true on success

Implements yarp::os::ConnectionReader.

Definition at line 256 of file StreamConnectionReader.cpp.

◆ expectBlock() [2/2]

bool StreamConnectionReader::expectBlock ( yarp::os::Bytes b)
virtual

Definition at line 84 of file StreamConnectionReader.cpp.

◆ expectFloat32()

yarp::conf::float32_t StreamConnectionReader::expectFloat32 ( )
overridevirtual

Read a 32-bit floating point number from the network connection.

Returns
the floating point number read from the connection

Implements yarp::os::ConnectionReader.

Definition at line 240 of file StreamConnectionReader.cpp.

◆ expectFloat64()

yarp::conf::float64_t StreamConnectionReader::expectFloat64 ( )
overridevirtual

Read a 64-bit floating point number from the network connection.

Returns
the floating point number read from the connection

Implements yarp::os::ConnectionReader.

Definition at line 248 of file StreamConnectionReader.cpp.

◆ expectInt16()

std::int16_t StreamConnectionReader::expectInt16 ( )
overridevirtual

Read a 16-bit integer from the network connection.

Returns
the integer read from the connection

Implements yarp::os::ConnectionReader.

Definition at line 212 of file StreamConnectionReader.cpp.

◆ expectInt32()

std::int32_t StreamConnectionReader::expectInt32 ( )
overridevirtual

Read a 32-bit integer from the network connection.

Returns
the integer read from the connection

Implements yarp::os::ConnectionReader.

Definition at line 220 of file StreamConnectionReader.cpp.

◆ expectInt64()

std::int64_t StreamConnectionReader::expectInt64 ( )
overridevirtual

Read a 64-bit integer from the network connection.

Returns
the integer read from the connection

Implements yarp::os::ConnectionReader.

Definition at line 232 of file StreamConnectionReader.cpp.

◆ expectInt8()

std::int8_t StreamConnectionReader::expectInt8 ( )
overridevirtual

Read a 8-bit integer from the network connection.

Returns
the integer read from the connection

Implements yarp::os::ConnectionReader.

Definition at line 204 of file StreamConnectionReader.cpp.

◆ expectLine()

std::string StreamConnectionReader::expectLine ( )
virtual

Definition at line 128 of file StreamConnectionReader.cpp.

◆ expectString() [1/2]

virtual std::string yarp::os::ConnectionReader::expectString
inlinevirtual

Read a string from the network connection.

The string should be serialized as "length" + "block".

Returns
the string read from the connection

Reimplemented from yarp::os::ConnectionReader.

Definition at line 68 of file ConnectionReader.h.

◆ expectString() [2/2]

std::string StreamConnectionReader::expectString ( int  len)
virtual

Definition at line 107 of file StreamConnectionReader.cpp.

◆ expectText()

std::string StreamConnectionReader::expectText ( const char  terminatingChar)
overridevirtual

Read some text from the network connection.

Parameters
terminatingCharThe marker for the end of the text
Returns
the text read from the connection

Implements yarp::os::ConnectionReader.

Definition at line 262 of file StreamConnectionReader.cpp.

◆ flushWriter()

void StreamConnectionReader::flushWriter ( )
virtual

Definition at line 144 of file StreamConnectionReader.cpp.

◆ getConnectionModifiers()

const Searchable & StreamConnectionReader::getConnectionModifiers ( ) const
overridevirtual

Access modifiers associated with the connection, if any.

Returns
connection configuration object

Implements yarp::os::ConnectionReader.

Definition at line 393 of file StreamConnectionReader.cpp.

◆ getLocalContact()

yarp::os::Contact StreamConnectionReader::getLocalContact ( ) const
overridevirtual

Gets information about who is receiving the data, if that information is available.

Returns
contact information about sender (Contact::invalid if not available)

Implements yarp::os::ConnectionReader.

Definition at line 332 of file StreamConnectionReader.cpp.

◆ getReference()

yarp::os::Portable * StreamConnectionReader::getReference ( ) const
overridevirtual

Get a direct pointer to the object being sent, if possible.

This only makes sense in local operation, when sender and receiver are in the same process; in all other situations this returns nullptr.

Returns
The message object, or nullptr if not available

Implements yarp::os::ConnectionReader.

Definition at line 371 of file StreamConnectionReader.cpp.

◆ getRemoteContact()

yarp::os::Contact StreamConnectionReader::getRemoteContact ( ) const
overridevirtual

Gets information about who is supplying the data being read, if that information is available.

Returns
contact information about sender (Contact::invalid if not available)

Implements yarp::os::ConnectionReader.

Definition at line 321 of file StreamConnectionReader.cpp.

◆ getSize()

size_t StreamConnectionReader::getSize ( ) const
overridevirtual

Checks how much data is available.

Returns
the number of bytes left on the connection.

Implements yarp::os::ConnectionReader.

Definition at line 172 of file StreamConnectionReader.cpp.

◆ getWriter()

yarp::os::ConnectionWriter * StreamConnectionReader::getWriter ( )
overridevirtual

Gets a way to reply to the message, if possible.

Returns
An object that permits replies, or nullptr if this cannot be done.

Implements yarp::os::ConnectionReader.

Definition at line 304 of file StreamConnectionReader.cpp.

◆ isActive()

bool StreamConnectionReader::isActive ( ) const
overridevirtual
Returns
true if the reader is active. Readers become inactive if the connection they are associated with breaks.

Implements yarp::os::ConnectionReader.

Definition at line 355 of file StreamConnectionReader.cpp.

◆ isBareMode()

bool StreamConnectionReader::isBareMode ( ) const
overridevirtual

Check if the connection is bare mode.

If it is, you are encouraged to omit type information from your serialization.

Returns
true if the connection is bare

Implements yarp::os::ConnectionReader.

Definition at line 281 of file StreamConnectionReader.cpp.

◆ isError()

bool StreamConnectionReader::isError ( ) const
overridevirtual
Returns
true if the reader encountered an error. Readers can encounter an error if there is some data loss. For unreliable protocols like UDP/Multicast, where losses are not unexpected, this error flag will be reset for the next incoming message.

Implements yarp::os::ConnectionReader.

Definition at line 347 of file StreamConnectionReader.cpp.

◆ isTextMode()

bool StreamConnectionReader::isTextMode ( ) const
overridevirtual

Check if the connection is text mode.

If it is, you are encouraged (but by no means required) to use a human-readable representation of your data structure.

Returns
true if the connection is text mode (as opposed to binary)

Implements yarp::os::ConnectionReader.

Definition at line 276 of file StreamConnectionReader.cpp.

◆ isValid()

bool StreamConnectionReader::isValid ( ) const
overridevirtual
Returns
true if the reader is valid. Invalid readers may signal a shutdown.

Implements yarp::os::ConnectionReader.

Definition at line 342 of file StreamConnectionReader.cpp.

◆ pushInt()

bool StreamConnectionReader::pushInt ( int  x)
overridevirtual

Store an integer to return on the next call to expectInt()

Parameters
xthe integer to store
Returns
true on success

Implements yarp::os::ConnectionReader.

Definition at line 177 of file StreamConnectionReader.cpp.

◆ readEnvelope()

Bytes StreamConnectionReader::readEnvelope ( )
overridevirtual

Read a message envelope, if available.

Reimplemented from yarp::os::ConnectionReader.

Definition at line 376 of file StreamConnectionReader.cpp.

◆ requestDrop()

void StreamConnectionReader::requestDrop ( )
overridevirtual

Tag the connection to be dropped after the current message.

Implements yarp::os::ConnectionReader.

Definition at line 388 of file StreamConnectionReader.cpp.

◆ reset()

void StreamConnectionReader::reset ( yarp::os::InputStream in,
TwoWayStream str,
const Route route,
size_t  len,
bool  textMode,
bool  bareMode = false 
)

Definition at line 49 of file StreamConnectionReader.cpp.

◆ setParentConnectionReader()

void StreamConnectionReader::setParentConnectionReader ( ConnectionReader parentConnectionReader)
overridevirtual

Set ConnectionReader to be used for reading the envelope.

Used by PortCoreInputUnit

Reimplemented from yarp::os::ConnectionReader.

Definition at line 403 of file StreamConnectionReader.cpp.

◆ setProtocol()

void StreamConnectionReader::setProtocol ( Protocol protocol)

Definition at line 69 of file StreamConnectionReader.cpp.

◆ setReference()

void StreamConnectionReader::setReference ( yarp::os::Portable obj)
virtual

Definition at line 161 of file StreamConnectionReader.cpp.

◆ setSize()

bool StreamConnectionReader::setSize ( size_t  len)
overridevirtual

Implements yarp::os::ConnectionReader.

Definition at line 166 of file StreamConnectionReader.cpp.

◆ suppressReply()

void StreamConnectionReader::suppressReply ( )

Definition at line 74 of file StreamConnectionReader.cpp.


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