Connection choreographer. More...
#include <yarp/os/impl/Protocol.h>
Public Member Functions | |
Protocol (TwoWayStream *stream) | |
Constructor. | |
~Protocol () override | |
Destructor. | |
void | setRoute (const Route &route) override |
Set the route associated with this connection. | |
const Route & | getRoute () const override |
TwoWayStream & | getStreams () override |
Access the streams associated with the connection. | |
void | takeStreams (TwoWayStream *streams) override |
Provide streams to be used with the connection. | |
TwoWayStream * | giveStreams () override |
Take ownership of the streams associated with the connection. | |
bool | checkStreams () const override |
Check whether streams are in a good state. | |
void | setReference (yarp::os::Portable *ref) override |
Give a direct pointer to an object being sent on the connection. | |
std::string | getSenderSpecifier () const override |
Extract a name for the sender, if the connection type supports that. | |
const std::string & | getEnvelope () const override |
Read the envelope associated with the current message. | |
void | setRemainingLength (int len) override |
Tell the connection that the given number of bytes are left to be read. | |
Connection & | getConnection () override |
Get the connection whose protocol operations we are managing. | |
Contactable * | getContactable () const override |
Get the port associated with the connection. | |
bool | open (const std::string &name) override |
Start negotiating a carrier, using the given name as our own if a name is needed (this should generally match the name of the associated port). | |
void | close () override |
Negotiate an end to operations. | |
void | interrupt () override |
OutputStream & | getOutputStream () override |
Access the output stream associated with the connection. | |
InputStream & | getInputStream () override |
Access the input stream associated with the connection. | |
void | reply (SizedWriter &writer) override |
Reply to a message we have just read. | |
OutputProtocol & | getOutput () override |
Get an interface for doing write operations on the connection. | |
yarp::os::ConnectionReader & | beginRead () override |
Begin a read operation, with bytes read via the returned yarp::os::ConnectionReader object. | |
void | endRead () override |
End the current read operation, begin by beginRead(). | |
void | suppressReply () override |
Make sure that any attempt to send a reply to input will be denied. | |
bool | setTimeout (double timeout) override |
Set the timeout to be used for network operations. | |
void | setEnvelope (const std::string &str) override |
Set the envelope that will be attached to the next message. | |
Connection & | getReceiver () override |
It is possible to chain a basic connection with a modifier. | |
void | attachPort (yarp::os::Contactable *port) override |
Set the port to be associated with the connection. | |
bool | isReplying () const override |
bool | open (const Route &route) override |
Start negotiating a carrier, using the given route (this should generally match the name of the sending port, the receiving port, and the desired carrier. | |
void | rename (const Route &route) override |
Relabel the route after the fact (e.g. | |
bool | isOk () const override |
Check if the connection is valid and can be used. | |
bool | write (SizedWriter &writer) override |
Write a message on the connection. | |
InputProtocol & | getInput () override |
Get an interface for doing read operations on the connection. | |
void | beginWrite () override |
Notify connection that we intend to write to it. | |
Connection & | getSender () override |
It is possible to chain a basic connection with a modifier. | |
void | willReply () |
Promise that we'll be making a reply. | |
Public Member Functions inherited from yarp::os::OutputProtocol | |
virtual | ~OutputProtocol ()=default |
Destructor. | |
Public Member Functions inherited from yarp::os::InputProtocol | |
virtual | ~InputProtocol ()=default |
Destructor. | |
Public Member Functions inherited from yarp::os::ConnectionState | |
virtual | ~ConnectionState () |
Destructor. | |
OutputStream & | os () |
Shorthand for getOutputStream() | |
InputStream & | is () |
Shorthand for getInputStream() | |
Connection choreographer.
Handles one side of a single YARP connection. The Protocol object for a connection holds its streams (which may change over time) and its carriers (which may be chained).
Definition at line 25 of file Protocol.h.
Protocol::Protocol | ( | TwoWayStream * | stream | ) |
Constructor.
The Protocol object becomes the owner of the provided stream, and will destroy it at some point.
Definition at line 30 of file Protocol.cpp.
|
override |
Destructor.
Definition at line 57 of file Protocol.cpp.
|
overridevirtual |
Set the port to be associated with the connection.
Implements yarp::os::OutputProtocol.
Definition at line 402 of file Protocol.cpp.
|
overridevirtual |
Begin a read operation, with bytes read via the returned yarp::os::ConnectionReader object.
Be sure to call endRead() when done.
Implements yarp::os::InputProtocol.
Definition at line 340 of file Protocol.cpp.
|
overridevirtual |
Notify connection that we intend to write to it.
This only needs to get called once. There is no endWrite().
Implements yarp::os::OutputProtocol.
Definition at line 414 of file Protocol.cpp.
|
overridevirtual |
Check whether streams are in a good state.
Implements yarp::os::ConnectionState.
Definition at line 137 of file Protocol.cpp.
|
overridevirtual |
Negotiate an end to operations.
Implements yarp::os::OutputProtocol.
Definition at line 242 of file Protocol.cpp.
|
overridevirtual |
End the current read operation, begin by beginRead().
Implements yarp::os::InputProtocol.
Definition at line 364 of file Protocol.cpp.
|
overridevirtual |
Get the connection whose protocol operations we are managing.
Implements yarp::os::OutputProtocol.
Definition at line 190 of file Protocol.cpp.
|
overridevirtual |
Get the port associated with the connection.
Implements yarp::os::ConnectionState.
Definition at line 199 of file Protocol.cpp.
|
overridevirtual |
Read the envelope associated with the current message.
Implements yarp::os::ConnectionState.
Definition at line 178 of file Protocol.cpp.
|
overridevirtual |
Get an interface for doing read operations on the connection.
Not all types of connections will support this, check yarp::os::InputProtocol::isOk() on the result.
Implements yarp::os::OutputProtocol.
Definition at line 334 of file Protocol.cpp.
|
overridevirtual |
Access the input stream associated with the connection.
Implements yarp::os::OutputProtocol.
Definition at line 269 of file Protocol.cpp.
|
overridevirtual |
Get an interface for doing write operations on the connection.
Not all types of connections will support this, check yarp::os::OutputProtocol::isOk() on the result.
Implements yarp::os::InputProtocol.
Definition at line 328 of file Protocol.cpp.
|
overridevirtual |
Access the output stream associated with the connection.
Implements yarp::os::OutputProtocol.
Definition at line 263 of file Protocol.cpp.
|
overridevirtual |
It is possible to chain a basic connection with a modifier.
If there is a receiver modifier, this call returns it, otherwise it will return a connection for which yarp::os::Connection::isValid() returns false.
Implements yarp::os::OutputProtocol.
Definition at line 393 of file Protocol.cpp.
Implements yarp::os::OutputProtocol.
Definition at line 110 of file Protocol.cpp.
|
overridevirtual |
It is possible to chain a basic connection with a modifier.
If there is a sender modifier, this call returns it, otherwise it will return a connection for which yarp::os::Connection::isValid() returns false.
Implements yarp::os::OutputProtocol.
Definition at line 420 of file Protocol.cpp.
|
overridevirtual |
Extract a name for the sender, if the connection type supports that.
Implements yarp::os::ConnectionState.
Definition at line 149 of file Protocol.cpp.
|
overridevirtual |
Access the streams associated with the connection.
The connection remains the owner of those streams.
Implements yarp::os::ConnectionState.
Definition at line 116 of file Protocol.cpp.
|
overridevirtual |
Take ownership of the streams associated with the connection.
The connection will never touch them again after this call.
Implements yarp::os::ConnectionState.
Definition at line 131 of file Protocol.cpp.
|
overridevirtual |
Implements yarp::os::OutputProtocol.
Definition at line 248 of file Protocol.cpp.
|
overridevirtual |
Check if the connection is valid and can be used.
Implements yarp::os::OutputProtocol.
Definition at line 281 of file Protocol.cpp.
|
overridevirtual |
Implements yarp::os::InputProtocol.
Definition at line 408 of file Protocol.cpp.
Start negotiating a carrier, using the given route (this should generally match the name of the sending port, the receiving port, and the desired carrier.
Implements yarp::os::OutputProtocol.
Definition at line 224 of file Protocol.cpp.
Start negotiating a carrier, using the given name as our own if a name is needed (this should generally match the name of the associated port).
Implements yarp::os::InputProtocol.
Definition at line 205 of file Protocol.cpp.
Relabel the route after the fact (e.g.
if the direction of initiative switches and the route essentially reverses)
Implements yarp::os::OutputProtocol.
Definition at line 275 of file Protocol.cpp.
|
overridevirtual |
Reply to a message we have just read.
Implements yarp::os::InputProtocol.
Definition at line 320 of file Protocol.cpp.
Set the envelope that will be attached to the next message.
Implements yarp::os::InputProtocol.
Definition at line 387 of file Protocol.cpp.
|
overridevirtual |
Give a direct pointer to an object being sent on the connection.
This allows serialization to be bypassed for local connections.
Implements yarp::os::ConnectionState.
Definition at line 143 of file Protocol.cpp.
Tell the connection that the given number of bytes are left to be read.
This is useful when there is no low-level way to know this.
Implements yarp::os::ConnectionState.
Definition at line 184 of file Protocol.cpp.
Set the route associated with this connection.
Implements yarp::os::ConnectionState.
Definition at line 63 of file Protocol.cpp.
Set the timeout to be used for network operations.
Implements yarp::os::OutputProtocol.
Definition at line 377 of file Protocol.cpp.
|
overridevirtual |
Make sure that any attempt to send a reply to input will be denied.
This is a good thing to do if we know the sender is not expecting a reply.
Implements yarp::os::InputProtocol.
Definition at line 371 of file Protocol.cpp.
|
overridevirtual |
Provide streams to be used with the connection.
The connection becomes the owner of these streams. Any streams already in use are closed and destroyed.
Implements yarp::os::ConnectionState.
Definition at line 122 of file Protocol.cpp.
|
inline |
Promise that we'll be making a reply.
Definition at line 88 of file Protocol.h.
|
overridevirtual |
Write a message on the connection.
If a reply is expected, we wait for one. If an acknowledgement is expected, we wait for one. Replies and acknowledgements are similar, except: replies are at the client payload level, acknowledgements are low-level protocol elements that the client doesn't need to know about.
Implements yarp::os::OutputProtocol.
Definition at line 287 of file Protocol.cpp.