YARP
Yet Another Robot Platform
InputProtocol.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
10 #ifndef YARP_OS_INPUTPROTOCOL_H
11 #define YARP_OS_INPUTPROTOCOL_H
12 
13 #include <yarp/os/Connection.h>
15 #include <yarp/os/InputStream.h>
16 #include <yarp/os/OutputStream.h>
17 #include <yarp/os/Property.h>
18 #include <yarp/os/Route.h>
19 #include <yarp/os/SizedWriter.h>
20 
21 #include <string>
22 
23 namespace yarp {
24 namespace os {
25 class OutputProtocol;
26 class Contactable;
27 } // namespace os
28 } // namespace yarp
29 
30 
31 namespace yarp {
32 namespace os {
33 
38 {
39 public:
43  virtual ~InputProtocol() = default;
44 
50  virtual bool open(const std::string& name) = 0;
51 
55  virtual void close() = 0;
56 
60  virtual void interrupt() = 0;
61 
66  virtual const Route& getRoute() const = 0;
67 
73  virtual ConnectionReader& beginRead() = 0;
74 
78  virtual void endRead() = 0;
79 
83  virtual void reply(SizedWriter& writer) = 0;
84 
88  virtual Connection& getConnection() = 0;
89 
96  virtual Connection& getReceiver() = 0;
97 
101  virtual bool isOk() const = 0;
102 
108  virtual OutputProtocol& getOutput() = 0;
109 
115  virtual void suppressReply() = 0;
116 
121 
125  virtual InputStream& getInputStream() = 0;
126 
130  virtual void setEnvelope(const std::string& str) = 0;
131 
135  virtual bool setTimeout(double timeout) = 0;
136 
140  virtual void attachPort(Contactable* port) = 0;
141 
145  virtual bool isReplying() const = 0;
146 };
147 
148 } // namespace os
149 } // namespace yarp
150 
151 #endif // YARP_OS_INPUTPROTOCOL_H
An interface for reading from a network connection.
A controller for an individual connection.
Definition: Connection.h:30
An abstract port.
Definition: Contactable.h:38
The input side of an active connection between two ports.
Definition: InputProtocol.h:38
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:29
The output side of an active connection between two ports.
Simple specification of the minimum functions needed from output streams.
Definition: OutputStream.h:25
Information about a connection between two ports.
Definition: Route.h:32
Minimal requirements for an efficient Writer.
Definition: SizedWriter.h:36
The main, catch-all namespace for YARP.
Definition: environment.h:18
#define YARP_os_API
Definition: api.h:19