YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
StreamConnectionReader.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_IMPL_STREAMCONNECTIONREADER_H
8#define YARP_OS_IMPL_STREAMCONNECTIONREADER_H
9
10#include <yarp/os/Bottle.h>
11#include <yarp/os/Bytes.h>
13#include <yarp/os/Contact.h>
14#include <yarp/os/InputStream.h>
15#include <yarp/os/NetFloat32.h>
16#include <yarp/os/NetFloat64.h>
17#include <yarp/os/NetInt16.h>
18#include <yarp/os/NetInt32.h>
19#include <yarp/os/NetInt64.h>
20#include <yarp/os/NetInt8.h>
21#include <yarp/os/NetType.h>
22#include <yarp/os/Route.h>
25
26namespace yarp::os::impl {
27
28class BufferedConnectionWriter;
29class Protocol;
30
36 public ConnectionReader
37{
38public:
41
42 void reset(yarp::os::InputStream& in, TwoWayStream* str, const Route& route, size_t len, bool textMode, bool bareMode = false);
43 void setProtocol(Protocol* protocol);
44 void suppressReply();
45 bool dropRequested();
46
47 virtual bool expectBlock(yarp::os::Bytes& b);
48#ifndef YARP_NO_DEPRECATED // Since YARP 3.2
49 using ConnectionReader::expectString;
50 virtual std::string expectString(int len);
51#endif
52 virtual std::string expectLine();
53 virtual void setReference(yarp::os::Portable* obj);
54
55 /**** OVERRIDES ****/
56 bool setSize(size_t len) override;
57 size_t getSize() const override;
58 bool pushInt(int x) override;
59 std::int8_t expectInt8() override;
60 std::int16_t expectInt16() override;
61 std::int32_t expectInt32() override;
62 std::int64_t expectInt64() override;
63 yarp::conf::float32_t expectFloat32() override;
64 yarp::conf::float64_t expectFloat64() override;
65 bool expectBlock(char* data, size_t len) override;
66 std::string expectText(const char terminatingChar) override;
67 bool isTextMode() const override;
68 bool isBareMode() const override;
69 bool convertTextMode() override;
70 yarp::os::ConnectionWriter* getWriter() override;
71 yarp::os::Contact getRemoteContact() const override;
72 yarp::os::Contact getLocalContact() const override;
73 bool isValid() const override;
74 bool isError() const override;
75 bool isActive() const override;
76 yarp::os::Portable* getReference() const override;
77 yarp::os::Bytes readEnvelope() override;
78 void requestDrop() override;
79 const yarp::os::Searchable& getConnectionModifiers() const override;
80 void setParentConnectionReader(ConnectionReader* parentConnectionReader) override;
81 void flushWriter() override;
82
83private:
84 bool isGood();
85
86 template <typename T, typename NetT>
87 T expectType();
88
90 StringInputStream altStream;
92 TwoWayStream* str;
93 Protocol* protocol;
94 size_t messageLen;
95 bool textMode;
96 bool bareMode;
97 bool valid;
98 bool err;
99 bool shouldDrop;
100 bool writePending;
101 Route route;
103 yarp::os::Bottle config;
104 bool convertedTextMode;
105 bool pushedIntFlag;
106 int pushedInt;
107 ConnectionReader* parentConnectionReader;
108};
109
110} // namespace yarp::os::impl
111
112#endif // YARP_OS_IMPL_STREAMCONNECTIONREADER_H
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:64
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.
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
This is a base class for objects that can be both read from and be written to the YARP network.
Definition Portable.h:25
Information about a connection between two ports.
Definition Route.h:28
A base class for nested structures that can be searched.
Definition Searchable.h:31
An InputStream that reads from a string.
A stream which can be asked to perform bidirectional communication.
A helper for creating cached object descriptions.
Connection choreographer.
Definition Protocol.h:29
Lets Readable objects read from the underlying InputStream associated with the connection between two...
The components from which ports and connections are built.
#define YARP_os_impl_API
Definition api.h:46