Public Member Functions

yarp::os::ConnectionWriter Class Reference

An interface for writing to a network connection. More...

#include <ConnectionWriter.h>

Inheritance diagram for yarp::os::ConnectionWriter:
yarp::os::impl::BufferedConnectionWriter yarp::os::impl::ConnectionRecorder

Public Member Functions

virtual ~ConnectionWriter ()
 Destructor.
virtual void appendBlock (const char *data, int len)=0
 Send a block of data to the network connection.
virtual void appendInt (int data)=0
 Send a representation of an integer to the network connection.
virtual void appendDouble (double data)=0
 Send a representation of a floating point number to the network connection.
virtual void appendString (const char *str, int terminate= '\n')=0
 Send a character sequence to the network connection.
virtual void appendExternalBlock (const char *data, int len)=0
 Send a block of data to the network connection, without making a copy.
virtual bool isTextMode ()=0
 Check if the connection is text mode.
virtual void declareSizes (int argc, int *argv)=0
 If you can easily determine how many blocks there are in a message, call this first, before anything else.
virtual void setReplyHandler (PortReader &reader)=0
 This sets a handler to deal with replies to the message.
virtual void setReference (Portable *obj)=0
 Stores a direct pointer to the object being sent.
virtual bool convertTextMode ()=0
 Converts a standard description in binary into a textual description, if the connection is in text-mode.
virtual bool isValid ()=0
virtual bool isActive ()=0
virtual bool isError ()=0

Detailed Description

An interface for writing to a network connection.

See also:
Port, PortWriter, ConnectionReader
Examples:

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 29 of file libYARP_OS/include/yarp/os/ConnectionWriter.h.


Constructor & Destructor Documentation

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

Destructor.

Definition at line 35 of file libYARP_OS/include/yarp/os/ConnectionWriter.h.


Member Function Documentation

virtual void yarp::os::ConnectionWriter::appendBlock ( const char *  data,
int  len 
) [pure virtual]

Send a block of data to the network connection.

Since communication may not happen immediately, or may happen multiple times, a copy of this data is made. If you know the block of data will remain valid, and it is a large block of data, please call ConnectionWriter::appendExternalBlock instead.

Parameters:
data the start of the data block
len the length of the data block

Referenced by yarp::os::impl::ConnectionRecorder::appendBlock(), yarp::os::impl::BufferedConnectionWriter::write(), and yarp::os::BinPortable< T >::write().

virtual void yarp::os::ConnectionWriter::appendInt ( int  data  )  [pure virtual]

Send a representation of an integer to the network connection.

Parameters:
data the integer to send
Examples:
port_power/TargetVer2.h, and port_power/TargetVer3.h.

Referenced by yarp::os::impl::ConnectionRecorder::appendInt(), yarp::os::impl::ConnectionRecorder::write(), and yarp::os::PortablePair< HEAD, BODY >::writePair().

virtual void yarp::os::ConnectionWriter::appendDouble ( double  data  )  [pure virtual]

Send a representation of a floating point number to the network connection.

Parameters:
data the floating point number to send

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

virtual void yarp::os::ConnectionWriter::appendString ( const char *  str,
int  terminate = '\n' 
) [pure virtual]

Send a character sequence to the network connection.

Parameters:
str the character sequence to send
terminate the terminating character to use

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

virtual void yarp::os::ConnectionWriter::appendExternalBlock ( const char *  data,
int  len 
) [pure virtual]

Send a block of data to the network connection, without making a copy.

If you are not confident that the block of data will remain valid throughout transmission, then call ConnectionWriter::appendBlock instead.

Parameters:
data the start of the data block
len the length of the data block

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

virtual bool yarp::os::ConnectionWriter::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)

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

virtual void yarp::os::ConnectionWriter::declareSizes ( int  argc,
int *  argv 
) [pure virtual]

If you can easily determine how many blocks there are in a message, call this first, before anything else.

This may improve efficiency in some situations.

Parameters:
argc Number of blocks
argv An array of integers, giving the length of each block

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

virtual void yarp::os::ConnectionWriter::setReplyHandler ( PortReader reader  )  [pure virtual]

This sets a handler to deal with replies to the message.

The handler will be called once per connection. There will be problems for connections using carriers that don't support replies.

Parameters:
reader the object that handles replies.

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

virtual void yarp::os::ConnectionWriter::setReference ( Portable obj  )  [pure virtual]

Stores a direct pointer to the object being sent.

This is useful for local communication, to bypass serialization.

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

virtual bool yarp::os::ConnectionWriter::convertTextMode (  )  [pure virtual]

Converts a standard description in binary into a textual description, if the connection is in text-mode.

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
Examples:
port_power/TargetVer3.h.

Referenced by yarp::os::impl::ConnectionRecorder::fini(), yarp::os::BinPortable< T >::write(), and yarp::os::PortablePair< HEAD, BODY >::writePair().

virtual bool yarp::os::ConnectionWriter::isValid (  )  [pure virtual]
Returns:
true if the writer is valid. A writer may be invalid if a connection has closed.

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

virtual bool yarp::os::ConnectionWriter::isActive (  )  [pure virtual]
Returns:
true if the writer is active. Writers may become inactive if the connection they are associated with breaks.

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

virtual bool yarp::os::ConnectionWriter::isError (  )  [pure virtual]
Returns:
true if the writer encountered an error. Writers 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.

Referenced by yarp::os::impl::ConnectionRecorder::isError(), and yarp::os::impl::BufferedConnectionWriter::write().


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