YARP
Yet Another Robot Platform
InputProtocol.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef YARP_OS_INPUTPROTOCOL_H
8 #define YARP_OS_INPUTPROTOCOL_H
9 
10 #include <yarp/os/Connection.h>
12 #include <yarp/os/InputStream.h>
13 #include <yarp/os/OutputStream.h>
14 #include <yarp/os/Property.h>
15 #include <yarp/os/Route.h>
16 #include <yarp/os/SizedWriter.h>
17 
18 #include <string>
19 
20 namespace yarp {
21 namespace os {
22 class OutputProtocol;
23 class Contactable;
24 } // namespace os
25 } // namespace yarp
26 
27 
28 namespace yarp {
29 namespace os {
30 
35 {
36 public:
40  virtual ~InputProtocol() = default;
41 
47  virtual bool open(const std::string& name) = 0;
48 
52  virtual void close() = 0;
53 
57  virtual void interrupt() = 0;
58 
63  virtual const Route& getRoute() const = 0;
64 
70  virtual ConnectionReader& beginRead() = 0;
71 
75  virtual void endRead() = 0;
76 
80  virtual void reply(SizedWriter& writer) = 0;
81 
85  virtual Connection& getConnection() = 0;
86 
93  virtual Connection& getReceiver() = 0;
94 
98  virtual bool isOk() const = 0;
99 
105  virtual OutputProtocol& getOutput() = 0;
106 
112  virtual void suppressReply() = 0;
113 
118 
122  virtual InputStream& getInputStream() = 0;
123 
127  virtual void setEnvelope(const std::string& str) = 0;
128 
132  virtual bool setTimeout(double timeout) = 0;
133 
137  virtual void attachPort(Contactable* port) = 0;
138 
142  virtual bool isReplying() const = 0;
143 };
144 
145 } // namespace os
146 } // namespace yarp
147 
148 #endif // YARP_OS_INPUTPROTOCOL_H
An interface for reading from a network connection.
A controller for an individual connection.
Definition: Connection.h:27
An abstract port.
Definition: Contactable.h:35
The input side of an active connection between two ports.
Definition: InputProtocol.h:35
virtual bool open(const std::string &name)=0
Start negotiating a carrier, using the given name as our own if a name is needed (this should general...
virtual bool isOk() const =0
Check if the connection is valid and can be used.
virtual const Route & getRoute() const =0
Get the route associated with this connection.
virtual void close()=0
Negotiate an end to operations.
virtual OutputStream & getOutputStream()=0
Access the output stream associated with the connection.
virtual ConnectionReader & beginRead()=0
Begin a read operation, with bytes read via the returned yarp::os::ConnectionReader object.
virtual bool setTimeout(double timeout)=0
Set the timeout to be used for network operations.
virtual Connection & getReceiver()=0
It is possible to chain a basic connection with a modifier.
virtual void setEnvelope(const std::string &str)=0
Set the envelope that will be attached to the next message.
virtual void endRead()=0
End the current read operation, begin by beginRead().
virtual void reply(SizedWriter &writer)=0
Reply to a message we have just read.
virtual Connection & getConnection()=0
Get the basic connection through which we are communicating.
virtual ~InputProtocol()=default
Destructor.
virtual OutputProtocol & getOutput()=0
Get an interface for doing write operations on the connection.
virtual void suppressReply()=0
Make sure that any attempt to send a reply to input will be denied.
virtual InputStream & getInputStream()=0
Access the input stream associated with the connection.
virtual void interrupt()=0
Try to get operations interrupted.
virtual bool isReplying() const =0
virtual void attachPort(Contactable *port)=0
Set the port to be associated with the connection.
Simple specification of the minimum functions needed from input streams.
Definition: InputStream.h:26
The output side of an active connection between two ports.
Simple specification of the minimum functions needed from output streams.
Definition: OutputStream.h:22
Information about a connection between two ports.
Definition: Route.h:29
Minimal requirements for an efficient Writer.
Definition: SizedWriter.h:33
The main, catch-all namespace for YARP.
Definition: dirs.h:16
#define YARP_os_API
Definition: api.h:18