A helper for recording entire message/reply transactions. More...
#include <yarp/os/impl/ConnectionRecorder.h>
Public Member Functions | |
ConnectionRecorder () | |
void | init (yarp::os::ConnectionReader *wrappedReader) |
Call this to wrap a specific ConnectionReader. More... | |
void | fini () |
Call this when all reading/writing has been done. More... | |
const yarp::os::impl::BufferedConnectionWriter & | getMessage () const |
const yarp::os::impl::BufferedConnectionWriter & | getReply () const |
bool | hasReply () const |
bool | expectBlock (char *data, size_t len) override |
Read a block of data from the network connection. More... | |
std::string | expectText (const char terminatingChar) override |
Read some text from the network connection. More... | |
std::int8_t | expectInt8 () override |
Read a 8-bit integer from the network connection. More... | |
std::int16_t | expectInt16 () override |
Read a 16-bit integer from the network connection. More... | |
std::int32_t | expectInt32 () override |
Read a 32-bit integer from the network connection. More... | |
std::int64_t | expectInt64 () override |
Read a 64-bit integer from the network connection. More... | |
yarp::conf::float32_t | expectFloat32 () override |
Read a 32-bit floating point number from the network connection. More... | |
yarp::conf::float64_t | expectFloat64 () override |
Read a 64-bit floating point number from the network connection. More... | |
bool | pushInt (int x) override |
Store an integer to return on the next call to expectInt() More... | |
bool | isTextMode () const override |
Check if the connection is text mode. More... | |
bool | isBareMode () const override |
Check if the connection is bare mode. More... | |
bool | convertTextMode () override |
Reads in a standard description in text mode, and converts it to a standard description in binary. More... | |
size_t | getSize () const override |
Checks how much data is available. More... | |
yarp::os::ConnectionWriter * | getWriter () override |
Gets a way to reply to the message, if possible. More... | |
yarp::os::Portable * | getReference () const override |
Get a direct pointer to the object being sent, if possible. More... | |
yarp::os::Contact | getRemoteContact () const override |
Gets information about who is supplying the data being read, if that information is available. More... | |
yarp::os::Contact | getLocalContact () const override |
Gets information about who is receiving the data, if that information is available. More... | |
bool | isValid () const override |
bool | isActive () const override |
bool | isError () const override |
void | appendBlock (const char *data, size_t len) override |
Send a block of data to the network connection. More... | |
void | appendInt8 (std::int8_t data) override |
Send a representation of a 8-bit integer to the network connection. More... | |
void | appendInt16 (std::int16_t data) override |
Send a representation of a 16-bit integer to the network connection. More... | |
void | appendInt32 (std::int32_t data) override |
Send a representation of a 32-bit integer to the network connection. More... | |
void | appendInt64 (std::int64_t data) override |
Send a representation of a 64-bit integer to the network connection. More... | |
void | appendFloat32 (yarp::conf::float32_t data) override |
Send a representation of a 32-bit floating point number to the network connection. More... | |
void | appendFloat64 (yarp::conf::float64_t data) override |
Send a representation of a 64-bit floating point number to the network connection. More... | |
void | appendText (const std::string &str, const char terminate) override |
Send a terminated string to the network connection. More... | |
void | appendExternalBlock (const char *data, size_t len) override |
Send a block of data to the network connection, without making a copy. More... | |
void | declareSizes (int argc, int *argv) override |
If you can easily determine how many blocks there are in a message, call this first, before anything else. More... | |
void | setReplyHandler (yarp::os::PortReader &reader) override |
This sets a handler to deal with replies to the message. More... | |
void | setReference (yarp::os::Portable *obj) override |
Stores a direct pointer to the object being sent. More... | |
bool | write (yarp::os::ConnectionWriter &connection) const override |
Write this object to a network connection. More... | |
void | requestDrop () override |
Tag the connection to be dropped after the current message. More... | |
const yarp::os::Searchable & | getConnectionModifiers () const override |
Access modifiers associated with the connection, if any. More... | |
yarp::os::SizedWriter * | getBuffer () const override |
bool | setSize (size_t len) override |
Public Member Functions inherited from yarp::os::ConnectionReader | |
virtual | ~ConnectionReader () |
Destructor. More... | |
virtual std::string | expectString () |
Read a string from the network connection. More... | |
virtual int | expectInt () final |
Read an integer from the network connection. More... | |
virtual double | expectDouble () |
Read a floating point number from the network connection. More... | |
virtual Bytes | readEnvelope () |
Read a message envelope, if available. More... | |
virtual void | setParentConnectionReader (ConnectionReader *parentConnectionReader) |
Set ConnectionReader to be used for reading the envelope. More... | |
Public Member Functions inherited from yarp::os::ConnectionWriter | |
virtual | ~ConnectionWriter () |
Destructor. More... | |
virtual void | appendInt (int data) final |
Send a representation of an 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 | appendString (const char *str, const char terminate='\n') final |
Send a character sequence 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 bool | isNull () const |
Public Member Functions inherited from yarp::os::PortWriter | |
virtual | ~PortWriter () |
Destructor. More... | |
virtual void | onCompletion () const |
This is called when the port has finished all writing operations. More... | |
virtual void | onCommencement () const |
This is called when the port is about to begin writing operations. More... | |
virtual yarp::os::Type | getWriteType () const |
Additional Inherited Members | |
Static Public Member Functions inherited from yarp::os::ConnectionReader | |
static ConnectionReader * | createConnectionReader (InputStream &is) |
Create an instance of YARP's standard connection reader implementation. More... | |
static bool | readFromStream (PortReader &portable, InputStream &is) |
Static Public Member Functions inherited from yarp::os::ConnectionWriter | |
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) |
A helper for recording entire message/reply transactions.
Definition at line 27 of file ConnectionRecorder.h.
yarp::os::impl::ConnectionRecorder::ConnectionRecorder | ( | ) |
Definition at line 14 of file ConnectionRecorder.cpp.
|
overridevirtual |
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 |
Implements yarp::os::ConnectionWriter.
Definition at line 196 of file ConnectionRecorder.cpp.
|
overridevirtual |
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 |
Implements yarp::os::ConnectionWriter.
Definition at line 244 of file ConnectionRecorder.cpp.
|
overridevirtual |
Send a representation of a 32-bit floating point number to the network connection.
data | the floating point number to send |
Implements yarp::os::ConnectionWriter.
Definition at line 226 of file ConnectionRecorder.cpp.
|
overridevirtual |
Send a representation of a 64-bit floating point number to the network connection.
data | the floating point number to send |
Implements yarp::os::ConnectionWriter.
Definition at line 232 of file ConnectionRecorder.cpp.
|
overridevirtual |
Send a representation of a 16-bit integer to the network connection.
data | the integer to send |
Implements yarp::os::ConnectionWriter.
Definition at line 208 of file ConnectionRecorder.cpp.
|
overridevirtual |
Send a representation of a 32-bit integer to the network connection.
data | the integer to send |
Implements yarp::os::ConnectionWriter.
Definition at line 214 of file ConnectionRecorder.cpp.
|
overridevirtual |
Send a representation of a 64-bit integer to the network connection.
data | the integer to send |
Implements yarp::os::ConnectionWriter.
Definition at line 220 of file ConnectionRecorder.cpp.
|
overridevirtual |
Send a representation of a 8-bit integer to the network connection.
data | the integer to send |
Implements yarp::os::ConnectionWriter.
Definition at line 202 of file ConnectionRecorder.cpp.
|
overridevirtual |
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 |
Implements yarp::os::ConnectionWriter.
Definition at line 238 of file ConnectionRecorder.cpp.
|
overridevirtual |
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.
Implements yarp::os::ConnectionReader.
Definition at line 136 of file ConnectionRecorder.cpp.
|
overridevirtual |
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 |
Implements yarp::os::ConnectionWriter.
Definition at line 250 of file ConnectionRecorder.cpp.
|
overridevirtual |
Read a block of data from the network connection.
data | Start of the block of data |
len | Length of the block of data |
Implements yarp::os::ConnectionReader.
Definition at line 57 of file ConnectionRecorder.cpp.
|
overridevirtual |
Read a 32-bit floating point number from the network connection.
Implements yarp::os::ConnectionReader.
Definition at line 105 of file ConnectionRecorder.cpp.
|
overridevirtual |
Read a 64-bit floating point number from the network connection.
Implements yarp::os::ConnectionReader.
Definition at line 112 of file ConnectionRecorder.cpp.
|
overridevirtual |
Read a 16-bit integer from the network connection.
Implements yarp::os::ConnectionReader.
Definition at line 80 of file ConnectionRecorder.cpp.
|
overridevirtual |
Read a 32-bit integer from the network connection.
Implements yarp::os::ConnectionReader.
Definition at line 87 of file ConnectionRecorder.cpp.
|
overridevirtual |
Read a 64-bit integer from the network connection.
Implements yarp::os::ConnectionReader.
Definition at line 98 of file ConnectionRecorder.cpp.
|
overridevirtual |
Read a 8-bit integer from the network connection.
Implements yarp::os::ConnectionReader.
Definition at line 73 of file ConnectionRecorder.cpp.
|
overridevirtual |
Read some text from the network connection.
terminatingChar | The marker for the end of the text |
Implements yarp::os::ConnectionReader.
Definition at line 66 of file ConnectionRecorder.cpp.
void yarp::os::impl::ConnectionRecorder::fini | ( | ) |
Call this when all reading/writing has been done.
Definition at line 32 of file ConnectionRecorder.cpp.
|
overridevirtual |
Implements yarp::os::ConnectionWriter.
Definition at line 291 of file ConnectionRecorder.cpp.
|
overridevirtual |
Access modifiers associated with the connection, if any.
Implements yarp::os::ConnectionReader.
Definition at line 285 of file ConnectionRecorder.cpp.
|
overridevirtual |
Gets information about who is receiving the data, if that information is available.
Implements yarp::os::ConnectionReader.
Definition at line 164 of file ConnectionRecorder.cpp.
const yarp::os::impl::BufferedConnectionWriter & yarp::os::impl::ConnectionRecorder::getMessage | ( | ) | const |
Definition at line 42 of file ConnectionRecorder.cpp.
|
overridevirtual |
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 nullptr.
Implements yarp::os::ConnectionReader.
Definition at line 154 of file ConnectionRecorder.cpp.
|
overridevirtual |
Gets information about who is supplying the data being read, if that information is available.
Implements yarp::os::ConnectionReader.
Definition at line 159 of file ConnectionRecorder.cpp.
const yarp::os::impl::BufferedConnectionWriter & yarp::os::impl::ConnectionRecorder::getReply | ( | ) | const |
Definition at line 47 of file ConnectionRecorder.cpp.
|
overridevirtual |
Checks how much data is available.
Implements yarp::os::ConnectionReader.
Definition at line 141 of file ConnectionRecorder.cpp.
|
overridevirtual |
Gets a way to reply to the message, if possible.
Implements yarp::os::ConnectionReader.
Definition at line 146 of file ConnectionRecorder.cpp.
bool yarp::os::impl::ConnectionRecorder::hasReply | ( | ) | const |
Definition at line 52 of file ConnectionRecorder.cpp.
void yarp::os::impl::ConnectionRecorder::init | ( | yarp::os::ConnectionReader * | wrappedReader | ) |
Call this to wrap a specific ConnectionReader.
Definition at line 23 of file ConnectionRecorder.cpp.
|
overridevirtual |
Implements yarp::os::ConnectionReader.
Definition at line 178 of file ConnectionRecorder.cpp.
|
overridevirtual |
Check if the connection is bare mode.
If it is, you are encouraged to omit type information from your serialization.
Implements yarp::os::ConnectionReader.
Definition at line 131 of file ConnectionRecorder.cpp.
|
overridevirtual |
Implements yarp::os::ConnectionReader.
Definition at line 187 of file ConnectionRecorder.cpp.
|
overridevirtual |
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.
Implements yarp::os::ConnectionReader.
Definition at line 126 of file ConnectionRecorder.cpp.
|
overridevirtual |
Implements yarp::os::ConnectionReader.
Definition at line 169 of file ConnectionRecorder.cpp.
|
overridevirtual |
Store an integer to return on the next call to expectInt()
x | the integer to store |
Implements yarp::os::ConnectionReader.
Definition at line 119 of file ConnectionRecorder.cpp.
|
overridevirtual |
Tag the connection to be dropped after the current message.
Implements yarp::os::ConnectionReader.
Definition at line 281 of file ConnectionRecorder.cpp.
|
overridevirtual |
Stores a direct pointer to the object being sent.
This is useful for local communication, to bypass serialization.
Implements yarp::os::ConnectionWriter.
Definition at line 260 of file ConnectionRecorder.cpp.
|
overridevirtual |
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. |
Implements yarp::os::ConnectionWriter.
Definition at line 255 of file ConnectionRecorder.cpp.
|
overridevirtual |
Implements yarp::os::ConnectionReader.
Definition at line 296 of file ConnectionRecorder.cpp.
|
overridevirtual |
Write this object to a network connection.
Override this for your particular class. Be aware that depending on the nature of the connections a port has, and what protocol they use, and how efficient the YARP implementation is, this method may be called once, twice, or many times, as the result of a single call to Port::write
writer | an interface to the network connection for writing |
Implements yarp::os::PortWriter.
Definition at line 265 of file ConnectionRecorder.cpp.