YARP
Yet Another Robot Platform
ConnectionState.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_CONNECTIONSTATE_H
7 #define YARP_OS_CONNECTIONSTATE_H
8 
9 #include <yarp/os/api.h>
10 
11 #include <string>
12 
13 namespace yarp {
14 namespace os {
15 
16 class Connection;
17 class InputStream;
18 class OutputStream;
19 class Portable;
20 class Route;
21 class TwoWayStream;
22 class Contactable;
23 
28 {
29 public:
33  virtual ~ConnectionState();
34 
39  virtual const Route& getRoute() const = 0;
40 
44  virtual void setRoute(const Route& route) = 0;
45 
49  virtual OutputStream& getOutputStream() = 0;
50 
54  virtual InputStream& getInputStream() = 0;
55 
59  virtual Connection& getConnection() = 0;
60 
66  virtual void setRemainingLength(int len) = 0;
67 
72  virtual std::string getSenderSpecifier() const = 0;
73 
78  virtual TwoWayStream& getStreams() = 0;
79 
85  virtual void takeStreams(TwoWayStream* streams) = 0;
86 
92  virtual TwoWayStream* giveStreams() = 0;
93 
99  virtual void setReference(yarp::os::Portable* ref) = 0;
100 
104  virtual bool checkStreams() const = 0;
105 
109  virtual Contactable* getContactable() const = 0;
110 
115  {
116  return getOutputStream();
117  }
118 
123  {
124  return getInputStream();
125  }
126 
130  virtual const std::string& getEnvelope() const = 0;
131 };
132 
133 
134 } // namespace os
135 } // namespace yarp
136 
137 #endif // YARP_OS_CONNECTIONSTATE_H
The basic state of a connection - route, streams in use, etc.
virtual Contactable * getContactable() const =0
Get the port associated with the connection.
virtual OutputStream & getOutputStream()=0
Access the output stream associated with this connection.
virtual void setRemainingLength(int len)=0
Tell the connection that the given number of bytes are left to be read.
virtual TwoWayStream & getStreams()=0
Access the streams associated with the connection.
virtual const Route & getRoute() const =0
Get the route associated with this connection.
virtual Connection & getConnection()=0
Access the controller for this connection.
virtual TwoWayStream * giveStreams()=0
Take ownership of the streams associated with the connection.
virtual void setReference(yarp::os::Portable *ref)=0
Give a direct pointer to an object being sent on the connection.
virtual const std::string & getEnvelope() const =0
Read the envelope associated with the current message.
virtual ~ConnectionState()
Destructor.
virtual std::string getSenderSpecifier() const =0
Extract a name for the sender, if the connection type supports that.
virtual bool checkStreams() const =0
Check whether streams are in a good state.
virtual void takeStreams(TwoWayStream *streams)=0
Provide streams to be used with the connection.
InputStream & is()
Shorthand for getInputStream()
virtual InputStream & getInputStream()=0
Access the input stream associated with this connection.
OutputStream & os()
Shorthand for getOutputStream()
virtual void setRoute(const Route &route)=0
Set the route associated with this connection.
A controller for an individual connection.
Definition: Connection.h:27
An abstract port.
Definition: Contactable.h:35
Simple specification of the minimum functions needed from input streams.
Definition: InputStream.h:26
Simple specification of the minimum functions needed from output streams.
Definition: OutputStream.h:22
This is a base class for objects that can be both read from and be written to the YARP network.
Definition: Portable.h:26
Information about a connection between two ports.
Definition: Route.h:29
A stream which can be asked to perform bidirectional communication.
Definition: TwoWayStream.h:26
The main, catch-all namespace for YARP.
Definition: dirs.h:16
#define YARP_os_API
Definition: api.h:18