YARP
Yet Another Robot Platform
ConnectionReader.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2018 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_CONNECTIONREADER_H
11 #define YARP_OS_CONNECTIONREADER_H
12 
13 #include <string>
14 #include <yarp/os/Contact.h>
15 #include <yarp/os/Bytes.h>
16 #include <yarp/os/Searchable.h>
17 #include <yarp/conf/numeric.h>
18 
19 namespace yarp {
20  namespace os {
21  class ConnectionReader;
22  class ConnectionWriter;
23  class PortReader;
24  class Portable;
25  class InputStream;
26  }
27 }
28 
35 public:
39  virtual ~ConnectionReader();
40 
48  virtual bool expectBlock(char *data, size_t len) = 0;
49 
55  virtual std::string expectText(int terminatingChar = '\n') = 0;
56 
62  YARP_DEPRECATED_INTERNAL_MSG("Use expectInt32 instead") // Since YARP 3.0.0
63  virtual int expectInt() final { return static_cast<int>(expectInt32()); }
64 
69  virtual std::int8_t expectInt8() = 0;
70 
75  virtual std::int16_t expectInt16() = 0;
76 
81  virtual std::int32_t expectInt32() = 0;
82 
87  virtual std::int64_t expectInt64() = 0;
88 
94  YARP_DEPRECATED_INTERNAL_MSG("Use expectFloat64 instead") // Since YARP 3.0.0
95  virtual double expectDouble() { return static_cast<double>(expectFloat64()); }
96 
101  virtual yarp::conf::float32_t expectFloat32() = 0;
102 
107  virtual yarp::conf::float64_t expectFloat64() = 0;
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 
146  virtual ConnectionWriter *getWriter() = 0;
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 
242 #endif // YARP_OS_CONNECTIONREADER_H
A base class for nested structures that can be searched.
Definition: Searchable.h:65
This is a base class for objects that can be both read from and be written to the YARP network...
Definition: Portable.h:27
Simple specification of the minimum functions needed from input streams.
Definition: InputStream.h:26
#define YARP_OS_API
Definition: api.h:19
A simple abstraction for a block of bytes.
Definition: Bytes.h:27
The main, catch-all namespace for YARP.
Definition: numeric.h:47
An interface for writing to a network connection.
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition: PortReader.h:27
An interface for reading from a network connection.
double float64_t
Definition: numeric.h:51
float float32_t
Definition: numeric.h:50
#define YARP_DEPRECATED_INTERNAL_MSG(X)
Definition: api.h:139
Represents how to reach a part of a YARP network.
Definition: Contact.h:34
bool isValid()
Check if time is valid (non-zero).
Definition: Time.cpp:308