YARP
Yet Another Robot Platform
ConnectionWriter.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_CONNECTIONWRITER_H
11 #define YARP_OS_CONNECTIONWRITER_H
12 
13 #include <yarp/os/api.h>
14 #include <string>
15 #include <yarp/conf/numeric.h>
16 
17 namespace yarp {
18  namespace os {
19  class ConnectionWriter;
20  class ConnectionReader;
21  class PortReader;
22  class PortWriter;
23  class Portable;
24  class SizedWriter;
25  class OutputStream;
26  }
27 }
28 
35 public:
36 
40  virtual ~ConnectionWriter();
41 
52  virtual void appendBlock(const char *data, size_t len) = 0;
53 
59  YARP_DEPRECATED_INTERNAL_MSG("Use appendInt32 instead") // Since YARP 3.0.0
60  virtual void appendInt(int data) final { appendInt32(static_cast<std::int32_t>(data)); }
61 
66  virtual void appendInt8(std::int8_t data) = 0;
67 
72  virtual void appendInt16(std::int16_t data) = 0;
73 
78  virtual void appendInt32(std::int32_t data) = 0;
79 
84  virtual void appendInt64(std::int64_t data) = 0;
85 
93  YARP_DEPRECATED_INTERNAL_MSG("Use appendFloat64 instead") // Since YARP 3.0.0
94  virtual void appendDouble(double data) { appendFloat64(static_cast<yarp::conf::float64_t>(data)); }
95 
102  virtual void appendFloat32(yarp::conf::float32_t data) = 0;
103 
110  virtual void appendFloat64(yarp::conf::float64_t data) = 0;
111 
117  virtual void appendString(const char *str, int terminate = '\n') = 0;
118 
127  virtual void appendExternalBlock(const char *data, size_t len) = 0;
128 
135  virtual bool isTextMode() const = 0;
136 
142  virtual bool isBareMode() const = 0;
143 
151  virtual void declareSizes(int argc, int *argv) = 0;
152 
159  virtual void setReplyHandler(PortReader& reader) = 0;
160 
166  virtual void setReference(Portable *obj) = 0;
167 
168 
177  virtual bool convertTextMode() = 0;
178 
179 
184  virtual bool isValid() const = 0;
185 
190  virtual bool isActive() const = 0;
191 
198  virtual bool isError() const = 0;
199 
200 
206  virtual void requestDrop() = 0;
207 
213  virtual bool isNull() const;
214 
215 
221  virtual SizedWriter *getBuffer() const = 0;
222 
223 
224  virtual void appendRawString(const std::string& str) {
225  appendInt32(static_cast<std::int32_t>(str.length()));
226  appendBlock((char*)str.c_str(), str.length());
227  }
228 
235  static ConnectionWriter *createBufferedConnectionWriter();
236 
237  static bool writeToStream(PortWriter& portable, OutputStream& os);
238 };
239 
240 #endif // YARP_OS_CONNECTIONWRITER_H
This is a base class for objects that can be both read from and be written to the YARP network...
Definition: Portable.h:27
#define YARP_OS_API
Definition: api.h:19
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
Definition: PortWriter.h:26
The main, catch-all namespace for YARP.
Definition: numeric.h:47
An interface for writing to a network connection.
virtual void appendRawString(const std::string &str)
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition: PortReader.h:27
Simple specification of the minimum functions needed from output streams.
Definition: OutputStream.h:24
double float64_t
Definition: numeric.h:51
float float32_t
Definition: numeric.h:50
#define YARP_DEPRECATED_INTERNAL_MSG(X)
Definition: api.h:139
Minimal requirements for an efficient Writer.
Definition: SizedWriter.h:34
bool isValid()
Check if time is valid (non-zero).
Definition: Time.cpp:308