YARP
Yet Another Robot Platform
ConnectionState.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 #ifndef YARP_OS_CONNECTIONSTATE_H
10 #define YARP_OS_CONNECTIONSTATE_H
11 
12 #include <yarp/os/api.h>
13 
14 #include <string>
15 
16 namespace yarp {
17 namespace os {
18 
19 class Connection;
20 class InputStream;
21 class OutputStream;
22 class Portable;
23 class Route;
24 class TwoWayStream;
25 class Contactable;
26 
31 {
32 public:
36  virtual ~ConnectionState();
37 
42  virtual const Route& getRoute() const = 0;
43 
47  virtual void setRoute(const Route& route) = 0;
48 
52  virtual OutputStream& getOutputStream() = 0;
53 
57  virtual InputStream& getInputStream() = 0;
58 
62  virtual Connection& getConnection() = 0;
63 
69  virtual void setRemainingLength(int len) = 0;
70 
75  virtual std::string getSenderSpecifier() const = 0;
76 
81  virtual TwoWayStream& getStreams() = 0;
82 
88  virtual void takeStreams(TwoWayStream* streams) = 0;
89 
95  virtual TwoWayStream* giveStreams() = 0;
96 
102  virtual void setReference(yarp::os::Portable* ref) = 0;
103 
107  virtual bool checkStreams() const = 0;
108 
112  virtual Contactable* getContactable() const = 0;
113 
118  {
119  return getOutputStream();
120  }
121 
126  {
127  return getInputStream();
128  }
129 
133  virtual const std::string& getEnvelope() const = 0;
134 };
135 
136 
137 } // namespace os
138 } // namespace yarp
139 
140 #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:30
An abstract port.
Definition: Contactable.h:38
Simple specification of the minimum functions needed from input streams.
Definition: InputStream.h:29
Simple specification of the minimum functions needed from output streams.
Definition: OutputStream.h:25
This is a base class for objects that can be both read from and be written to the YARP network.
Definition: Portable.h:29
Information about a connection between two ports.
Definition: Route.h:32
A stream which can be asked to perform bidirectional communication.
Definition: TwoWayStream.h:29
The main, catch-all namespace for YARP.
Definition: environment.h:25
#define YARP_os_API
Definition: api.h:19