YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
Carrier.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef YARP_OS_CARRIER_H
8#define YARP_OS_CARRIER_H
9
10#include <yarp/os/Connection.h>
11
12#define YARP_ENACT_CONNECT 1
13#define YARP_ENACT_DISCONNECT 2
14#define YARP_ENACT_EXISTS 3
15
16
17namespace yarp::os {
18
19class SizedWriter;
20class Bytes;
21class Contact;
22class ContactStyle;
23class ConnectionReader;
24class ConnectionState;
25class Face;
26
27
44{
45public:
51 virtual Carrier* create() const = 0;
52
66 virtual bool checkHeader(const Bytes& header) = 0;
67
77 virtual void setParameters(const Bytes& header) = 0;
78
86 void getHeader(Bytes& header) const override = 0;
87
88
99 bool isConnectionless() const override = 0;
100
101
111 bool isBroadcast() const override;
112
118 virtual bool canAccept() const = 0;
119
125 virtual bool canOffer() const = 0;
126
132 bool isTextMode() const override = 0;
133
141 bool canEscape() const override = 0;
142
153 void handleEnvelope(const std::string& envelope) override;
154
161 bool requireAck() const override = 0;
162
169 bool supportReply() const override = 0;
170
179 bool isLocal() const override = 0;
180
181
193 bool isPush() const override;
194
201 virtual bool prepareSend(ConnectionState& proto) = 0;
202
213 virtual bool sendHeader(ConnectionState& proto) = 0;
214
221 virtual bool expectReplyToHeader(ConnectionState& proto) = 0;
222
229 virtual bool write(ConnectionState& proto, SizedWriter& writer) = 0;
230
231
232 virtual bool reply(ConnectionState& proto, SizedWriter& writer);
233
240 virtual bool expectExtraHeader(ConnectionState& proto) = 0;
241
248 virtual bool respondToHeader(ConnectionState& proto) = 0;
249
256 virtual bool expectIndex(ConnectionState& proto) = 0;
257
264 virtual bool expectSenderSpecifier(ConnectionState& proto) = 0;
265
272 virtual bool sendAck(ConnectionState& proto) = 0;
273
280 virtual bool expectAck(ConnectionState& proto) = 0;
281
287 bool isActive() const override = 0;
288
293 void prepareDisconnect() override;
294
295
301 virtual std::string toString() const = 0;
302
306 virtual void close();
307
311 virtual ~Carrier();
312
327 virtual std::string getBootstrapCarrierName() const;
328
343 virtual int connect(const Contact& src,
344 const Contact& dest,
345 const ContactStyle& style,
346 int mode,
347 bool reversed);
348
349
356 bool modifiesIncomingData() const override;
357
372 ConnectionReader& modifyIncomingData(ConnectionReader& reader) override;
373
381 bool acceptIncomingData(ConnectionReader& reader) override;
382
389 bool modifiesOutgoingData() const override;
390
401 const PortWriter& modifyOutgoingData(const PortWriter& writer) override;
402
409 bool modifiesReply() const override;
410
417 PortReader& modifyReply(PortReader& reader) override;
418
426 bool acceptOutgoingData(const PortWriter& writer) override;
427
433 virtual bool configure(ConnectionState& proto);
434
435 virtual bool configureFromProperty(yarp::os::Property& options);
436
442 void setCarrierParams(const Property& params) override;
449 void getCarrierParams(Property& params) const override;
450
455 virtual yarp::os::Face* createFace() const;
456};
457
458} // namespace yarp::os
459
460#endif // YARP_OS_CARRIER_H
A simple abstraction for a block of bytes.
Definition Bytes.h:24
A base class for connection types (tcp, mcast, shmem, ...) which are called carriers in YARP.
Definition Carrier.h:44
bool supportReply() const override=0
This flag is used by YARP to determine whether the connection can carry RPC traffic,...
bool isConnectionless() const override=0
Check if this carrier is connectionless (like udp, mcast) or connection based (like tcp).
virtual bool write(ConnectionState &proto, SizedWriter &writer)=0
Write a message.
virtual std::string toString() const =0
Get name of carrier.
virtual bool respondToHeader(ConnectionState &proto)=0
Respond to the header.
bool canEscape() const override=0
Check if carrier can encode administrative messages, as opposed to just user data.
bool requireAck() const override=0
Check if carrier has flow control, requiring sent messages to be acknowledged by recipient.
bool isTextMode() const override=0
Check if carrier is textual in nature.
virtual ~Carrier()
Destructor.
virtual bool expectSenderSpecifier(ConnectionState &proto)=0
Expect the name of the sending port.
bool isActive() const override=0
Check if carrier is alive and error free.
virtual bool sendHeader(ConnectionState &proto)=0
Write a header appropriate to the carrier to the connection, followed by any carrier-specific data.
virtual void setParameters(const Bytes &header)=0
Configure this carrier based on the first 8 bytes of the connection.
virtual bool expectExtraHeader(ConnectionState &proto)=0
Receive any carrier-specific header.
virtual bool expectIndex(ConnectionState &proto)=0
Expect a message header, if there is one for this carrier.
virtual bool expectAck(ConnectionState &proto)=0
Receive an acknowledgement, if expected for this carrier.
bool isLocal() const override=0
Check if carrier operates within a single process.
void getHeader(Bytes &header) const override=0
Provide 8 bytes describing this connection sufficiently to allow the other side of a connection to se...
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...
virtual bool canAccept() const =0
Check if reading is implemented for this carrier.
virtual bool canOffer() const =0
Check if writing is implemented for this carrier.
virtual bool expectReplyToHeader(ConnectionState &proto)=0
Process reply to header, if one is expected for this carrier.
virtual Carrier * create() const =0
Factory method.
virtual bool prepareSend(ConnectionState &proto)=0
Perform any initialization needed before writing on a connection.
virtual bool sendAck(ConnectionState &proto)=0
Send an acknowledgement, if needed for this carrier.
An interface for reading from a network connection.
The basic state of a connection - route, streams in use, etc.
A controller for an individual connection.
Definition Connection.h:26
Preferences for how to communicate with a contact.
Represents how to reach a part of a YARP network.
Definition Contact.h:33
The initial point-of-contact with a port.
Definition Face.h:20
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition PortReader.h:24
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
Definition PortWriter.h:23
A class for storing options and configuration information.
Definition Property.h:33
Minimal requirements for an efficient Writer.
Definition SizedWriter.h:32
An interface to the operating system, including Port based communication.
#define YARP_os_API
Definition api.h:18