A helper for recording entire message/reply transactions. More...
#include <yarp/os/impl/ConnectionRecorder.h>
Inheritance diagram for yarp::os::impl::ConnectionRecorder:Public Member Functions | |
| ConnectionRecorder () | |
| void | init (yarp::os::ConnectionReader *wrappedReader) |
| Call this to wrap a specific ConnectionReader. | |
| void | fini () |
| Call this when all reading/writing has been done. | |
| 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. | |
| std::string | expectText (const char terminatingChar) override |
| Read some text from the network connection. | |
| std::int8_t | expectInt8 () override |
| Read a 8-bit integer from the network connection. | |
| std::int16_t | expectInt16 () override |
| Read a 16-bit integer from the network connection. | |
| std::int32_t | expectInt32 () override |
| Read a 32-bit integer from the network connection. | |
| std::int64_t | expectInt64 () override |
| Read a 64-bit integer from the network connection. | |
| yarp::conf::float32_t | expectFloat32 () override |
| Read a 32-bit floating point number from the network connection. | |
| yarp::conf::float64_t | expectFloat64 () override |
| Read a 64-bit floating point number from the network connection. | |
| bool | pushInt (int x) override |
| Store an integer to return on the next call to expectInt() | |
| bool | isTextMode () const override |
| Check if the connection is text mode. | |
| bool | isBareMode () const override |
| Check if the connection is bare mode. | |
| bool | convertTextMode () override |
| Reads in a standard description in text mode, and converts it to a standard description in binary. | |
| size_t | getSize () const override |
| Checks how much data is available. | |
| yarp::os::ConnectionWriter * | getWriter () override |
| Gets a way to reply to the message, if possible. | |
| yarp::os::Portable * | getReference () const override |
| Get a direct pointer to the object being sent, if possible. | |
| yarp::os::Contact | getRemoteContact () const override |
| Gets information about who is supplying the data being read, if that information is available. | |
| yarp::os::Contact | getLocalContact () const override |
| Gets information about who is receiving the data, if that information is available. | |
| 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. | |
| void | appendInt8 (std::int8_t data) override |
| Send a representation of a 8-bit integer to the network connection. | |
| void | appendInt16 (std::int16_t data) override |
| Send a representation of a 16-bit integer to the network connection. | |
| void | appendInt32 (std::int32_t data) override |
| Send a representation of a 32-bit integer to the network connection. | |
| void | appendInt64 (std::int64_t data) override |
| Send a representation of a 64-bit integer to the network connection. | |
| void | appendFloat32 (yarp::conf::float32_t data) override |
| Send a representation of a 32-bit floating point number to the network connection. | |
| void | appendFloat64 (yarp::conf::float64_t data) override |
| Send a representation of a 64-bit floating point number to the network connection. | |
| void | appendText (const std::string &str, const char terminate) override |
| Send a terminated string to the network connection. | |
| void | appendExternalBlock (const char *data, size_t len) override |
| Send a block of data to the network connection, without making a copy. | |
| 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. | |
| void | setReplyHandler (yarp::os::PortReader &reader) override |
| This sets a handler to deal with replies to the message. | |
| void | setReference (yarp::os::Portable *obj) override |
| Stores a direct pointer to the object being sent. | |
| bool | write (yarp::os::ConnectionWriter &connection) const override |
| Write this object to a network connection. | |
| void | requestDrop () override |
| Tag the connection to be dropped after the current message. | |
| const yarp::os::Searchable & | getConnectionModifiers () const override |
| Access modifiers associated with the connection, if any. | |
| yarp::os::SizedWriter * | getBuffer () override |
| const yarp::os::SizedWriter * | getBuffer () const override |
| bool | setSize (size_t len) override |
| void | flushWriter () override |
Public Member Functions inherited from yarp::os::ConnectionReader | |
| virtual | ~ConnectionReader () |
| Destructor. | |
| virtual std::string | expectString () |
| Read a string from the network connection. | |
| virtual Bytes | readEnvelope () |
| Read a message envelope, if available. | |
| virtual void | setParentConnectionReader (ConnectionReader *parentConnectionReader) |
| Set ConnectionReader to be used for reading the envelope. | |
Public Member Functions inherited from yarp::os::ConnectionWriter | |
| virtual | ~ConnectionWriter () |
| Destructor. | |
| void | appendString (const std::string &str) |
| Send a string to the network connection. | |
| virtual bool | isNull () const |
Public Member Functions inherited from yarp::os::PortWriter | |
| virtual | ~PortWriter () |
| Destructor. | |
| virtual void | onCompletion () const |
| This is called when the port has finished all writing operations. | |
| virtual void | onCommencement () const |
| This is called when the port is about to begin writing operations. | |
| 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. | |
| 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() | |
| static bool | writeToStream (PortWriter &portable, OutputStream &os) |
A helper for recording entire message/reply transactions.
Definition at line 22 of file ConnectionRecorder.h.
| yarp::os::impl::ConnectionRecorder::ConnectionRecorder | ( | ) |
Definition at line 11 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 193 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 241 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 223 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 229 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 205 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 211 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 217 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 199 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 235 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 133 of file ConnectionRecorder.cpp.
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 247 of file ConnectionRecorder.cpp.
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 54 of file ConnectionRecorder.cpp.
|
overridevirtual |
Read a 32-bit floating point number from the network connection.
Implements yarp::os::ConnectionReader.
Definition at line 102 of file ConnectionRecorder.cpp.
|
overridevirtual |
Read a 64-bit floating point number from the network connection.
Implements yarp::os::ConnectionReader.
Definition at line 109 of file ConnectionRecorder.cpp.
|
overridevirtual |
Read a 16-bit integer from the network connection.
Implements yarp::os::ConnectionReader.
Definition at line 77 of file ConnectionRecorder.cpp.
|
overridevirtual |
Read a 32-bit integer from the network connection.
Implements yarp::os::ConnectionReader.
Definition at line 84 of file ConnectionRecorder.cpp.
|
overridevirtual |
Read a 64-bit integer from the network connection.
Implements yarp::os::ConnectionReader.
Definition at line 95 of file ConnectionRecorder.cpp.
|
overridevirtual |
Read a 8-bit integer from the network connection.
Implements yarp::os::ConnectionReader.
Definition at line 70 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 63 of file ConnectionRecorder.cpp.
| void yarp::os::impl::ConnectionRecorder::fini | ( | ) |
Call this when all reading/writing has been done.
Definition at line 29 of file ConnectionRecorder.cpp.
|
overridevirtual |
Implements yarp::os::ConnectionReader.
Definition at line 303 of file ConnectionRecorder.cpp.
|
overridevirtual |
Implements yarp::os::ConnectionWriter.
Definition at line 293 of file ConnectionRecorder.cpp.
|
overridevirtual |
Implements yarp::os::ConnectionWriter.
Definition at line 288 of file ConnectionRecorder.cpp.
|
overridevirtual |
Access modifiers associated with the connection, if any.
Implements yarp::os::ConnectionReader.
Definition at line 282 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 161 of file ConnectionRecorder.cpp.
| const yarp::os::impl::BufferedConnectionWriter & yarp::os::impl::ConnectionRecorder::getMessage | ( | ) | const |
Definition at line 39 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 151 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 156 of file ConnectionRecorder.cpp.
| const yarp::os::impl::BufferedConnectionWriter & yarp::os::impl::ConnectionRecorder::getReply | ( | ) | const |
Definition at line 44 of file ConnectionRecorder.cpp.
|
overridevirtual |
Checks how much data is available.
Implements yarp::os::ConnectionReader.
Definition at line 138 of file ConnectionRecorder.cpp.
|
overridevirtual |
Gets a way to reply to the message, if possible.
Implements yarp::os::ConnectionReader.
Definition at line 143 of file ConnectionRecorder.cpp.
| bool yarp::os::impl::ConnectionRecorder::hasReply | ( | ) | const |
Definition at line 49 of file ConnectionRecorder.cpp.
| void yarp::os::impl::ConnectionRecorder::init | ( | yarp::os::ConnectionReader * | wrappedReader | ) |
Call this to wrap a specific ConnectionReader.
Definition at line 20 of file ConnectionRecorder.cpp.
|
overridevirtual |
Implements yarp::os::ConnectionReader.
Definition at line 175 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 128 of file ConnectionRecorder.cpp.
|
overridevirtual |
Implements yarp::os::ConnectionReader.
Definition at line 184 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 123 of file ConnectionRecorder.cpp.
|
overridevirtual |
Implements yarp::os::ConnectionReader.
Definition at line 166 of file ConnectionRecorder.cpp.
Store an integer to return on the next call to expectInt()
| x | the integer to store |
Implements yarp::os::ConnectionReader.
Definition at line 116 of file ConnectionRecorder.cpp.
|
overridevirtual |
Tag the connection to be dropped after the current message.
Implements yarp::os::ConnectionReader.
Definition at line 278 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 257 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 252 of file ConnectionRecorder.cpp.
Implements yarp::os::ConnectionReader.
Definition at line 298 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 262 of file ConnectionRecorder.cpp.