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
13namespace yarp::os {
14
15class Connection;
16class InputStream;
17class OutputStream;
18class Portable;
19class Route;
20class TwoWayStream;
21class Contactable;
22
27{
28public:
33
38 virtual const Route& getRoute() const = 0;
39
43 virtual void setRoute(const Route& route) = 0;
44
49
54
58 virtual Connection& getConnection() = 0;
59
65 virtual void setRemainingLength(int len) = 0;
66
71 virtual std::string getSenderSpecifier() const = 0;
72
77 virtual TwoWayStream& getStreams() = 0;
78
84 virtual void takeStreams(TwoWayStream* streams) = 0;
85
91 virtual TwoWayStream* giveStreams() = 0;
92
98 virtual void setReference(yarp::os::Portable* ref) = 0;
99
103 virtual bool checkStreams() const = 0;
104
108 virtual Contactable* getContactable() const = 0;
109
114 {
115 return getOutputStream();
116 }
117
122 {
123 return getInputStream();
124 }
125
129 virtual const std::string& getEnvelope() const = 0;
130};
131
132
133} // namespace yarp::os
134
135#endif // YARP_OS_CONNECTIONSTATE_H
The basic state of a connection - route, streams in use, etc.
OutputStream & os()
Shorthand for getOutputStream()
virtual void setRemainingLength(int len)=0
Tell the connection that the given number of bytes are left to be read.
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 OutputStream & getOutputStream()=0
Access the output stream associated with this connection.
virtual const Route & getRoute() const =0
Get the route associated with this connection.
virtual TwoWayStream * giveStreams()=0
Take ownership of the streams associated with the connection.
virtual InputStream & getInputStream()=0
Access the input stream associated with this connection.
virtual ~ConnectionState()
Destructor.
virtual std::string getSenderSpecifier() const =0
Extract a name for the sender, if the connection type supports that.
InputStream & is()
Shorthand for getInputStream()
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.
virtual TwoWayStream & getStreams()=0
Access the streams associated with the connection.
virtual void setRoute(const Route &route)=0
Set the route associated with this connection.
virtual Connection & getConnection()=0
Access the controller for this connection.
virtual Contactable * getContactable() const =0
Get the port associated with the connection.
A controller for an individual connection.
Definition: Connection.h:26
An abstract port.
Definition: Contactable.h:28
Simple specification of the minimum functions needed from input streams.
Definition: InputStream.h:25
Simple specification of the minimum functions needed from output streams.
Definition: OutputStream.h:21
This is a base class for objects that can be both read from and be written to the YARP network.
Definition: Portable.h:25
Information about a connection between two ports.
Definition: Route.h:28
A stream which can be asked to perform bidirectional communication.
Definition: TwoWayStream.h:25
An interface to the operating system, including Port based communication.
#define YARP_os_API
Definition: api.h:18