YARP
Yet Another Robot Platform
TwoWayStream.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_TWOWAYSTREAM_H
11 #define YARP_OS_TWOWAYSTREAM_H
12 
13 #include <yarp/conf/numeric.h>
14 
15 #include <yarp/os/Contact.h>
16 #include <yarp/os/InputStream.h>
17 #include <yarp/os/OutputStream.h>
18 
19 namespace yarp {
20 namespace os {
21 
29 {
30 public:
34  virtual ~TwoWayStream();
35 
41  virtual InputStream& getInputStream() = 0;
42 
48  virtual OutputStream& getOutputStream() = 0;
49 
56  virtual const Contact& getLocalAddress() const = 0;
57 
64  virtual const Contact& getRemoteAddress() const = 0;
65 
73  virtual bool isOk() const = 0;
74 
78  virtual void reset() = 0;
79 
85  virtual void close() = 0;
86 
94  virtual void beginPacket() = 0;
95 
101  virtual void endPacket() = 0;
102 };
103 
104 
109 {
110 private:
111  Contact address;
112 
113 public:
114  virtual ~NullStream();
115 
116  InputStream& getInputStream() override;
117  OutputStream& getOutputStream() override;
118 
119  const Contact& getLocalAddress() const override;
120  const Contact& getRemoteAddress() const override;
121 
122  bool isOk() const override;
123  void reset() override;
124  void close() override;
125  void beginPacket() override;
126  void endPacket() override;
127 
129  yarp::conf::ssize_t read(Bytes& b) override;
130 
132  void write(const Bytes& b) override;
133 };
134 
135 } // namespace os
136 } // namespace yarp
137 
138 #endif // YARP_OS_TWOWAYSTREAM_H
yarp::os::TwoWayStream::getLocalAddress
virtual const Contact & getLocalAddress() const =0
Get the address of the local side of the stream.
yarp::os::TwoWayStream
A stream which can be asked to perform bidirectional communication.
Definition: TwoWayStream.h:29
yarp::sig::file::read
bool read(ImageOf< PixelRgb > &dest, const std::string &src, image_fileformat format=FORMAT_ANY)
Definition: ImageFile.cpp:827
yarp::os::OutputStream::write
virtual void write(char ch)
Write a single byte to the stream.
Definition: OutputStream.cpp:17
numeric.h
yarp::os::OutputStream
Simple specification of the minimum functions needed from output streams.
Definition: OutputStream.h:25
OutputStream.h
YARP_os_API
#define YARP_os_API
Definition: api.h:19
yarp::os::TwoWayStream::reset
virtual void reset()=0
Reset the stream.
yarp::os::NullStream
A "null" stream, always invalid.
Definition: TwoWayStream.h:109
yarp::os::TwoWayStream::getOutputStream
virtual OutputStream & getOutputStream()=0
Get an OutputStream to write to.
yarp::os::TwoWayStream::close
virtual void close()=0
Terminate the stream.
yarp::os::TwoWayStream::endPacket
virtual void endPacket()=0
Mark the end of a logical packet (see beginPacket).
yarp::os::TwoWayStream::~TwoWayStream
virtual ~TwoWayStream()
Destructor.
yarp::conf::ssize_t
::ssize_t ssize_t
Definition: numeric.h:60
yarp::os::TwoWayStream::getRemoteAddress
virtual const Contact & getRemoteAddress() const =0
Get the address of the remote side of the stream.
yarp::os::Bytes
A simple abstraction for a block of bytes.
Definition: Bytes.h:28
yarp::os::TwoWayStream::beginPacket
virtual void beginPacket()=0
Mark the beginning of a logical packet.
yarp::os::InputStream::read
virtual int read()
Read and return a single byte.
Definition: InputStream.cpp:23
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::os::Contact
Represents how to reach a part of a YARP network.
Definition: Contact.h:39
yarp::os::TwoWayStream::isOk
virtual bool isOk() const =0
Check if the stream is ok or in an error state.
InputStream.h
yarp::os::TwoWayStream::getInputStream
virtual InputStream & getInputStream()=0
Get an InputStream to read from.
yarp::sig::file::write
bool write(const ImageOf< PixelRgb > &src, const std::string &dest, image_fileformat format=FORMAT_PPM)
Definition: ImageFile.cpp:971
Contact.h
yarp::os::InputStream
Simple specification of the minimum functions needed from input streams.
Definition: InputStream.h:29
yarp::os::NullStream::~NullStream
virtual ~NullStream()