YARP
Yet Another Robot Platform
Carrier.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
10 #ifndef YARP_OS_CARRIER_H
11 #define YARP_OS_CARRIER_H
12 
13 #include <yarp/os/Connection.h>
14 
15 #define YARP_ENACT_CONNECT 1
16 #define YARP_ENACT_DISCONNECT 2
17 #define YARP_ENACT_EXISTS 3
18 
19 
20 namespace yarp {
21 namespace os {
22 
23 class SizedWriter;
24 class Bytes;
25 class Contact;
26 class ContactStyle;
27 class ConnectionReader;
28 class ConnectionState;
29 class Face;
30 
31 
48 {
49 public:
55  virtual Carrier* create() const = 0;
56 
70  virtual bool checkHeader(const Bytes& header) = 0;
71 
81  virtual void setParameters(const Bytes& header) = 0;
82 
90  void getHeader(Bytes& header) const override = 0;
91 
92 
103  bool isConnectionless() const override = 0;
104 
105 
115  bool isBroadcast() const override;
116 
122  virtual bool canAccept() const = 0;
123 
129  virtual bool canOffer() const = 0;
130 
136  bool isTextMode() const override = 0;
137 
145  bool canEscape() const override = 0;
146 
157  void handleEnvelope(const std::string& envelope) override;
158 
165  bool requireAck() const override = 0;
166 
173  bool supportReply() const override = 0;
174 
183  bool isLocal() const override = 0;
184 
185 
197  bool isPush() const override;
198 
205  virtual bool prepareSend(ConnectionState& proto) = 0;
206 
217  virtual bool sendHeader(ConnectionState& proto) = 0;
218 
225  virtual bool expectReplyToHeader(ConnectionState& proto) = 0;
226 
233  virtual bool write(ConnectionState& proto, SizedWriter& writer) = 0;
234 
235 
236  virtual bool reply(ConnectionState& proto, SizedWriter& writer);
237 
244  virtual bool expectExtraHeader(ConnectionState& proto) = 0;
245 
252  virtual bool respondToHeader(ConnectionState& proto) = 0;
253 
260  virtual bool expectIndex(ConnectionState& proto) = 0;
261 
268  virtual bool expectSenderSpecifier(ConnectionState& proto) = 0;
269 
276  virtual bool sendAck(ConnectionState& proto) = 0;
277 
284  virtual bool expectAck(ConnectionState& proto) = 0;
285 
291  bool isActive() const override = 0;
292 
297  void prepareDisconnect() override;
298 
299 
305  virtual std::string toString() const = 0;
306 
310  virtual void close();
311 
315  virtual ~Carrier();
316 
331  virtual std::string getBootstrapCarrierName() const;
332 
347  virtual int connect(const Contact& src,
348  const Contact& dest,
349  const ContactStyle& style,
350  int mode,
351  bool reversed);
352 
353 
360  bool modifiesIncomingData() const override;
361 
376  ConnectionReader& modifyIncomingData(ConnectionReader& reader) override;
377 
385  bool acceptIncomingData(ConnectionReader& reader) override;
386 
393  bool modifiesOutgoingData() const override;
394 
405  const PortWriter& modifyOutgoingData(const PortWriter& writer) override;
406 
413  bool modifiesReply() const override;
414 
421  PortReader& modifyReply(PortReader& reader) override;
422 
430  bool acceptOutgoingData(const PortWriter& writer) override;
431 
437  virtual bool configure(ConnectionState& proto);
438 
439  virtual bool configureFromProperty(yarp::os::Property& options);
440 
446  void setCarrierParams(const Property& params) override;
453  void getCarrierParams(Property& params) const override;
454 
459  virtual yarp::os::Face* createFace() const;
460 };
461 
462 } // namespace os
463 } // namespace yarp
464 
465 #endif // YARP_OS_CARRIER_H
yarp::os::ContactStyle
Definition: ContactStyle.h:26
yarp::os::Carrier
A base class for connection types (tcp, mcast, shmem, ...) which are called carriers in YARP.
Definition: Carrier.h:47
yarp::os::PortWriter
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
Definition: PortWriter.h:26
yarp::os::PortReader
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition: PortReader.h:27
Connection.h
yarp::os::Bytes
A simple abstraction for a block of bytes.
Definition: Bytes.h:27
yarp::os::ConnectionReader
An interface for reading from a network connection.
Definition: ConnectionReader.h:39
yarp::os::ConnectionState
The basic state of a connection - route, streams in use, etc.
Definition: ConnectionState.h:30
toString
std::string toString(const T &value)
convert an arbitrary type to string.
Definition: fakeMotionControl.cpp:121
yarp
Definition: environment.h:18
yarp::os::Connection
A controller for an individual connection.
Definition: Connection.h:29
YARP_os_API
#define YARP_os_API
Definition: api.h:19
yarp::os::Contact
Represents how to reach a part of a YARP network.
Definition: Contact.h:38
yarp::sig::file::write
bool write(const ImageOf< PixelRgb > &src, const std::string &dest, image_fileformat format=FORMAT_PPM)
Definition: ImageFile.cpp:804
yarp::os::Face
The initial point-of-contact with a port.
Definition: Face.h:23
yarp::os::SizedWriter
Minimal requirements for an efficient Writer.
Definition: SizedWriter.h:35
yarp::os::Property
A class for storing options and configuration information.
Definition: Property.h:34