A base class for connection types (tcp, mcast, shmem, ...) which are called carriers in YARP. More...
#include <yarp/os/Carrier.h>
Public Member Functions | |
virtual Carrier * | create () const =0 |
Factory method. More... | |
virtual bool | checkHeader (const Bytes &header)=0 |
Given the first 8 bytes received on a connection, decide if this is the right carrier type to use for the rest of the connection. More... | |
virtual void | setParameters (const Bytes &header)=0 |
Configure this carrier based on the first 8 bytes of the connection. More... | |
void | getHeader (Bytes &header) const override=0 |
Provide 8 bytes describing this connection sufficiently to allow the other side of a connection to select it. More... | |
bool | isConnectionless () const override=0 |
Check if this carrier is connectionless (like udp, mcast) or connection based (like tcp). More... | |
bool | isBroadcast () const override |
Check if this carrier uses a broadcast mechanism. More... | |
virtual bool | canAccept () const =0 |
Check if reading is implemented for this carrier. More... | |
virtual bool | canOffer () const =0 |
Check if writing is implemented for this carrier. More... | |
bool | isTextMode () const override=0 |
Check if carrier is textual in nature. More... | |
bool | canEscape () const override=0 |
Check if carrier can encode administrative messages, as opposed to just user data. More... | |
void | handleEnvelope (const std::string &envelope) override |
Carriers that do not distinguish data from administrative headers (i.e. More... | |
bool | requireAck () const override=0 |
Check if carrier has flow control, requiring sent messages to be acknowledged by recipient. More... | |
bool | supportReply () const override=0 |
This flag is used by YARP to determine whether the connection can carry RPC traffic, that is, messages with replies. More... | |
bool | isLocal () const override=0 |
Check if carrier operates within a single process. More... | |
bool | isPush () const override |
Check if carrier is "push" or "pull" style. More... | |
virtual bool | prepareSend (ConnectionState &proto)=0 |
Perform any initialization needed before writing on a connection. More... | |
virtual bool | sendHeader (ConnectionState &proto)=0 |
Write a header appropriate to the carrier to the connection, followed by any carrier-specific data. More... | |
virtual bool | expectReplyToHeader (ConnectionState &proto)=0 |
Process reply to header, if one is expected for this carrier. More... | |
virtual bool | write (ConnectionState &proto, SizedWriter &writer)=0 |
Write a message. More... | |
virtual bool | reply (ConnectionState &proto, SizedWriter &writer) |
virtual bool | expectExtraHeader (ConnectionState &proto)=0 |
Receive any carrier-specific header. More... | |
virtual bool | respondToHeader (ConnectionState &proto)=0 |
Respond to the header. More... | |
virtual bool | expectIndex (ConnectionState &proto)=0 |
Expect a message header, if there is one for this carrier. More... | |
virtual bool | expectSenderSpecifier (ConnectionState &proto)=0 |
Expect the name of the sending port. More... | |
virtual bool | sendAck (ConnectionState &proto)=0 |
Send an acknowledgement, if needed for this carrier. More... | |
virtual bool | expectAck (ConnectionState &proto)=0 |
Receive an acknowledgement, if expected for this carrier. More... | |
bool | isActive () const override=0 |
Check if carrier is alive and error free. More... | |
void | prepareDisconnect () override |
Do cleanup and preparation for the coming disconnect, if necessary. More... | |
virtual std::string | toString () const =0 |
Get name of carrier. More... | |
virtual void | close () |
Close the carrier. More... | |
virtual | ~Carrier () |
Destructor. More... | |
virtual std::string | getBootstrapCarrierName () const |
Get the name of the carrier that should be used prior to handshaking, if a port is registered with this carrier as its default carrier. More... | |
virtual int | connect (const Contact &src, const Contact &dest, const ContactStyle &style, int mode, bool reversed) |
Some carrier types may require special connection logic. More... | |
bool | modifiesIncomingData () const override |
Check if this carrier modifies incoming data through the Carrier::modifyIncomingData method. More... | |
ConnectionReader & | modifyIncomingData (ConnectionReader &reader) override |
Modify incoming payload data, if appropriate. More... | |
bool | acceptIncomingData (ConnectionReader &reader) override |
Determine whether incoming data should be accepted. More... | |
bool | modifiesOutgoingData () const override |
Check if this carrier modifies outgoing data through the Carrier::modifyOutgoingData method. More... | |
const PortWriter & | modifyOutgoingData (const PortWriter &writer) override |
Modify outgoing payload data, if appropriate. More... | |
bool | modifiesReply () const override |
Check if this carrier modifies outgoing data through the Carrier::modifyReply method. More... | |
PortReader & | modifyReply (PortReader &reader) override |
Modify reply payload data, if appropriate. More... | |
bool | acceptOutgoingData (const PortWriter &writer) override |
Determine whether outgoing data should be accepted. More... | |
virtual bool | configure (ConnectionState &proto) |
Give carrier a shot at looking at how the connection is set up. More... | |
virtual bool | configureFromProperty (yarp::os::Property &options) |
void | setCarrierParams (const Property ¶ms) override |
Configure carrier from port administrative commands. More... | |
void | getCarrierParams (Property ¶ms) const override |
Get carrier configuration and deliver it by port administrative commands. More... | |
virtual yarp::os::Face * | createFace () const |
Create new Face object that the carrier needs. More... | |
Public Member Functions inherited from yarp::os::Connection | |
virtual | ~Connection () |
Destructor. More... | |
virtual bool | isValid () const |
Check if this object is really a connection, or just an empty placeholder. More... | |
virtual bool | isBareMode () const |
Check if carrier excludes type information from payload. More... | |
virtual std::string | getName () const =0 |
Get the name of this connection type ("tcp", "mcast", "shmem", ...) More... | |
A base class for connection types (tcp, mcast, shmem, ...) which are called carriers in YARP.
The methods prepareSend, sendHeader, expectReplyToHeader, sendIndex, expectAck, and write are important on the originating side of a connection.
The methods expectExtraHeader, respondToHeader, expectIndex, expectSenderSpecifier, and sendAck are important on the receiving side of a connection.
To understand the protocol phases involved, see see Port and connection protocols.
|
virtualdefault |
Destructor.
|
overridevirtual |
Determine whether incoming data should be accepted.
reader | for incoming data. |
Implements yarp::os::Connection.
Reimplemented in PriorityCarrier, PortMonitor, and ForwardingCarrier.
Definition at line 60 of file Carrier.cpp.
|
overridevirtual |
Determine whether outgoing data should be accepted.
writer | for outgoing data. |
Implements yarp::os::Connection.
Reimplemented in PortMonitor, and ForwardingCarrier.
Definition at line 98 of file Carrier.cpp.
|
pure virtual |
Check if reading is implemented for this carrier.
Implemented in ForwardingCarrier, yarp::os::AbstractCarrier, XmlRpcCarrier, TcpRosCarrier, MjpegCarrier, HumanCarrier, and H264Carrier.
|
overridepure virtual |
Check if carrier can encode administrative messages, as opposed to just user data.
The word escape is used in the sense of escape character or escape sequence here.
Implements yarp::os::Connection.
Implemented in ForwardingCarrier, yarp::os::impl::NameserCarrier, yarp::os::impl::LocalCarrier, yarp::os::AbstractCarrier, XmlRpcCarrier, TcpRosCarrier, MpiCarrier, MjpegCarrier, HumanCarrier, and H264Carrier.
|
pure virtual |
Check if writing is implemented for this carrier.
Implemented in ForwardingCarrier, yarp::os::AbstractCarrier, XmlRpcCarrier, TcpRosCarrier, MjpegCarrier, HumanCarrier, and H264Carrier.
|
pure virtual |
Given the first 8 bytes received on a connection, decide if this is the right carrier type to use for the rest of the connection.
For example the "text" carrier looks for the 8-byte sequence "CONNECT ". See the YARP protocol documentation for all the sequences in use here. In general you are free to add your own.
header | a buffer holding the first 8 bytes received on the connection |
Implemented in yarp::os::AbstractCarrier, ForwardingCarrier, yarp::os::ModifyingCarrier, yarp::os::impl::TcpCarrier, XmlRpcCarrier, UnixSocketCarrier, TcpRosCarrier, ShmemCarrier, MpiCarrier, MjpegCarrier, H264Carrier, yarp::os::impl::UdpCarrier, yarp::os::impl::TextCarrier, yarp::os::impl::NameserCarrier, yarp::os::impl::LocalCarrier, yarp::os::impl::HttpCarrier, and HumanCarrier.
|
virtual |
Close the carrier.
Reimplemented in MpiCarrier, ForwardingCarrier, MpiP2PCarrier, MpiBcastCarrier, and BayerCarrier.
Definition at line 87 of file Carrier.cpp.
|
virtual |
Give carrier a shot at looking at how the connection is set up.
Reimplemented in UnixSocketCarrier, PriorityCarrier, PortMonitor, and ForwardingCarrier.
Definition at line 105 of file Carrier.cpp.
|
virtual |
Reimplemented in yarp::os::ModifyingCarrier, ForwardingCarrier, UnixSocketCarrier, and PortMonitor.
Definition at line 111 of file Carrier.cpp.
|
virtual |
Some carrier types may require special connection logic.
This can be implemented here. Normally this is not necessary.
src | Initiator of the connection. |
dest | Destination of the connection. |
style | Options for connection. |
mode | YARP_ENACT_CONNECT / YARP_ENACT_DISCONNECT / YARP_ENACT_EXISTS. |
reversed | true for pull connections, false for push connections. |
Reimplemented in ForwardingCarrier, and TcpRosCarrier.
Definition at line 35 of file Carrier.cpp.
|
pure virtual |
Factory method.
Get a new object of the same type as this one.
Implemented in yarp::os::ModifyingCarrier, yarp::os::AbstractCarrier, MpiCarrier, StubCarrier, ForwardingCarrier, yarp::os::impl::UdpCarrier, yarp::os::impl::TextCarrier, yarp::os::impl::TcpCarrier, yarp::os::impl::NameserCarrier, yarp::os::impl::McastCarrier, yarp::os::impl::LocalCarrier, yarp::os::impl::HttpCarrier, XmlRpcCarrier, UnixSocketCarrier, RosSrvCarrier, TcpRosCarrier, ShmemCarrier, PriorityCarrier, PortMonitor, MpiP2PCarrier, MpiBcastCarrier, MjpegCarrier, HumanCarrier, H264Carrier, and BayerCarrier.
|
virtual |
Create new Face object that the carrier needs.
Reimplemented in ForwardingCarrier, and H264Carrier.
Definition at line 128 of file Carrier.cpp.
|
pure virtual |
Receive an acknowledgement, if expected for this carrier.
proto | the protocol object, which tracks connection state |
Implemented in XmlRpcCarrier, UnixSocketCarrier, TcpRosCarrier, MpiCarrier, MjpegCarrier, H264Carrier, ForwardingCarrier, yarp::os::impl::TextCarrier, yarp::os::impl::NameserCarrier, yarp::os::impl::HttpCarrier, yarp::os::AbstractCarrier, and HumanCarrier.
|
pure virtual |
Receive any carrier-specific header.
proto | the protocol object, which tracks connection state |
Implemented in XmlRpcCarrier, TcpRosCarrier, MjpegCarrier, H264Carrier, ForwardingCarrier, yarp::os::impl::McastCarrier, yarp::os::impl::LocalCarrier, yarp::os::AbstractCarrier, and HumanCarrier.
|
pure virtual |
Expect a message header, if there is one for this carrier.
proto | the protocol object, which tracks connection state |
Implemented in XmlRpcCarrier, UnixSocketCarrier, TcpRosCarrier, MpiCarrier, MjpegCarrier, H264Carrier, ForwardingCarrier, yarp::os::impl::TextCarrier, yarp::os::impl::NameserCarrier, yarp::os::impl::LocalCarrier, yarp::os::impl::HttpCarrier, yarp::os::AbstractCarrier, and HumanCarrier.
|
pure virtual |
Process reply to header, if one is expected for this carrier.
proto | the protocol object, which tracks connection state |
Implemented in yarp::os::impl::TcpCarrier, XmlRpcCarrier, UnixSocketCarrier, TcpRosCarrier, ShmemCarrier, MpiCarrier, MpiBcastCarrier, MjpegCarrier, H264Carrier, ForwardingCarrier, yarp::os::impl::UdpCarrier, yarp::os::impl::TextCarrier, yarp::os::impl::NameserCarrier, yarp::os::impl::McastCarrier, yarp::os::impl::LocalCarrier, yarp::os::impl::HttpCarrier, yarp::os::AbstractCarrier, and HumanCarrier.
|
pure virtual |
Expect the name of the sending port.
proto | the protocol object, which tracks connection state |
Implemented in XmlRpcCarrier, TcpRosCarrier, MpiCarrier, MjpegCarrier, H264Carrier, ForwardingCarrier, yarp::os::impl::TextCarrier, yarp::os::impl::NameserCarrier, yarp::os::impl::HttpCarrier, yarp::os::AbstractCarrier, and HumanCarrier.
|
virtual |
Get the name of the carrier that should be used prior to handshaking, if a port is registered with this carrier as its default carrier.
Normally, this should be "tcp".
For carriers intended to interoperate with foreign ports not capable of initiating streams, the bootstrap carrier name should be left blank. YARP may use that fact to arrange for alternate methods of initiating a stream.
Reimplemented in ForwardingCarrier, XmlRpcCarrier, TcpRosCarrier, MjpegCarrier, and H264Carrier.
Definition at line 30 of file Carrier.cpp.
|
overridevirtual |
Get carrier configuration and deliver it by port administrative commands.
params | properties |
Implements yarp::os::Connection.
Reimplemented in yarp::os::ModifyingCarrier, PriorityCarrier, PortMonitor, and ForwardingCarrier.
Definition at line 123 of file Carrier.cpp.
|
overridepure virtual |
Provide 8 bytes describing this connection sufficiently to allow the other side of a connection to select it.
header | a buffer to hold the first 8 bytes to send on a connection |
Implements yarp::os::Connection.
Implemented in yarp::os::AbstractCarrier, ForwardingCarrier, yarp::os::ModifyingCarrier, yarp::os::impl::TcpCarrier, XmlRpcCarrier, UnixSocketCarrier, TcpRosCarrier, ShmemCarrier, MpiCarrier, MjpegCarrier, H264Carrier, yarp::os::impl::UdpCarrier, yarp::os::impl::TextCarrier, yarp::os::impl::NameserCarrier, yarp::os::impl::LocalCarrier, yarp::os::impl::HttpCarrier, and HumanCarrier.
|
overridevirtual |
Carriers that do not distinguish data from administrative headers (i.e.
canEscape returns false), can overload this method to handle the envelope inside the stream. On the receiving side, the InputStream will have to overload the yarp::os::InputStream::setReadEnvelopeCallback method, and execute the callback as soon as the envelope is ready.
envelope | the envelope to transmit bundled with data. |
Implements yarp::os::Connection.
Reimplemented in ForwardingCarrier, MjpegCarrier, and H264Carrier.
Definition at line 20 of file Carrier.cpp.
|
overridepure virtual |
Check if carrier is alive and error free.
Implements yarp::os::Connection.
Implemented in ForwardingCarrier, yarp::os::impl::McastCarrier, yarp::os::AbstractCarrier, XmlRpcCarrier, TcpRosCarrier, MpiBcastCarrier, MjpegCarrier, HumanCarrier, H264Carrier, and BayerCarrier.
|
overridevirtual |
Check if this carrier uses a broadcast mechanism.
This flag is used to determine whether it is appropriate to send "kill" messages using a carrier or whether they should be sent "out-of-band"
Implements yarp::os::Connection.
Reimplemented in ForwardingCarrier, yarp::os::impl::McastCarrier, and MpiBcastCarrier.
Definition at line 15 of file Carrier.cpp.
|
overridepure virtual |
Check if this carrier is connectionless (like udp, mcast) or connection based (like tcp).
This flag is used by YARP to determine whether the connection can carry RPC traffic, that is, messages with replies. Replies are not supported by YARP on connectionless carriers.
Implements yarp::os::Connection.
Implemented in ForwardingCarrier, yarp::os::impl::UdpCarrier, yarp::os::impl::TcpCarrier, yarp::os::impl::LocalCarrier, yarp::os::AbstractCarrier, XmlRpcCarrier, UnixSocketCarrier, TcpRosCarrier, ShmemCarrier, MpiCarrier, MjpegCarrier, HumanCarrier, and H264Carrier.
|
overridepure virtual |
Check if carrier operates within a single process.
In such a case, YARP connections may get completely reorganized in order to optimize them.
Implements yarp::os::Connection.
Implemented in ForwardingCarrier, yarp::os::impl::LocalCarrier, yarp::os::AbstractCarrier, XmlRpcCarrier, TcpRosCarrier, MjpegCarrier, HumanCarrier, and H264Carrier.
|
overridevirtual |
Check if carrier is "push" or "pull" style.
Push means that the side that initiates a connection is also the one that will sending of data or commands. All native YARP connections are like this. A "pull" style is equivalent to automatically sending a "reverse connection" port command at the start of the connection.
Implements yarp::os::Connection.
Reimplemented in ForwardingCarrier, TcpRosCarrier, MjpegCarrier, and H264Carrier.
Definition at line 25 of file Carrier.cpp.
|
overridepure virtual |
Check if carrier is textual in nature.
Implements yarp::os::Connection.
Implemented in ForwardingCarrier, yarp::os::impl::TextCarrier, yarp::os::impl::NameserCarrier, yarp::os::impl::HttpCarrier, yarp::os::AbstractCarrier, XmlRpcCarrier, TcpRosCarrier, MjpegCarrier, HumanCarrier, H264Carrier, and BayerCarrier.
|
overridevirtual |
Check if this carrier modifies incoming data through the Carrier::modifyIncomingData method.
Implements yarp::os::Connection.
Reimplemented in ForwardingCarrier, and yarp::os::ModifyingCarrier.
Definition at line 49 of file Carrier.cpp.
|
overridevirtual |
Check if this carrier modifies outgoing data through the Carrier::modifyOutgoingData method.
Implements yarp::os::Connection.
Reimplemented in ForwardingCarrier, and yarp::os::ModifyingCarrier.
Definition at line 67 of file Carrier.cpp.
|
overridevirtual |
Check if this carrier modifies outgoing data through the Carrier::modifyReply method.
Implements yarp::os::Connection.
Reimplemented in ForwardingCarrier, and yarp::os::ModifyingCarrier.
Definition at line 78 of file Carrier.cpp.
|
overridevirtual |
Modify incoming payload data, if appropriate.
Doesn't need to be done immediately, it is fine to hold onto a reference to the incoming data reader and use it on demand. This can be handy in order to avoid unnecessary copies.
reader | for incoming data. |
Implements yarp::os::Connection.
Reimplemented in PortMonitor, BayerCarrier, and ForwardingCarrier.
Definition at line 55 of file Carrier.cpp.
|
overridevirtual |
Modify outgoing payload data, if appropriate.
Doesn't need to be done immediately, it is fine to hold onto a reference to the outgoing data reader and use it on demand. This can be handy in order to avoid unnecessary copies.
writer | for outgoing data. |
Implements yarp::os::Connection.
Reimplemented in PortMonitor, and ForwardingCarrier.
Definition at line 73 of file Carrier.cpp.
|
overridevirtual |
Modify reply payload data, if appropriate.
reader | for the replied message. |
Implements yarp::os::Connection.
Reimplemented in PortMonitor, and ForwardingCarrier.
Definition at line 93 of file Carrier.cpp.
|
overridevirtual |
Do cleanup and preparation for the coming disconnect, if necessary.
Implements yarp::os::Connection.
Reimplemented in ForwardingCarrier, and MpiBcastCarrier.
Definition at line 83 of file Carrier.cpp.
|
pure virtual |
Perform any initialization needed before writing on a connection.
proto | the protocol object, which tracks connection state |
Implemented in XmlRpcCarrier, TcpRosCarrier, MjpegCarrier, H264Carrier, ForwardingCarrier, yarp::os::AbstractCarrier, and HumanCarrier.
|
virtual |
Reimplemented in XmlRpcCarrier, TcpRosCarrier, MjpegCarrier, H264Carrier, ForwardingCarrier, and yarp::os::impl::HttpCarrier.
Definition at line 313 of file Carriers.cpp.
|
overridepure virtual |
Check if carrier has flow control, requiring sent messages to be acknowledged by recipient.
Implements yarp::os::Connection.
Implemented in ForwardingCarrier, yarp::os::impl::UdpCarrier, yarp::os::impl::TextCarrier, yarp::os::impl::TcpCarrier, yarp::os::impl::NameserCarrier, yarp::os::impl::LocalCarrier, yarp::os::impl::HttpCarrier, yarp::os::AbstractCarrier, XmlRpcCarrier, UnixSocketCarrier, TcpRosCarrier, ShmemCarrier, MjpegCarrier, HumanCarrier, and H264Carrier.
|
pure virtual |
Respond to the header.
proto | the protocol object, which tracks connection state |
Implemented in yarp::os::ModifyingCarrier, yarp::os::impl::TcpCarrier, XmlRpcCarrier, UnixSocketCarrier, TcpRosCarrier, ShmemCarrier, MpiCarrier, MjpegCarrier, H264Carrier, yarp::os::AbstractCarrier, ForwardingCarrier, yarp::os::impl::UdpCarrier, yarp::os::impl::TextCarrier, yarp::os::impl::NameserCarrier, yarp::os::impl::McastCarrier, yarp::os::impl::LocalCarrier, yarp::os::impl::HttpCarrier, and HumanCarrier.
|
pure virtual |
Send an acknowledgement, if needed for this carrier.
proto | the protocol object, which tracks connection state |
Implemented in XmlRpcCarrier, UnixSocketCarrier, TcpRosCarrier, MpiCarrier, MjpegCarrier, H264Carrier, ForwardingCarrier, yarp::os::impl::TextCarrier, yarp::os::impl::NameserCarrier, yarp::os::impl::HttpCarrier, yarp::os::AbstractCarrier, and HumanCarrier.
|
pure virtual |
Write a header appropriate to the carrier to the connection, followed by any carrier-specific data.
Must communicate at least the name of the originating port, if there is one.
proto | the protocol object, which tracks connection state |
Implemented in XmlRpcCarrier, TcpRosCarrier, MpiCarrier, MjpegCarrier, H264Carrier, ForwardingCarrier, yarp::os::impl::TextCarrier, yarp::os::impl::NameserCarrier, yarp::os::impl::McastCarrier, yarp::os::impl::LocalCarrier, yarp::os::impl::HttpCarrier, yarp::os::AbstractCarrier, and HumanCarrier.
|
overridevirtual |
Configure carrier from port administrative commands.
params | properties |
Implements yarp::os::Connection.
Reimplemented in yarp::os::ModifyingCarrier, PriorityCarrier, PortMonitor, and ForwardingCarrier.
Definition at line 118 of file Carrier.cpp.
|
pure virtual |
Configure this carrier based on the first 8 bytes of the connection.
This will only be called if checkHeader passed.
header | a buffer holding the first 8 bytes received on the connection |
Implemented in ForwardingCarrier, yarp::os::impl::TcpCarrier, yarp::os::AbstractCarrier, XmlRpcCarrier, UnixSocketCarrier, TcpRosCarrier, ShmemCarrier, MjpegCarrier, H264Carrier, yarp::os::impl::UdpCarrier, yarp::os::impl::LocalCarrier, yarp::os::impl::HttpCarrier, and HumanCarrier.
|
overridepure virtual |
This flag is used by YARP to determine whether the connection can carry RPC traffic, that is, messages with replies.
Implements yarp::os::Connection.
Implemented in MpiCarrier, ForwardingCarrier, yarp::os::impl::TextCarrier, yarp::os::impl::NameserCarrier, yarp::os::impl::HttpCarrier, yarp::os::AbstractCarrier, XmlRpcCarrier, TcpRosCarrier, MpiP2PCarrier, MpiBcastCarrier, MjpegCarrier, HumanCarrier, and H264Carrier.
|
pure virtual |
Get name of carrier.
Implemented in ForwardingCarrier, yarp::os::AbstractCarrier, XmlRpcCarrier, TcpRosCarrier, PriorityCarrier, PortMonitor, MjpegCarrier, HumanCarrier, H264Carrier, and BayerCarrier.
|
pure virtual |
Write a message.
proto | the protocol object, which tracks connection state |
Implemented in XmlRpcCarrier, TcpRosCarrier, MpiCarrier, MjpegCarrier, H264Carrier, ForwardingCarrier, yarp::os::impl::NameserCarrier, yarp::os::impl::LocalCarrier, yarp::os::impl::HttpCarrier, yarp::os::AbstractCarrier, and HumanCarrier.