YARP  2.3.68+220-20170323.2+git4955ef0
Yet Another Robot Platform
ConnectionWriter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006 RobotCub Consortium
3  * Authors: Paul Fitzpatrick
4  * CopyPolicy: Released under the terms of the LGPLv2.1 or later, see LGPL.TXT
5  */
6 
7 #ifndef YARP_OS_CONNECTIONWRITER_H
8 #define YARP_OS_CONNECTIONWRITER_H
9 
10 #include <yarp/os/ConstString.h>
11 #include <yarp/conf/numeric.h>
12 
13 namespace yarp {
14  namespace os {
15  class ConnectionWriter;
16  class ConnectionReader;
17  class PortReader;
18  class PortWriter;
19  class Portable;
20  class SizedWriter;
21  class OutputStream;
22  }
23 }
24 
30 class YARP_OS_API yarp::os::ConnectionWriter {
31 public:
32 
36  virtual ~ConnectionWriter();
37 
48  virtual void appendBlock(const char *data, size_t len) = 0;
49 
54  virtual void appendInt(int data) = 0;
55 
60  virtual void appendInt64(const YARP_INT64& data) = 0;
61 
68  virtual void appendDouble(double data) = 0;
69 
75  virtual void appendString(const char *str, int terminate = '\n') = 0;
76 
85  virtual void appendExternalBlock(const char *data, size_t len) = 0;
86 
93  virtual bool isTextMode() = 0;
94 
100  virtual bool isBareMode() = 0;
101 
109  virtual void declareSizes(int argc, int *argv) = 0;
110 
117  virtual void setReplyHandler(PortReader& reader) = 0;
118 
124  virtual void setReference(Portable *obj) = 0;
125 
126 
135  virtual bool convertTextMode() = 0;
136 
137 
142  virtual bool isValid() = 0;
143 
148  virtual bool isActive() = 0;
149 
156  virtual bool isError() = 0;
157 
158 
164  virtual void requestDrop() = 0;
165 
171  virtual bool isNull() const;
172 
173 
179  virtual SizedWriter *getBuffer() = 0;
180 
181 
182  virtual void appendRawString(const ConstString& str) {
183  appendInt(str.length());
184  appendBlock((char*)str.c_str(),str.length());
185  }
186 
193  static ConnectionWriter *createBufferedConnectionWriter();
194 
195  static bool writeToStream(PortWriter& portable, OutputStream& os);
196 };
197 
198 #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:26
#define YARP_INT64
Definition: numeric.h:64
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
Definition: PortWriter.h:24
The main, catch-all namespace for YARP.
A string with almost the same api as std::string.
Definition: ConstString.h:44
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:25
Simple specification of the minimum functions needed from output streams.
Definition: OutputStream.h:22
size_t length() const
const char * c_str() const
Accesses the character sequence stored in this object.
Definition: ConstString.cpp:88
Minimal requirements for an efficient Writer.
Definition: SizedWriter.h:29
virtual void appendRawString(const ConstString &str)