1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
|
#ifndef CLIENT_HPP_INCLUDED
#define CLIENT_HPP_INCLUDED
#include <string>
#include <vector>
#include <memory>
#include <xmlrpc-c/girerr.hpp>
#include <xmlrpc-c/girmem.hpp>
#include <xmlrpc-c/base.hpp>
#include <xmlrpc-c/timeout.hpp>
#include <xmlrpc-c/client_transport.hpp>
namespace xmlrpc_c {
class clientTransactionPtr;
class clientTransaction : public girmem::autoObject {
friend class clientTransactionPtr;
public:
virtual void
finish(xmlrpc_c::rpcOutcome const& outcome) = 0;
virtual void
finishErr(girerr::error const& error) = 0;
protected:
clientTransaction();
};
class clientTransactionPtr : public girmem::autoObjectPtr {
public:
clientTransactionPtr();
clientTransactionPtr(clientTransaction * const transP);
virtual ~clientTransactionPtr();
virtual xmlrpc_c::clientTransaction *
operator->() const;
};
class clientPtr;
class client : public girmem::autoObject {
/*----------------------------------------------------------------------------
A generic client -- a means of performing an RPC. This is so generic
that it can be used for clients that are not XML-RPC.
This is a base class. Derived classes define things such as that
XML and HTTP get used to perform the RPC.
-----------------------------------------------------------------------------*/
friend class clientTransactionPtr;
public:
virtual ~client();
virtual void
call(xmlrpc_c::carriageParm * const carriageParmP,
std::string const& methodName,
xmlrpc_c::paramList const& paramList,
xmlrpc_c::rpcOutcome * const outcomeP) = 0;
virtual void
start(xmlrpc_c::carriageParm * const carriageParmP,
std::string const& methodName,
xmlrpc_c::paramList const& paramList,
xmlrpc_c::clientTransactionPtr const& tranP);
void
finishAsync(xmlrpc_c::timeout const timeout);
virtual void
setInterrupt(int *);
};
class clientPtr : public girmem::autoObjectPtr {
public:
clientPtr();
explicit clientPtr(xmlrpc_c::client * const clientP);
xmlrpc_c::client *
operator->() const;
xmlrpc_c::client *
get() const;
};
class serverAccessor : public girmem::autoObject {
public:
serverAccessor(xmlrpc_c::clientPtr const clientP,
xmlrpc_c::carriageParmPtr const carriageParmP);
void
call(std::string const& methodName,
xmlrpc_c::paramList const& paramList,
xmlrpc_c::rpcOutcome * const outcomeP) const;
private:
xmlrpc_c::clientPtr const clientP;
xmlrpc_c::carriageParmPtr const carriageParmP;
};
class serverAccessorPtr : public girmem::autoObjectPtr {
public:
serverAccessorPtr();
explicit
serverAccessorPtr(xmlrpc_c::serverAccessor * const serverAccessorP);
xmlrpc_c::serverAccessor *
operator->() const;
xmlrpc_c::serverAccessor *
get() const;
};
class connection {
/*----------------------------------------------------------------------------
A nexus of a particular client and a particular server, along with
carriage parameters for performing RPCs between the two.
This is a minor convenience for client programs that always talk to
the same server the same way.
Use this as a parameter to rpc.call().
-----------------------------------------------------------------------------*/
public:
connection(xmlrpc_c::client * const clientP,
xmlrpc_c::carriageParm * const carriageParmP);
~connection();
xmlrpc_c::client * clientP;
xmlrpc_c::carriageParm * carriageParmP;
};
class client_xml : public xmlrpc_c::client {
/*----------------------------------------------------------------------------
A client that uses XML-RPC XML in the RPC. This class does not define
how the XML gets transported, though (i.e. does not require HTTP).
-----------------------------------------------------------------------------*/
public:
client_xml(xmlrpc_c::clientXmlTransport * const transportP);
client_xml(xmlrpc_c::clientXmlTransport * const transportP,
xmlrpc_dialect const dialect);
client_xml(xmlrpc_c::clientXmlTransportPtr const transportP);
client_xml(xmlrpc_c::clientXmlTransportPtr const transportP,
xmlrpc_dialect const dialect);
~client_xml();
void
call(carriageParm * const carriageParmP,
std::string const& methodName,
xmlrpc_c::paramList const& paramList,
xmlrpc_c::rpcOutcome * const outcomeP);
void
start(xmlrpc_c::carriageParm * const carriageParmP,
std::string const& methodName,
xmlrpc_c::paramList const& paramList,
xmlrpc_c::clientTransactionPtr const& tranP);
void
finishAsync(xmlrpc_c::timeout const timeout);
virtual void
setInterrupt(int * interruptP);
private:
struct client_xml_impl * implP;
};
class xmlTransaction_client : public xmlrpc_c::xmlTransaction {
public:
xmlTransaction_client(xmlrpc_c::clientTransactionPtr const& tranP);
void
finish(std::string const& responseXml) const;
void
finishErr(girerr::error const& error) const;
private:
xmlrpc_c::clientTransactionPtr const tranP;
};
class xmlTransaction_clientPtr : public xmlTransactionPtr {
public:
xmlTransaction_clientPtr();
xmlTransaction_clientPtr(xmlrpc_c::clientTransactionPtr const& tranP);
xmlrpc_c::xmlTransaction_client *
operator->() const;
};
class rpcPtr;
class rpc : public clientTransaction {
/*----------------------------------------------------------------------------
An RPC. An RPC consists of method name, parameters, and result. It
does not specify in any way how the method name and parameters get
turned into a result. It does not presume XML or HTTP.
You don't create an object of this class directly. All references to
an rpc object should be by an rpcPtr object. Create a new RPC by
creating a new rpcPtr. Accordingly, our constructors and destructors
are protected, but available to our friend class rpcPtr.
In order to do asynchronous RPCs, you normally have to create a derived
class that defines a useful notifyComplete(). If you do that, you'll
want to make sure the derived class objects get accessed only via rpcPtrs
as well.
-----------------------------------------------------------------------------*/
friend class xmlrpc_c::rpcPtr;
public:
void
call(xmlrpc_c::client * const clientP,
xmlrpc_c::carriageParm * const carriageParmP);
void
call(xmlrpc_c::connection const& connection);
void
start(xmlrpc_c::client * const clientP,
xmlrpc_c::carriageParm * const carriageParmP);
void
start(xmlrpc_c::connection const& connection);
void
finish(xmlrpc_c::rpcOutcome const& outcome);
void
finishErr(girerr::error const& error);
virtual void
notifyComplete();
bool
isFinished() const;
bool
isSuccessful() const;
xmlrpc_c::value
getResult() const;
xmlrpc_c::fault
getFault() const;
rpc(std::string const methodName,
xmlrpc_c::paramList const& paramList);
virtual ~rpc();
private:
struct rpc_impl * implP;
};
class rpcPtr : public clientTransactionPtr {
public:
rpcPtr();
explicit rpcPtr(xmlrpc_c::rpc * const rpcP);
rpcPtr(std::string const methodName,
xmlrpc_c::paramList const& paramList);
xmlrpc_c::rpc *
operator->() const;
};
} // namespace
#endif
|