YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ConnectionReader.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_CONNECTIONREADER_H
8#define YARP_OS_CONNECTIONREADER_H
9
10#include <yarp/conf/numeric.h>
11
12#include <yarp/os/Bytes.h>
13#include <yarp/os/Contact.h>
14#include <yarp/os/Searchable.h>
15
16#include <string>
17
18namespace yarp::os {
19class ConnectionWriter;
20class PortReader;
21class Portable;
22class InputStream;
23} // namespace yarp::os
24
25
26namespace yarp::os {
27
34{
35public:
40
48 virtual bool expectBlock(char* data, size_t len) = 0;
49
55 virtual std::string expectText(const char terminatingChar = '\n') = 0;
56
62 virtual std::string expectString()
63 {
64 std::string ret;
65 std::int32_t len = expectInt32();
66 if (!isError()) {
67 ret.resize(static_cast<size_t>(len));
68 expectBlock(const_cast<char*>(ret.data()), len);
69 }
70 return ret;
71 }
72
77 virtual std::int8_t expectInt8() = 0;
78
83 virtual std::int16_t expectInt16() = 0;
84
89 virtual std::int32_t expectInt32() = 0;
90
95 virtual std::int64_t expectInt64() = 0;
96
102
108
115 virtual bool isTextMode() const = 0;
116
122 virtual bool isBareMode() const = 0;
123
132 virtual bool convertTextMode() = 0;
133
138 virtual size_t getSize() const = 0;
139
140
147
153 virtual Bytes readEnvelope();
154
162 virtual Portable* getReference() const = 0;
163
171 virtual Contact getRemoteContact() const = 0;
172
180 virtual Contact getLocalContact() const = 0;
181
186 virtual bool isValid() const = 0;
187
192 virtual bool isActive() const = 0;
193
200 virtual bool isError() const = 0;
201
205 virtual void requestDrop() = 0;
206
213 virtual const Searchable& getConnectionModifiers() const = 0;
214
220 virtual bool pushInt(int x) = 0;
221
222 virtual bool setSize(size_t len) = 0;
223
230 static ConnectionReader* createConnectionReader(InputStream& is);
231
232 static bool readFromStream(PortReader& portable, InputStream& is);
233
239 virtual void setParentConnectionReader(ConnectionReader* parentConnectionReader);
240
241 virtual void flushWriter() = 0;
242};
243
244} // namespace yarp::os
245
246#endif // YARP_OS_CONNECTIONREADER_H
bool ret
A mini-server for performing network communication in the background.
A simple abstraction for a block of bytes.
Definition Bytes.h:24
An interface for reading from a network connection.
virtual std::string expectString()
Read a string from the network connection.
virtual bool isTextMode() const =0
Check if the connection is text mode.
virtual size_t getSize() const =0
Checks how much data is available.
virtual bool expectBlock(char *data, size_t len)=0
Read a block of data from the network connection.
virtual void flushWriter()=0
virtual bool isBareMode() const =0
Check if the connection is bare mode.
virtual bool pushInt(int x)=0
Store an integer to return on the next call to expectInt()
virtual std::int32_t expectInt32()=0
Read a 32-bit integer from the network connection.
virtual void requestDrop()=0
Tag the connection to be dropped after the current message.
virtual ConnectionWriter * getWriter()=0
Gets a way to reply to the message, if possible.
virtual std::string expectText(const char terminatingChar='\n')=0
Read some text from the network connection.
virtual bool convertTextMode()=0
Reads in a standard description in text mode, and converts it to a standard description in binary.
virtual Portable * getReference() const =0
Get a direct pointer to the object being sent, if possible.
virtual yarp::conf::float32_t expectFloat32()=0
Read a 32-bit floating point number from the network connection.
virtual Contact getRemoteContact() const =0
Gets information about who is supplying the data being read, if that information is available.
virtual bool setSize(size_t len)=0
virtual std::int64_t expectInt64()=0
Read a 64-bit integer from the network connection.
virtual Contact getLocalContact() const =0
Gets information about who is receiving the data, if that information is available.
virtual bool isActive() const =0
virtual ~ConnectionReader()
Destructor.
virtual bool isValid() const =0
virtual bool isError() const =0
virtual std::int16_t expectInt16()=0
Read a 16-bit integer from the network connection.
virtual std::int8_t expectInt8()=0
Read a 8-bit integer from the network connection.
virtual yarp::conf::float64_t expectFloat64()=0
Read a 64-bit floating point number from the network connection.
virtual const Searchable & getConnectionModifiers() const =0
Access modifiers associated with the connection, if any.
An interface for writing to a network connection.
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
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition PortReader.h:24
This is a base class for objects that can be both read from and be written to the YARP network.
Definition Portable.h:25
A base class for nested structures that can be searched.
Definition Searchable.h:31
double float64_t
Definition numeric.h:77
float float32_t
Definition numeric.h:76
An interface to the operating system, including Port based communication.
#define YARP_os_API
Definition api.h:18