XmlRpcClient.h
Go to the documentation of this file.
1 #include "sick_scan/sick_scan_base.h" /* Base definitions included in all header files, added by add_sick_scan_base_header.py. Do not edit this line. */
2 
3 #ifndef _XMLRPCCLIENT_H_
4 #define _XMLRPCCLIENT_H_
5 //
6 // XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
7 //
8 #if defined(_MSC_VER)
9 # pragma warning(disable:4786) // identifier was truncated in debug info
10 #endif
11 
12 
13 #ifndef MAKEDEPEND
14 # include <string>
15 #endif
16 
17 #include "xmlrpcpp/XmlRpcDispatch.h"
18 #include "xmlrpcpp/XmlRpcSource.h"
19 #include "xmlrpcpp/XmlRpcDecl.h"
20 
21 namespace XmlRpc {
22 
23  // Arguments and results are represented by XmlRpcValues
24  class XmlRpcValue;
25 
27  class XMLRPCPP_DECL XmlRpcClient : public XmlRpcSource {
28  public:
29  // Static data
30  static const char REQUEST_BEGIN[];
31  static const char REQUEST_END_METHODNAME[];
32  static const char PARAMS_TAG[];
33  static const char PARAMS_ETAG[];
34  static const char PARAM_TAG[];
35  static const char PARAM_ETAG[];
36  static const char REQUEST_END[];
37  // Result tags
38  static const char METHODRESPONSE_TAG[];
39  static const char FAULT_TAG[];
40 
45  XmlRpcClient(const char* host, int port, const char* uri=0);
46 
48  virtual ~XmlRpcClient();
49 
60  bool execute(const char* method, XmlRpcValue const& params, XmlRpcValue& result);
61 
62  bool executeNonBlock(const char* method, XmlRpcValue const& params);
63  bool executeCheckDone(XmlRpcValue& result);
64 
66  bool isFault() const { return _isFault; }
67 
68 
69  // XmlRpcSource interface implementation
71  virtual void close();
72 
76  virtual unsigned handleEvent(unsigned eventType);
77 
78  protected:
79  // Execution processing helpers
80  virtual bool doConnect();
81  virtual bool setupConnection();
82 
83  virtual bool generateRequest(const char* method, XmlRpcValue const& params);
84  virtual std::string generateHeader(std::string const& body);
85  virtual bool writeRequest();
86  virtual bool readHeader();
87  virtual bool readResponse();
88  virtual bool parseResponse(XmlRpcValue& result);
89 
90  // Possible IO states for the connection
91  enum ClientConnectionState { NO_CONNECTION, CONNECTING, WRITE_REQUEST, READ_HEADER, READ_RESPONSE, IDLE };
92  ClientConnectionState _connectionState;
93 
94  // Server location
95  std::string _host;
96  std::string _uri;
97  int _port;
98  public:
99  const std::string &getHost() { return _host; }
100  const std::string &getUri() { return _uri; }
101  int getPort() const { return _port; }
102 
103  // The xml-encoded request, http header of response, and response xml
104  std::string _request;
105  std::string _header;
106  std::string _response;
107 
108  // Number of times the client has attempted to send the request
109  int _sendAttempts;
110 
111  // Number of bytes of the request that have been written to the socket so far
112  int _bytesWritten;
113 
114  // True if we are currently executing a request. If you want to multithread,
115  // each thread should have its own client.
116  bool _executing;
117 
118  // True if the server closed the connection
119  bool _eof;
120 
121  // True if a fault response was returned by the server
122  bool _isFault;
123 
124  // Number of bytes expected in the response body (parsed from response header)
125  int _contentLength;
126 
127  // Event dispatcher
128  XmlRpcDispatch _disp;
129 
130  }; // class XmlRpcClient
131 
132 } // namespace XmlRpc
133 
134 #endif // _XMLRPCCLIENT_H_
roswrap::master::execute
ROSCPP_DECL bool execute(const std::string &method, const XmlRpc::XmlRpcValue &request, XmlRpc::XmlRpcValue &response, XmlRpc::XmlRpcValue &payload, bool wait_for_master)
Execute an XMLRPC call on the master.
XmlRpc
roswrap::master::getPort
ROSCPP_DECL uint32_t getPort()
Get the port where the master runs.
sick_scan_base.h
roswrap::master::getHost
const ROSCPP_DECL std::string & getHost()
Get the hostname where the master runs.
XMLRPCPP_DECL
#define XMLRPCPP_DECL
Definition: XmlRpcDecl.h:53


sick_scan_xd
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Fri Oct 25 2024 02:47:13