YARP  2.3.70
Yet Another Robot Platform
yarp::os::ConnectionReader Class Referenceabstract

An interface for reading from a network connection. More...

#include <yarp/os/ConnectionReader.h>

+ Inheritance diagram for yarp::os::ConnectionReader:

Public Member Functions

virtual ~ConnectionReader ()
 Destructor. More...
 
virtual bool expectBlock (const char *data, size_t len)=0
 Read a block of data from the network connection. More...
 
virtual ConstString expectText (int terminatingChar='\n')=0
 Read some text from the network connection. More...
 
virtual int expectInt ()=0
 Read an integer from the network connection. More...
 
virtual YARP_INT64 expectInt64 ()=0
 Read a 64 bit integer from the network connection. More...
 
virtual double expectDouble ()=0
 Read a floating point number from the network connection. More...
 
virtual bool isTextMode ()=0
 Check if the connection is text mode. More...
 
virtual bool isBareMode ()=0
 Check if the connection is bare mode. More...
 
virtual bool convertTextMode ()=0
 Reads in a standard description in text mode, and converts it to a standard description in binary. More...
 
virtual size_t getSize ()=0
 Checks how much data is available. More...
 
virtual ConnectionWritergetWriter ()=0
 Gets a way to reply to the message, if possible. More...
 
virtual Bytes readEnvelope ()
 Read a message envelope, if available. More...
 
virtual PortablegetReference ()=0
 Get a direct pointer to the object being sent, if possible. More...
 
virtual Contact getRemoteContact ()=0
 Gets information about who is supplying the data being read, if that information is available. More...
 
virtual Contact getLocalContact ()=0
 Gets information about who is receiving the data, if that information is available. More...
 
virtual bool isValid ()=0
 
virtual bool isActive ()=0
 
virtual bool isError ()=0
 
virtual void requestDrop ()=0
 Tag the connection to be dropped after the current message. More...
 
virtual SearchablegetConnectionModifiers ()=0
 Access modifiers associated with the connection, if any. More...
 
virtual bool pushInt (int x)=0
 Store an integer to return on the next call to expectInt() More...
 
virtual bool setSize (size_t len)=0
 
virtual void setParentConnectionReader (ConnectionReader *parentConnectionReader)
 Set ConnectionReader to be used for reading the envelope. More...
 

Static Public Member Functions

static ConnectionReadercreateConnectionReader (InputStream &is)
 Create an instance of YARP's standard connection reader implementation. More...
 
static bool readFromStream (PortReader &portable, InputStream &is)
 

Detailed Description

Constructor & Destructor Documentation

◆ ~ConnectionReader()

ConnectionReader::~ConnectionReader ( )
virtual

Destructor.

Definition at line 14 of file ConnectionReader.cpp.

Member Function Documentation

◆ convertTextMode()

virtual bool yarp::os::ConnectionReader::convertTextMode ( )
pure virtual

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

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::StreamConnectionReader, yarp::os::BayerCarrier, and yarp::os::NullConnectionReader.

Examples:
port_power/TargetVer3.h.

◆ createConnectionReader()

ConnectionReader * ConnectionReader::createConnectionReader ( InputStream is)
static

Create an instance of YARP's standard connection reader implementation.

Definition at line 28 of file ConnectionReader.cpp.

◆ expectBlock()

virtual bool yarp::os::ConnectionReader::expectBlock ( const char *  data,
size_t  len 
)
pure virtual

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

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::StreamConnectionReader, yarp::os::BayerCarrier, and yarp::os::NullConnectionReader.

◆ expectDouble()

virtual double yarp::os::ConnectionReader::expectDouble ( )
pure virtual

Read a floating point number from the network connection.

Returns
the floating point number read from the connection

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::StreamConnectionReader, yarp::os::BayerCarrier, and yarp::os::NullConnectionReader.

◆ expectInt()

virtual int yarp::os::ConnectionReader::expectInt ( )
pure virtual

Read an integer from the network connection.

Returns
the integer read from the connection

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::StreamConnectionReader, yarp::os::BayerCarrier, and yarp::os::NullConnectionReader.

Examples:
port_power/TargetVer2.h, and port_power/TargetVer3.h.

◆ expectInt64()

virtual YARP_INT64 yarp::os::ConnectionReader::expectInt64 ( )
pure virtual

Read a 64 bit integer from the network connection.

Returns
the integer read from the connection

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::StreamConnectionReader, and yarp::os::BayerCarrier.

◆ expectText()

virtual ConstString yarp::os::ConnectionReader::expectText ( int  terminatingChar = '\n')
pure virtual

