Public Member Functions

yarp::os::ConnectionReader Class Reference

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

#include <ConnectionReader.h>

Inheritance diagram for yarp::os::ConnectionReader:
yarp::os::impl::ConnectionRecorder yarp::os::impl::StreamConnectionReader

Public Member Functions

virtual ~ConnectionReader ()
 Destructor.
virtual bool expectBlock (const char *data, int len)=0
 Read a block of data from the network connection.
virtual ConstString expectText (int terminatingChar= '\n')=0
 Read some text from the network connection.
virtual int expectInt ()=0
 Read an integer from the network connection.
virtual double expectDouble ()=0
 Read a floating point number from the network connection.
virtual bool isTextMode ()=0
 Check if the connection is text mode.
virtual bool convertTextMode ()=0
 Reads in a standard description in text mode, and converts it to a standard description in binary.
virtual int getSize ()=0
 Checks how much data is available.
virtual ConnectionWritergetWriter ()=0
 Gets a way to reply to the message, if possible.
virtual Bytes readEnvelope ()
 Read a message envelope, if available.
virtual PortablegetReference ()=0
 Get a direct pointer to the object being sent, if possible.
virtual Contact getRemoteContact ()=0
 Gets information about who is supplying the data being read, if that information is available.
virtual Contact getLocalContact ()=0
 Gets information about who is receiving the data, if that information is available.
virtual bool isValid ()=0
virtual bool isActive ()=0
virtual bool isError ()=0

Detailed Description

An interface for reading from a network connection.

See also:
Port, PortReader, ConnectionWriter
Examples:

port_power/ex0300_port_callback.cpp, port_power/ex0402_port_callback_reply.cpp, port_power/ex0403_bufferedport_callback_reply.cpp, port_power/TargetVer2.h, and port_power/TargetVer3.h.

Definition at line 34 of file libYARP_OS/include/yarp/os/ConnectionReader.h.


Constructor & Destructor Documentation

virtual yarp::os::ConnectionReader::~ConnectionReader (  )  [inline, virtual]

Destructor.

Definition at line 40 of file libYARP_OS/include/yarp/os/ConnectionReader.h.


Member Function Documentation

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

Read a block of data from the network connection.

Parameters:
data Start of the block of data
len Length of the block of data
Returns:
true on success

Implemented in yarp::os::impl::StreamConnectionReader.

Referenced by yarp::os::impl::ConnectionRecorder::expectBlock(), and yarp::os::BinPortable< T >::read().

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

Read some text from the network connection.

Parameters:
terminatingChar The marker for the end of the text
Returns:
the text read from the connection

Implemented in yarp::os::impl::StreamConnectionReader.

Referenced by yarp::os::impl::ConnectionRecorder::expectText().

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::StreamConnectionReader.

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

Referenced by yarp::os::impl::ConnectionRecorder::expectInt(), and yarp::os::PortablePair< HEAD, BODY >::readPair().

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::StreamConnectionReader.

Referenced by yarp::os::impl::ConnectionRecorder::expectDouble().

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::StreamConnectionReader.

Referenced by yarp::os::impl::ConnectionRecorder::init().

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::StreamConnectionReader.

Examples:
port_power/TargetVer3.h.

Referenced by yarp::os::impl::ConnectionRecorder::init(), yarp::os::BinPortable< T >::read(), and yarp::os::PortablePair< HEAD, BODY >::readPair().

virtual int 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::StreamConnectionReader.

Referenced by yarp::os::impl::ConnectionRecorder::getSize().

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 NULL if this cannot be done.

Implemented in yarp::os::impl::StreamConnectionReader.

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

Referenced by yarp::name::NameServerConnectionHandler::apply(), yarp::os::impl::ConnectionRecorder::getWriter(), and RosSlave::read().

virtual Bytes yarp::os::ConnectionReader::readEnvelope (  )  [inline, virtual]

Read a message envelope, if available.

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

Definition at line 107 of file libYARP_OS/include/yarp/os/ConnectionReader.h.

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 NULL

Returns:
The message object, or NULL if not available

Implemented in yarp::os::impl::StreamConnectionReader.

Referenced by yarp::os::impl::ConnectionRecorder::getReference().

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::StreamConnectionReader.

Referenced by yarp::name::NameServerConnectionHandler::apply(), and yarp::os::impl::ConnectionRecorder::getRemoteContact().

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::StreamConnectionReader.

Referenced by yarp::os::impl::ConnectionRecorder::getLocalContact().

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::StreamConnectionReader.

Referenced by yarp::os::impl::ConnectionRecorder::isValid().

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::StreamConnectionReader.

Referenced by yarp::os::impl::ConnectionRecorder::isActive().

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::StreamConnectionReader.

Referenced by yarp::os::impl::ConnectionRecorder::isError().


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines