YARP
Yet Another Robot Platform
Connection.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
6 #ifndef YARP_OS_CONNECTION_H
7 #define YARP_OS_CONNECTION_H
8 
9 #include <yarp/os/api.h>
10 
11 #include <string>
12 
13 namespace yarp {
14 namespace os {
15 
16 class Bytes;
17 class ConnectionReader;
18 class PortWriter;
19 class PortReader;
20 class Property;
21 
27 {
28 public:
32  virtual ~Connection();
33 
40  virtual bool isValid() const;
41 
47  virtual bool isTextMode() const = 0;
48 
54  virtual bool isBareMode() const;
55 
66  virtual void handleEnvelope(const std::string& envelope) = 0;
67 
68 
76  virtual bool canEscape() const = 0;
77 
84  virtual bool requireAck() const = 0;
85 
92  virtual bool supportReply() const = 0;
93 
102  virtual bool isLocal() const = 0;
103 
104 
116  virtual bool isPush() const = 0;
117 
128  virtual bool isConnectionless() const = 0;
129 
130 
140  virtual bool isBroadcast() const = 0;
141 
142 
148  virtual bool isActive() const = 0;
149 
150 
157  virtual bool modifiesIncomingData() const = 0;
158 
170 
179 
186  virtual bool modifiesOutgoingData() const = 0;
187 
198  virtual const PortWriter& modifyOutgoingData(const PortWriter& writer) = 0;
199 
207  virtual bool acceptOutgoingData(const PortWriter& writer) = 0;
208 
215  virtual bool modifiesReply() const = 0;
216 
223  virtual PortReader& modifyReply(PortReader& reader) = 0;
224 
230  virtual void setCarrierParams(const yarp::os::Property& params) = 0;
231 
238  virtual void getCarrierParams(yarp::os::Property& params) const = 0;
239 
247  virtual void getHeader(yarp::os::Bytes& header) const = 0;
248 
253  virtual void prepareDisconnect() = 0;
254 
260  virtual std::string getName() const = 0;
261 };
262 
263 } // namespace os
264 } // namespace yarp
265 
266 
267 #endif // YARP_OS_CONNECTION_H
A simple abstraction for a block of bytes.
Definition: Bytes.h:25
An interface for reading from a network connection.
A controller for an individual connection.
Definition: Connection.h:27
virtual bool isLocal() const =0
Check if carrier operates within a single process.
virtual bool isTextMode() const =0
Check if carrier is textual in nature.
virtual void prepareDisconnect()=0
Do cleanup and preparation for the coming disconnect, if necessary.
virtual bool acceptIncomingData(yarp::os::ConnectionReader &reader)=0
Determine whether incoming data should be accepted.
virtual bool isConnectionless() const =0
Check if this carrier is connectionless (like udp, mcast) or connection based (like tcp).
virtual void getCarrierParams(yarp::os::Property &params) const =0
Get carrier configuration and deliver it by port administrative commands.
virtual void handleEnvelope(const std::string &envelope)=0
Carriers that do not distinguish data from administrative headers (i.e.
virtual bool acceptOutgoingData(const PortWriter &writer)=0
Determine whether outgoing data should be accepted.
virtual ~Connection()
Destructor.
virtual bool requireAck() const =0
Check if carrier has flow control, requiring sent messages to be acknowledged by recipient.
virtual bool modifiesReply() const =0
Check if this carrier modifies outgoing data through the Carrier::modifyReply method.
virtual bool modifiesIncomingData() const =0
Check if this carrier modifies incoming data through the Carrier::modifyIncomingData method.
virtual yarp::os::ConnectionReader & modifyIncomingData(yarp::os::ConnectionReader &reader)=0
Modify incoming payload data, if appropriate.
virtual PortReader & modifyReply(PortReader &reader)=0
Modify reply payload data, if appropriate.
virtual bool isActive() const =0
Check if carrier is alive and error free.
virtual bool canEscape() const =0
Check if carrier can encode administrative messages, as opposed to just user data.
virtual bool isPush() const =0
Check if carrier is "push" or "pull" style.
virtual std::string getName() const =0
Get the name of this connection type ("tcp", "mcast", "shmem", ...)
virtual const PortWriter & modifyOutgoingData(const PortWriter &writer)=0
Modify outgoing payload data, if appropriate.
virtual bool supportReply() const =0
This flag is used by YARP to determine whether the connection can carry RPC traffic,...
virtual bool modifiesOutgoingData() const =0
Check if this carrier modifies outgoing data through the Carrier::modifyOutgoingData method.
virtual bool isBroadcast() const =0
Check if this carrier uses a broadcast mechanism.
virtual void getHeader(yarp::os::Bytes &header) const =0
Provide 8 bytes describing this connection sufficiently to allow the other side of a connection to se...
virtual void setCarrierParams(const yarp::os::Property &params)=0
Configure carrier from port administrative commands.
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition: PortReader.h:25
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
Definition: PortWriter.h:24
A class for storing options and configuration information.
Definition: Property.h:34
bool isValid()
Check if time is valid (non-zero).
Definition: Time.cpp:314
The main, catch-all namespace for YARP.
Definition: dirs.h:16
#define YARP_os_API
Definition: api.h:18