Read some text from the network connection.

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

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::StreamConnectionReader, yarp::os::BayerCarrier, and yarp::os::NullConnectionReader.

◆ getConnectionModifiers()

virtual Searchable& yarp::os::ConnectionReader::getConnectionModifiers ( )
pure virtual

Access modifiers associated with the connection, if any.

Returns
connection configuration object

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::StreamConnectionReader, yarp::os::BayerCarrier, and yarp::os::NullConnectionReader.

◆ getLocalContact()

virtual Contact yarp::os::ConnectionReader::getLocalContact ( )
pure virtual

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

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

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::StreamConnectionReader, yarp::os::BayerCarrier, and yarp::os::NullConnectionReader.

◆ getReference()

virtual Portable* yarp::os::ConnectionReader::getReference ( )
pure virtual

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 YARP_NULLPTR.

Returns
The message object, or YARP_NULLPTR if not available

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::StreamConnectionReader, yarp::os::BayerCarrier, and yarp::os::NullConnectionReader.

◆ getRemoteContact()

virtual Contact yarp::os::ConnectionReader::getRemoteContact ( )
pure virtual

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)

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::StreamConnectionReader, yarp::os::BayerCarrier, and yarp::os::NullConnectionReader.

◆ getSize()

virtual size_t yarp::os::ConnectionReader::getSize ( )
pure virtual

Checks how much data is available.

Returns
the number of bytes left on the connection.

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::StreamConnectionReader, yarp::os::BayerCarrier, and yarp::os::NullConnectionReader.

◆ getWriter()

virtual ConnectionWriter* yarp::os::ConnectionReader::getWriter ( )
pure virtual

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

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

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::StreamConnectionReader, yarp::os::BayerCarrier, yarp::os::NullConnectionReader, and DummyConnectorReader.

Examples:
port_power/ex0402_port_callback_reply.cpp, and port_power/ex0403_bufferedport_callback_reply.cpp.

◆ isActive()

virtual bool yarp::os::ConnectionReader::isActive ( )
pure virtual
Returns
true if the reader is active. Readers become inactive if the connection they are associated with breaks.

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::StreamConnectionReader, yarp::os::BayerCarrier, and yarp::os::NullConnectionReader.

◆ isBareMode()

virtual bool yarp::os::ConnectionReader::isBareMode ( )
pure virtual

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

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::StreamConnectionReader, and yarp::os::BayerCarrier.

◆ isError()

virtual bool yarp::os::ConnectionReader::isError ( )
pure virtual
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.

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::StreamConnectionReader, yarp::os::BayerCarrier, and yarp::os::NullConnectionReader.

◆ isTextMode()

virtual bool yarp::os::ConnectionReader::isTextMode ( )
pure virtual

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)

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::StreamConnectionReader, yarp::os::BayerCarrier, and yarp::os::NullConnectionReader.

◆ isValid()

virtual bool yarp::os::ConnectionReader::isValid ( )
pure virtual
Returns
true if the reader is valid. Invalid readers may signal a shutdown.

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::StreamConnectionReader, yarp::os::BayerCarrier, and yarp::os::NullConnectionReader.

◆ pushInt()

virtual bool yarp::os::ConnectionReader::pushInt ( int  x)
pure virtual

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

Parameters
xthe integer to store
Returns
true on success

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::BayerCarrier, yarp::os::impl::StreamConnectionReader, and yarp::os::NullConnectionReader.

◆ readEnvelope()

Bytes ConnectionReader::readEnvelope ( )
virtual

Read a message envelope, if available.

Reimplemented in yarp::os::impl::StreamConnectionReader, yarp::os::BayerCarrier, and yarp::os::NullConnectionReader.

Definition at line 18 of file ConnectionReader.cpp.

◆ readFromStream()

bool ConnectionReader::readFromStream ( PortReader portable,
InputStream is 
)
static

Definition at line 36 of file ConnectionReader.cpp.

◆ requestDrop()

virtual void yarp::os::ConnectionReader::requestDrop ( )
pure virtual

Tag the connection to be dropped after the current message.

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::StreamConnectionReader, yarp::os::BayerCarrier, and yarp::os::NullConnectionReader.

◆ setParentConnectionReader()

void ConnectionReader::setParentConnectionReader ( ConnectionReader parentConnectionReader)
virtual

Set ConnectionReader to be used for reading the envelope.

Used by PortCoreInputUnit

Reimplemented in yarp::os::impl::StreamConnectionReader.

Definition at line 23 of file ConnectionReader.cpp.

◆ setSize()

virtual bool yarp::os::ConnectionReader::setSize ( size_t  len)
pure virtual

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