An interface for writing to a network connection. More...
#include <yarp/os/ConnectionWriter.h>
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) final |
Send a representation of an integer to the network connection. More... | |
virtual void | appendInt8 (std::int8_t data)=0 |
Send a representation of a 8-bit integer to the network connection. More... | |
virtual void | appendInt16 (std::int16_t data)=0 |
Send a representation of a 16-bit integer to the network connection. More... | |
virtual void | appendInt32 (std::int32_t data)=0 |
Send a representation of a 32-bit integer to the network connection. More... | |
virtual void | appendInt64 (std::int64_t data)=0 |
Send a representation of a 64-bit integer to the network connection. More... | |
virtual void | appendDouble (double data) |
Send a representation of a floating point number to the network connection. More... | |
virtual void | appendFloat32 (yarp::conf::float32_t data)=0 |
Send a representation of a 32-bit floating point number to the network connection. More... | |
virtual void | appendFloat64 (yarp::conf::float64_t data)=0 |
Send a representation of a 64-bit floating point number to the network connection. More... | |
virtual void | appendString (const char *str, const char terminate='\n') final |
Send a character sequence to the network connection. More... | |
virtual void | appendText (const std::string &str, const char terminate='\n')=0 |
Send a terminated string to the network connection. More... | |
virtual void | appendRawString (const std::string &str) final |
void | appendString (const std::string &str) |
Send a string 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 () const =0 |
Check if the connection is text mode. More... | |
virtual bool | isBareMode () const =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 () const =0 |
virtual bool | isActive () const =0 |
virtual bool | isError () const =0 |
virtual void | requestDrop ()=0 |
Tag the connection to be dropped after the current message. More... | |
virtual bool | isNull () const |
virtual SizedWriter * | getBuffer () const =0 |
Static Public Member Functions | |
static ConnectionWriter * | createBufferedConnectionWriter () |
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) |
An interface for writing to a network connection.
Definition at line 39 of file ConnectionWriter.h.
|
virtualdefault |
Destructor.
|
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.
data | the start of the data block |
len | the length of the data block |
Implemented in yarp::os::NullConnectionWriter, yarp::os::impl::ConnectionRecorder, and yarp::os::impl::BufferedConnectionWriter.
|
inlinevirtual |
Send a representation of a floating point number to the network connection.
data | the floating point number to send |
Definition at line 102 of file ConnectionWriter.h.
|
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, call ConnectionWriter::appendBlock instead.
data | the start of the data block |
len | the length of the data block |
Implemented in yarp::os::NullConnectionWriter, yarp::os::impl::ConnectionRecorder, and yarp::os::impl::BufferedConnectionWriter.
|
pure virtual |
Send a representation of a 32-bit floating point number to the network connection.
data | the floating point number to send |
Implemented in yarp::os::NullConnectionWriter, yarp::os::impl::ConnectionRecorder, and yarp::os::impl::BufferedConnectionWriter.
|
pure virtual |
Send a representation of a 64-bit floating point number to the network connection.
data | the floating point number to send |
Implemented in yarp::os::NullConnectionWriter, yarp::os::impl::ConnectionRecorder, and yarp::os::impl::BufferedConnectionWriter.
|
inlinefinalvirtual |
Send a representation of an integer to the network connection.
data | the integer to send |
Definition at line 65 of file ConnectionWriter.h.
|
pure virtual |
Send a representation of a 16-bit integer to the network connection.
data | the integer to send |
Implemented in yarp::os::NullConnectionWriter, yarp::os::impl::ConnectionRecorder, and yarp::os::impl::BufferedConnectionWriter.
|
pure virtual |
Send a representation of a 32-bit integer to the network connection.
data | the integer to send |
Implemented in yarp::os::NullConnectionWriter, yarp::os::impl::ConnectionRecorder, and yarp::os::impl::BufferedConnectionWriter.
|
pure virtual |
Send a representation of a 64-bit integer to the network connection.
data | the integer to send |
Implemented in yarp::os::NullConnectionWriter, yarp::os::impl::ConnectionRecorder, and yarp::os::impl::BufferedConnectionWriter.
|
pure virtual |
Send a representation of a 8-bit integer to the network connection.
data | the integer to send |
Implemented in yarp::os::NullConnectionWriter, yarp::os::impl::ConnectionRecorder, and yarp::os::impl::BufferedConnectionWriter.
|
inlinefinalvirtual |
Definition at line 150 of file ConnectionWriter.h.
|
inlinefinalvirtual |
Send a character sequence to the network connection.
str | the character sequence to send |
terminate | the terminating character to use |
Definition at line 131 of file ConnectionWriter.h.
|
inline |
Send a string to the network connection.
The lenght of string is not specified in advance, therefore the reader should read the number of bytes specified by the first integer. The string terminating character (normally '\0') is not transmitted.
str | the string to send |
Definition at line 165 of file ConnectionWriter.h.
|
pure virtual |
Send a terminated string to the network connection.
The lenght of string is not specified in advance, therefore the reader should read until the terminating character is found.
str | the string to send |
terminate | the terminating character to use |
Implemented in yarp::os::NullConnectionWriter, yarp::os::impl::BufferedConnectionWriter, and yarp::os::impl::ConnectionRecorder.
|
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.
Implemented in yarp::os::NullConnectionWriter, yarp::os::impl::ConnectionRecorder, and yarp::os::impl::BufferedConnectionWriter.
|
static |
Create a connection writer implementation that stores to a buffer which can be read later using getBuffer()
Definition at line 25 of file ConnectionWriter.cpp.
|
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.
argc | Number of blocks |
argv | An array of integers, giving the length of each block |
Implemented in yarp::os::NullConnectionWriter, yarp::os::impl::ConnectionRecorder, and yarp::os::impl::BufferedConnectionWriter.
|
pure virtual |
Implemented in yarp::os::NullConnectionWriter, yarp::os::impl::ConnectionRecorder, and yarp::os::impl::BufferedConnectionWriter.
|
pure virtual |
Implemented in yarp::os::NullConnectionWriter, yarp::os::impl::ConnectionRecorder, and yarp::os::impl::BufferedConnectionWriter.
|
pure virtual |
Check if the connection is bare mode.
If it is, you are encouraged to omit type information from your serialization.
Implemented in yarp::os::NullConnectionWriter, yarp::os::impl::ConnectionRecorder, and yarp::os::impl::BufferedConnectionWriter.
|
pure virtual |
Implemented in yarp::os::NullConnectionWriter, yarp::os::impl::ConnectionRecorder, and yarp::os::impl::BufferedConnectionWriter.
|
virtual |
Reimplemented in yarp::os::NullConnectionWriter.
Definition at line 19 of file ConnectionWriter.cpp.
|
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.
Implemented in yarp::os::NullConnectionWriter, yarp::os::impl::ConnectionRecorder, and yarp::os::impl::BufferedConnectionWriter.
|
pure virtual |
Implemented in yarp::os::NullConnectionWriter, yarp::os::impl::ConnectionRecorder, and yarp::os::impl::BufferedConnectionWriter.
|
pure virtual |
Tag the connection to be dropped after the current message.
Implemented in yarp::os::NullConnectionWriter, yarp::os::impl::ConnectionRecorder, and yarp::os::impl::BufferedConnectionWriter.
|
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.
|
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.
reader | the object that handles replies. |
Implemented in yarp::os::impl::ConnectionRecorder, yarp::os::NullConnectionWriter, and yarp::os::impl::BufferedConnectionWriter.
|
static |
Definition at line 30 of file ConnectionWriter.cpp.