YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ConnectionWriter.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_CONNECTIONWRITER_H
8#define YARP_OS_CONNECTIONWRITER_H
9
10#include <yarp/conf/numeric.h>
11
12#include <yarp/os/api.h>
13
14#include <string>
15
16namespace yarp::os {
17class ConnectionReader;
18class PortReader;
19class PortWriter;
20class Portable;
21class SizedWriter;
22class OutputStream;
23} // namespace yarp::os
24
25
26namespace yarp::os {
27
34{
35public:
40
51 virtual void appendBlock(const char* data, size_t len) = 0;
52
57 virtual void appendInt8(std::int8_t data) = 0;
58
63 virtual void appendInt16(std::int16_t data) = 0;
64
69 virtual void appendInt32(std::int32_t data) = 0;
70
75 virtual void appendInt64(std::int64_t data) = 0;
76
83 virtual void appendFloat32(yarp::conf::float32_t data) = 0;
84
91 virtual void appendFloat64(yarp::conf::float64_t data) = 0;
92
102 virtual void appendText(const std::string& str, const char terminate = '\n') = 0;
103
113 void appendString(const std::string& str)
114 {
115 appendInt32(static_cast<std::int32_t>(str.length()));
116 appendBlock((char*)str.c_str(), str.length());
117 }
118
126 virtual void appendExternalBlock(const char* data, size_t len) = 0;
127
134 virtual bool isTextMode() const = 0;
135
141 virtual bool isBareMode() const = 0;
142
150 virtual void declareSizes(int argc, int* argv) = 0;
151
158 virtual void setReplyHandler(PortReader& reader) = 0;
159
165 virtual void setReference(Portable* obj) = 0;
166
167
176 virtual bool convertTextMode() = 0;
177
178
183 virtual bool isValid() const = 0;
184
189 virtual bool isActive() const = 0;
190
197 virtual bool isError() const = 0;
198
199
205 virtual void requestDrop() = 0;
206
212 virtual bool isNull() const;
213
214
218 virtual SizedWriter* getBuffer() = 0;
219
223 virtual const SizedWriter* getBuffer() const = 0;
224
231 static ConnectionWriter* createBufferedConnectionWriter();
232
233 static bool writeToStream(PortWriter& portable, OutputStream& os);
234};
235
236} // namespace yarp::os
237
238#endif // YARP_OS_CONNECTIONWRITER_H
A mini-server for performing network communication in the background.
An interface for writing to a network connection.
virtual bool isError() const =0
virtual void setReplyHandler(PortReader &reader)=0
This sets a handler to deal with replies to the message.
virtual void appendInt64(std::int64_t data)=0
Send a representation of a 64-bit integer to the network connection.
virtual bool isBareMode() const =0
Check if the connection is bare mode.
virtual bool isTextMode() const =0
Check if the connection is text mode.
virtual const SizedWriter * getBuffer() const =0
virtual ~ConnectionWriter()
Destructor.
virtual void appendText(const std::string &str, const char terminate='\n')=0
Send a terminated string to the network connection.
virtual void appendInt8(std::int8_t data)=0
Send a representation of a 8-bit integer to the network connection.
virtual SizedWriter * getBuffer()=0
virtual void appendFloat32(yarp::conf::float32_t data)=0
Send a representation of a 32-bit floating point number to the network connection.
virtual void appendExternalBlock(const char *data, size_t len)=0
Send a block of data to the network connection, without making a copy.
virtual void appendInt16(std::int16_t data)=0
Send a representation of a 16-bit integer to the network connection.
virtual void declareSizes(int argc, int *argv)=0
If you can easily determine how many blocks there are in a message, call this first,...
virtual void setReference(Portable *obj)=0
Stores a direct pointer to the object being sent.
virtual bool convertTextMode()=0
Converts a standard description in binary into a textual description, if the connection is in text-mo...
virtual void appendInt32(std::int32_t data)=0
Send a representation of a 32-bit integer to the network connection.
virtual void appendFloat64(yarp::conf::float64_t data)=0
Send a representation of a 64-bit floating point number to the network connection.
virtual bool isValid() const =0
virtual void appendBlock(const char *data, size_t len)=0
Send a block of data to the network connection.
void appendString(const std::string &str)
Send a string to the network connection.
virtual void requestDrop()=0
Tag the connection to be dropped after the current message.
virtual bool isActive() const =0
Simple specification of the minimum functions needed from output streams.
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition PortReader.h:24
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
Definition PortWriter.h:23
This is a base class for objects that can be both read from and be written to the YARP network.
Definition Portable.h:25
Minimal requirements for an efficient Writer.
Definition SizedWriter.h:32
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