Connection choreographer. More...
#include <yarp/os/impl/Protocol.h>
Public Member Functions | |
Protocol (TwoWayStream *stream) | |
Constructor. More... | |
~Protocol () override | |
Destructor. More... | |
void | setRoute (const Route &route) override |
Set the route associated with this connection. More... | |
const Route & | getRoute () const override |
Get the route associated with this connection. More... | |
TwoWayStream & | getStreams () override |
Access the streams associated with the connection. More... | |
void | takeStreams (TwoWayStream *streams) override |
Provide streams to be used with the connection. More... | |
TwoWayStream * | giveStreams () override |
Take ownership of the streams associated with the connection. More... | |
bool | checkStreams () const override |
Check whether streams are in a good state. More... | |
void | setReference (yarp::os::Portable *ref) override |
Give a direct pointer to an object being sent on the connection. More... | |
std::string | getSenderSpecifier () const override |
Extract a name for the sender, if the connection type supports that. More... | |
const std::string & | getEnvelope () const override |
Read the envelope associated with the current message. More... | |
void | setRemainingLength (int len) override |
Tell the connection that the given number of bytes are left to be read. More... | |
Connection & | getConnection () override |
Access the controller for this connection. More... | |
Contactable * | getContactable () const override |
Get the port associated with the connection. More... | |
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). More... | |
void | close () override |
Negotiate an end to operations. More... | |
void | interrupt () override |
Try to get operations interrupted. More... | |
OutputStream & | getOutputStream () override |
Access the output stream associated with this connection. More... | |
InputStream & | getInputStream () override |
Access the input stream associated with this connection. More... | |
void | reply (SizedWriter &writer) override |
Reply to a message we have just read. More... | |
OutputProtocol & | getOutput () override |
Get an interface for doing write operations on the connection. More... | |
yarp::os::ConnectionReader & | beginRead () override |
Begin a read operation, with bytes read via the returned yarp::os::ConnectionReader object. More... | |
void | endRead () override |
End the current read operation, begin by beginRead(). More... | |
void | suppressReply () override |
Make sure that any attempt to send a reply to input will be denied. More... | |
bool | setTimeout (double timeout) override |
Set the timeout to be used for network operations. More... | |
void | setEnvelope (const std::string &str) override |
Set the envelope that will be attached to the next message. More... | |
Connection & | getReceiver () override |
It is possible to chain a basic connection with a modifier. More... | |
void | attachPort (yarp::os::Contactable *port) override |
Set the port to be associated with the connection. More... | |
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. More... | |
void | rename (const Route &route) override |
Relabel the route after the fact (e.g. More... | |
bool | isOk () const override |
Check if the connection is valid and can be used. More... | |
bool | write (SizedWriter &writer) override |
Write a message on the connection. More... | |
InputProtocol & | getInput () override |
Get an interface for doing read operations on the connection. More... | |
void | beginWrite () override |
Notify connection that we intend to write to it. More... | |
Connection & | getSender () override |
It is possible to chain a basic connection with a modifier. More... | |
void | willReply () |
Promise that we'll be making a reply. More... | |
Public Member Functions inherited from yarp::os::OutputProtocol | |
virtual | ~OutputProtocol ()=default |
Destructor. More... | |
Public Member Functions inherited from yarp::os::InputProtocol | |
virtual | ~InputProtocol ()=default |
Destructor. More... | |
Public Member Functions inherited from yarp::os::ConnectionState | |
virtual | ~ConnectionState () |
Destructor. More... | |
OutputStream & | os () |
Shorthand for getOutputStream() More... | |
InputStream & | is () |
Shorthand for getInputStream() More... | |
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 30 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 33 of file Protocol.cpp.
|
override |
Destructor.
Definition at line 60 of file Protocol.cpp.
|
overridevirtual |
Set the port to be associated with the connection.
Implements yarp::os::InputProtocol.
Definition at line 405 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 343 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 417 of file Protocol.cpp.
|
overridevirtual |
Check whether streams are in a good state.
Implements yarp::os::ConnectionState.
Definition at line 140 of file Protocol.cpp.
|
overridevirtual |
Negotiate an end to operations.
Implements yarp::os::InputProtocol.
Definition at line 245 of file Protocol.cpp.
|
overridevirtual |
End the current read operation, begin by beginRead().
Implements yarp::os::InputProtocol.
Definition at line 367 of file Protocol.cpp.
|
overridevirtual |
Access the controller for this connection.
Implements yarp::os::ConnectionState.
Definition at line 193 of file Protocol.cpp.
|
overridevirtual |
Get the port associated with the connection.
Implements yarp::os::ConnectionState.
Definition at line 202 of file Protocol.cpp.
|
overridevirtual |
Read the envelope associated with the current message.
Implements yarp::os::ConnectionState.
Definition at line 181 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 337 of file Protocol.cpp.
|
overridevirtual |
Access the input stream associated with this connection.
Implements yarp::os::ConnectionState.
Definition at line 272 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 331 of file Protocol.cpp.
|
overridevirtual |
Access the output stream associated with this connection.
Implements yarp::os::ConnectionState.
Definition at line 266 of file Protocol.cpp.
|
overridevirtual |
It is possible to chain a basic connection with a modifier.
If there is a modifier, this call returns it, otherwise it will return a connection for which yarp::os::Connection::isValid() returns false.
Implements yarp::os::InputProtocol.
Definition at line 396 of file Protocol.cpp.
|
overridevirtual |
Get the route associated with this connection.
A route is a triplet of the source port, destination port, and carrier.
Implements yarp::os::ConnectionState.
Definition at line 113 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 423 of file Protocol.cpp.
|
overridevirtual |
Extract a name for the sender, if the connection type supports that.
Implements yarp::os::ConnectionState.
Definition at line 152 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 119 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 134 of file Protocol.cpp.
|
overridevirtual |
Try to get operations interrupted.
Implements yarp::os::InputProtocol.
Definition at line 251 of file Protocol.cpp.
|
overridevirtual |
Check if the connection is valid and can be used.
Implements yarp::os::InputProtocol.
Definition at line 284 of file Protocol.cpp.
|
overridevirtual |
Implements yarp::os::InputProtocol.
Definition at line 411 of file Protocol.cpp.
|
overridevirtual |
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 227 of file Protocol.cpp.
|
overridevirtual |
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 208 of file Protocol.cpp.
|
overridevirtual |
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 278 of file Protocol.cpp.
|
overridevirtual |
Reply to a message we have just read.
Implements yarp::os::InputProtocol.
Definition at line 323 of file Protocol.cpp.
|
overridevirtual |
Set the envelope that will be attached to the next message.
Implements yarp::os::InputProtocol.
Definition at line 390 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 146 of file Protocol.cpp.
|
overridevirtual |
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 187 of file Protocol.cpp.
|
overridevirtual |
Set the route associated with this connection.
Implements yarp::os::ConnectionState.
Definition at line 66 of file Protocol.cpp.
|
overridevirtual |
Set the timeout to be used for network operations.
Implements yarp::os::InputProtocol.
Definition at line 380 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 374 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 125 of file Protocol.cpp.
|
inline |
Promise that we'll be making a reply.
Definition at line 93 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 290 of file Protocol.cpp.