YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
TwoWayStream.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_TWOWAYSTREAM_H
8#define YARP_OS_TWOWAYSTREAM_H
9
10#include <yarp/conf/numeric.h>
11
12#include <yarp/os/Contact.h>
13#include <yarp/os/InputStream.h>
15
16namespace yarp::os {
17
25{
26public:
30 virtual ~TwoWayStream();
31
38
45
52 virtual const Contact& getLocalAddress() const = 0;
53
60 virtual const Contact& getRemoteAddress() const = 0;
61
69 virtual bool isOk() const = 0;
70
74 virtual void reset() = 0;
75
81 virtual void close() = 0;
82
90 virtual void beginPacket() = 0;
91
97 virtual void endPacket() = 0;
98};
99
100
105{
106private:
107 Contact address;
108
109public:
110 virtual ~NullStream();
111
112 InputStream& getInputStream() override;
113 OutputStream& getOutputStream() override;
114
115 const Contact& getLocalAddress() const override;
116 const Contact& getRemoteAddress() const override;
117
118 bool isOk() const override;
119 void reset() override;
120 void close() override;
121 void beginPacket() override;
122 void endPacket() override;
123
125 yarp::conf::ssize_t read(Bytes& b) override;
126
128 void write(const Bytes& b) override;
129};
130
131} // namespace yarp::os
132
133#endif // YARP_OS_TWOWAYSTREAM_H
A simple abstraction for a block of bytes.
Definition Bytes.h:24
Represents how to reach a part of a YARP network.
Definition Contact.h:33
Simple specification of the minimum functions needed from input streams.
Definition InputStream.h:25
virtual int read()
Read and return a single byte.
A "null" stream, always invalid.
Simple specification of the minimum functions needed from output streams.
virtual void write(char ch)
Write a single byte to the stream.
A stream which can be asked to perform bidirectional communication.
virtual InputStream & getInputStream()=0
Get an InputStream to read from.
virtual const Contact & getRemoteAddress() const =0
Get the address of the remote side of the stream.
virtual void endPacket()=0
Mark the end of a logical packet (see beginPacket).
virtual void close()=0
Terminate the stream.
virtual void reset()=0
Reset the stream.
virtual ~TwoWayStream()
Destructor.
virtual void beginPacket()=0
Mark the beginning of a logical packet.
virtual bool isOk() const =0
Check if the stream is ok or in an error state.
virtual const Contact & getLocalAddress() const =0
Get the address of the local side of the stream.
virtual OutputStream & getOutputStream()=0
Get an OutputStream to write to.
::ssize_t ssize_t
Definition numeric.h:86
An interface to the operating system, including Port based communication.
#define YARP_os_API
Definition api.h:18