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

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

#include <yarp/os/ConnectionWriter.h>

+ Inheritance diagram for yarp::os::ConnectionWriter:

Public Member Functions

virtual ~ConnectionWriter ()
 Destructor. More...
 
virtual void appendBlock (const char *data, size_t len)=0
 Send a block of data to the network connection. More...
 
virtual void appendInt (int data)=0
 Send a representation of an integer to the network connection. More...
 
virtual void appendInt64 (const YARP_INT64 &data)=0
 Send a representation of a 64-bit integer to the network connection. More...
 
virtual void appendDouble (double data)=0
 Send a representation of a floating point number to the network connection. More...
 
virtual void appendString (const char *str, int terminate='\n')=0
 Send a character sequence to the network connection. More...
 
virtual void appendExternalBlock (const char *data, size_t len)=0
 Send a block of data to the network connection, without making a copy. 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 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. More...
 
virtual void setReplyHandler (PortReader &reader)=0
 This sets a handler to deal with replies to the message. More...
 
virtual void setReference (Portable *obj)=0
 Stores a direct pointer to the object being sent. More...
 
virtual bool convertTextMode ()=0
 Converts a standard description in binary into a textual description, if the connection is in text-mode. 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 bool isNull () const
 
virtual SizedWritergetBuffer ()=0
 
virtual void appendRawString (const ConstString &str)
 

Static Public Member Functions

static ConnectionWritercreateBufferedConnectionWriter ()
 Create a connection writer implementation that stores to a buffer which can be read later using getBuffer() More...
 
static bool writeToStream (PortWriter &portable, OutputStream &os)
 

Detailed Description

Constructor & Destructor Documentation

◆ ~ConnectionWriter()

ConnectionWriter::~ConnectionWriter ( )
virtual

Destructor.

Definition at line 13 of file ConnectionWriter.cpp.

Member Function Documentation

◆ appendBlock()

virtual void yarp::os::ConnectionWriter::appendBlock ( const char *  data,
size_t  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
datathe start of the data block
lenthe length of the data block

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::BufferedConnectionWriter, and yarp::os::NullConnectionWriter.

◆ appendDouble()

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

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

Parameters
datathe floating point number to send

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::BufferedConnectionWriter, and yarp::os::NullConnectionWriter.

◆ appendExternalBlock()

virtual void yarp::os::ConnectionWriter::appendExternalBlock ( const char *  data,
size_t  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
datathe start of the data block
lenthe length of the data block

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::BufferedConnectionWriter, and yarp::os::NullConnectionWriter.

◆ appendInt()

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

Send a representation of an integer to the network connection.

Parameters
datathe integer to send

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::BufferedConnectionWriter, and yarp::os::NullConnectionWriter.

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

◆ appendInt64()

virtual void yarp::os::ConnectionWriter::appendInt64 ( const YARP_INT64 &  data)
pure virtual

Send a representation of a 64-bit integer to the network connection.

Parameters
datathe integer to send

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::BufferedConnectionWriter, and yarp::os::NullConnectionWriter.

◆ appendRawString()

virtual void yarp::os::ConnectionWriter::appendRawString ( const ConstString str)
inlinevirtual

Definition at line 182 of file ConnectionWriter.h.

◆ appendString()

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

Send a character sequence to the network connection.

Parameters
strthe character sequence to send
terminatethe terminating character to use

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::BufferedConnectionWriter, and yarp::os::NullConnectionWriter.

◆ convertTextMode()

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

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::BufferedConnectionWriter, and yarp::os::NullConnectionWriter.

Examples:
port_power/TargetVer3.h.

◆ createBufferedConnectionWriter()

ConnectionWriter * ConnectionWriter::createBufferedConnectionWriter ( )
static

Create a connection writer implementation that stores to a buffer which can be read later using getBuffer()

Definition at line 21 of file ConnectionWriter.cpp.

◆ declareSizes()

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
argcNumber of blocks
argvAn array of integers, giving the length of each block

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::BufferedConnectionWriter, and yarp::os::NullConnectionWriter.

◆ getBuffer()

virtual SizedWriter* yarp::os::ConnectionWriter::getBuffer ( )
pure virtual

◆ isActive()

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.

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::BufferedConnectionWriter, and yarp::os::NullConnectionWriter.

◆ isBareMode()

virtual bool yarp::os::ConnectionWriter::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::BufferedConnectionWriter, and yarp::os::NullConnectionWriter.

◆ isError()

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.

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::BufferedConnectionWriter, and yarp::os::NullConnectionWriter.

◆ isNull()

bool ConnectionWriter::isNull ( ) const
virtual
Returns
true if writer goes nowhere.

Reimplemented in yarp::os::NullConnectionWriter.

Definition at line 16 of file ConnectionWriter.cpp.

◆ isTextMode()

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)

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::BufferedConnectionWriter, and yarp::os::NullConnectionWriter.

◆ isValid()

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.

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::BufferedConnectionWriter, and yarp::os::NullConnectionWriter.

◆ requestDrop()

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

Tag the connection to be dropped after the current message.

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::BufferedConnectionWriter, and yarp::os::NullConnectionWriter.

◆ setReference()

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.

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::BufferedConnectionWriter, and yarp::os::NullConnectionWriter.

◆ setReplyHandler()

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
readerthe object that handles replies.

Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::impl::BufferedConnectionWriter, and yarp::os::NullConnectionWriter.

◆ writeToStream()

bool ConnectionWriter::writeToStream ( PortWriter portable,
OutputStream os 
)
static

Definition at line 25 of file ConnectionWriter.cpp.


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