YARP
Yet Another Robot Platform
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>
14 #include <yarp/os/OutputStream.h>
15 
16 namespace yarp {
17 namespace os {
18 
26 {
27 public:
31  virtual ~TwoWayStream();
32 
38  virtual InputStream& getInputStream() = 0;
39 
45  virtual OutputStream& getOutputStream() = 0;
46 
53  virtual const Contact& getLocalAddress() const = 0;
54 
61  virtual const Contact& getRemoteAddress() const = 0;
62 
70  virtual bool isOk() const = 0;
71 
75  virtual void reset() = 0;
76 
82  virtual void close() = 0;
83 
91  virtual void beginPacket() = 0;
92 
98  virtual void endPacket() = 0;
99 };
100 
101 
106 {
107 private:
108  Contact address;
109 
110 public:
111  virtual ~NullStream();
112 
113  InputStream& getInputStream() override;
114  OutputStream& getOutputStream() override;
115 
116  const Contact& getLocalAddress() const override;
117  const Contact& getRemoteAddress() const override;
118 
119  bool isOk() const override;
120  void reset() override;
121  void close() override;
122  void beginPacket() override;
123  void endPacket() override;
124 
126  yarp::conf::ssize_t read(Bytes& b) override;
127 
129  void write(const Bytes& b) override;
130 };
131 
132 } // namespace os
133 } // namespace yarp
134 
135 #endif // YARP_OS_TWOWAYSTREAM_H
A simple abstraction for a block of bytes.
Definition: Bytes.h:25
Represents how to reach a part of a YARP network.
Definition: Contact.h:36
Simple specification of the minimum functions needed from input streams.
Definition: InputStream.h:26
virtual int read()
Read and return a single byte.
Definition: InputStream.cpp:20
A "null" stream, always invalid.
Definition: TwoWayStream.h:106
Simple specification of the minimum functions needed from output streams.
Definition: OutputStream.h:22
virtual void write(char ch)
Write a single byte to the stream.
A stream which can be asked to perform bidirectional communication.
Definition: TwoWayStream.h:26
virtual OutputStream & getOutputStream()=0
Get an OutputStream to write to.
virtual void endPacket()=0
Mark the end of a logical packet (see beginPacket).
virtual const Contact & getLocalAddress() const =0
Get the address of the local side of the stream.
virtual const Contact & getRemoteAddress() const =0
Get the address of the remote side of the stream.
virtual void close()=0
Terminate the stream.
virtual void reset()=0
Reset the stream.
virtual InputStream & getInputStream()=0
Get an InputStream to read from.
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.
::ssize_t ssize_t
Definition: numeric.h:86
bool read(ImageOf< PixelRgb > &dest, const std::string &src, image_fileformat format=FORMAT_ANY)
Definition: ImageFile.cpp:923
bool write(const ImageOf< PixelRgb > &src, const std::string &dest, image_fileformat format=FORMAT_PPM)
Definition: ImageFile.cpp:1099
The main, catch-all namespace for YARP.
Definition: dirs.h:16
#define YARP_os_API
Definition: api.h:18