YARP
Yet Another Robot Platform
ConnectionState.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 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
yarp::os::TwoWayStream
A stream which can be asked to perform bidirectional communication.
Definition: TwoWayStream.h:29
yarp::os::Portable
This is a base class for objects that can be both read from and be written to the YARP network.
Definition: Portable.h:29
yarp::os::ConnectionState::setReference
virtual void setReference(yarp::os::Portable *ref)=0
Give a direct pointer to an object being sent on the connection.
yarp::os::ConnectionState::giveStreams
virtual TwoWayStream * giveStreams()=0
Take ownership of the streams associated with the connection.
yarp::os::OutputStream
Simple specification of the minimum functions needed from output streams.
Definition: OutputStream.h:25
api.h
yarp::os::ConnectionState::getEnvelope
virtual const std::string & getEnvelope() const =0
Read the envelope associated with the current message.
YARP_os_API
#define YARP_os_API
Definition: api.h:19
yarp::os::Route
Information about a connection between two ports.
Definition: Route.h:32
yarp::os::ConnectionState::setRemainingLength
virtual void setRemainingLength(int len)=0
Tell the connection that the given number of bytes are left to be read.
yarp::os::ConnectionState::takeStreams
virtual void takeStreams(TwoWayStream *streams)=0
Provide streams to be used with the connection.
yarp::os::ConnectionState::os
OutputStream & os()
Shorthand for getOutputStream()
Definition: ConnectionState.h:117
yarp::os::ConnectionState::getRoute
virtual const Route & getRoute() const =0
Get the route associated with this connection.
yarp::os::ConnectionState::getConnection
virtual Connection & getConnection()=0
Access the controller for this connection.
yarp::os::ConnectionState::~ConnectionState
virtual ~ConnectionState()
Destructor.
yarp::os::ConnectionState::setRoute
virtual void setRoute(const Route &route)=0
Set the route associated with this connection.
yarp::os::ConnectionState::checkStreams
virtual bool checkStreams() const =0
Check whether streams are in a good state.
yarp::os::ConnectionState::getStreams
virtual TwoWayStream & getStreams()=0
Access the streams associated with the connection.
yarp::os::ConnectionState
The basic state of a connection - route, streams in use, etc.
Definition: ConnectionState.h:31
yarp::os::ConnectionState::getSenderSpecifier
virtual std::string getSenderSpecifier() const =0
Extract a name for the sender, if the connection type supports that.
yarp::os::ConnectionState::getOutputStream
virtual OutputStream & getOutputStream()=0
Access the output stream associated with this connection.
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::os::Connection
A controller for an individual connection.
Definition: Connection.h:30
yarp::os::ConnectionState::is
InputStream & is()
Shorthand for getInputStream()
Definition: ConnectionState.h:125
yarp::os::ConnectionState::getContactable
virtual Contactable * getContactable() const =0
Get the port associated with the connection.
yarp::os::ConnectionState::getInputStream
virtual InputStream & getInputStream()=0
Access the input stream associated with this connection.
yarp::os::InputStream
Simple specification of the minimum functions needed from input streams.
Definition: InputStream.h:29
yarp::os::Contactable
An abstract port.
Definition: Contactable.h:38