1 #ifndef CLIENT_HPP_INCLUDED
2 #define CLIENT_HPP_INCLUDED
8 #include <xmlrpc-c/girerr.hpp>
9 #include <xmlrpc-c/girmem.hpp>
10 #include <xmlrpc-c/base.hpp>
11 #include <xmlrpc-c/timeout.hpp>
12 #include <xmlrpc-c/client_transport.hpp>
16 class clientTransactionPtr;
18 class clientTransaction : public girmem::autoObject {
20 friend class clientTransactionPtr;
24 finish(xmlrpc_c::rpcOutcome const& outcome) = 0;
27 finishErr(girerr::error const& error) = 0;
33 class clientTransactionPtr : public girmem::autoObjectPtr {
36 clientTransactionPtr();
38 virtual ~clientTransactionPtr();
40 virtual xmlrpc_c::clientTransaction *
46 class client : public girmem::autoObject {
47 /*----------------------------------------------------------------------------
48 A generic client -- a means of performing an RPC. This is so generic
49 that it can be used for clients that are not XML-RPC.
51 This is a base class. Derived classes define things such as that
52 XML and HTTP get used to perform the RPC.
53 -----------------------------------------------------------------------------*/
54 friend class clientTransactionPtr;
60 call(xmlrpc_c::carriageParm * const carriageParmP,
61 std::string const& methodName,
62 xmlrpc_c::paramList const& paramList,
63 xmlrpc_c::rpcOutcome * const outcomeP) = 0;
66 start(xmlrpc_c::carriageParm * const carriageParmP,
67 std::string const& methodName,
68 xmlrpc_c::paramList const& paramList,
69 xmlrpc_c::clientTransactionPtr const& tranP);
72 class clientPtr : public girmem::autoObjectPtr {
76 explicit clientPtr(xmlrpc_c::client * const clientP);
85 class serverAccessor : public girmem::autoObject {
88 serverAccessor(xmlrpc_c::clientPtr const clientP,
89 xmlrpc_c::carriageParmPtr const carriageParmP);
92 call(std::string const& methodName,
93 xmlrpc_c::paramList const& paramList,
94 xmlrpc_c::rpcOutcome * const outcomeP) const;
97 xmlrpc_c::clientPtr const clientP;
98 xmlrpc_c::carriageParmPtr const carriageParmP;
101 class serverAccessorPtr : public girmem::autoObjectPtr {
106 serverAccessorPtr(xmlrpc_c::serverAccessor * const serverAccessorP);
108 xmlrpc_c::serverAccessor *
111 xmlrpc_c::serverAccessor *
116 /*----------------------------------------------------------------------------
117 A nexus of a particular client and a particular server, along with
118 carriage parameters for performing RPCs between the two.
120 This is a minor convenience for client programs that always talk to
121 the same server the same way.
123 Use this as a parameter to rpc.call().
124 -----------------------------------------------------------------------------*/
126 connection(xmlrpc_c::client * const clientP,
127 xmlrpc_c::carriageParm * const carriageParmP);
131 xmlrpc_c::client * clientP;
132 xmlrpc_c::carriageParm * carriageParmP;
135 class client_xml : public xmlrpc_c::client {
136 /*----------------------------------------------------------------------------
137 A client that uses XML-RPC XML in the RPC. This class does not define
138 how the XML gets transported, though (i.e. does not require HTTP).
139 -----------------------------------------------------------------------------*/
141 client_xml(xmlrpc_c::clientXmlTransport * const transportP);
143 client_xml(xmlrpc_c::clientXmlTransportPtr const transportP);
146 call(carriageParm * const carriageParmP,
147 std::string const& methodName,
148 xmlrpc_c::paramList const& paramList,
149 xmlrpc_c::rpcOutcome * const outcomeP);
152 start(xmlrpc_c::carriageParm * const carriageParmP,
153 std::string const& methodName,
154 xmlrpc_c::paramList const& paramList,
155 xmlrpc_c::clientTransactionPtr const& tranP);
158 finishAsync(xmlrpc_c::timeout const timeout);
161 /* We have both kinds of pointers to give the user flexibility -- we
162 have constructors that take both. But the simple pointer
163 'transportP' is valid in both cases.
165 xmlrpc_c::clientXmlTransport * transportP;
166 xmlrpc_c::clientXmlTransportPtr transportPtr;
169 class xmlTransaction_client : public xmlrpc_c::xmlTransaction {
172 xmlTransaction_client(xmlrpc_c::clientTransactionPtr const& tranP);
175 finish(std::string const& responseXml) const;
178 finishErr(girerr::error const& error) const;
180 xmlrpc_c::clientTransactionPtr const tranP;
183 class xmlTransaction_clientPtr : public xmlTransactionPtr {
185 xmlTransaction_clientPtr();
187 xmlTransaction_clientPtr(xmlrpc_c::clientTransactionPtr const& tranP);
189 xmlrpc_c::xmlTransaction_client *
195 class rpc : public clientTransaction {
196 /*----------------------------------------------------------------------------
197 An RPC. An RPC consists of method name, parameters, and result. It
198 does not specify in any way how the method name and parameters get
199 turned into a result. It does not presume XML or HTTP.
201 You don't create an object of this class directly. All references to
202 an rpc object should be by an rpcPtr object. Create a new RPC by
203 creating a new rpcPtr. Accordingly, our constructors and destructors
204 are protected, but available to our friend class rpcPtr.
206 In order to do asynchronous RPCs, you normally have to create a derived
207 class that defines a useful notifyComplete(). If you do that, you'll
208 want to make sure the derived class objects get accessed only via rpcPtrs
210 -----------------------------------------------------------------------------*/
211 friend class xmlrpc_c::rpcPtr;
215 call(xmlrpc_c::client * const clientP,
216 xmlrpc_c::carriageParm * const carriageParmP);
219 call(xmlrpc_c::connection const& connection);
222 start(xmlrpc_c::client * const clientP,
223 xmlrpc_c::carriageParm * const carriageParmP);
226 start(xmlrpc_c::connection const& connection);
229 finish(xmlrpc_c::rpcOutcome const& outcome);
232 finishErr(girerr::error const& error);
241 isSuccessful() const;
249 rpc(std::string const methodName,
250 xmlrpc_c::paramList const& paramList);
256 STATE_UNFINISHED, // RPC is running or not started yet
257 STATE_ERROR, // We couldn't execute the RPC
258 STATE_FAILED, // RPC executed successfully, but failed per XML-RPC
259 STATE_SUCCEEDED // RPC is done, no exception
262 girerr::error * errorP; // Defined only in STATE_ERROR
263 xmlrpc_c::rpcOutcome outcome;
264 // Defined only in STATE_FAILED and STATE_SUCCEEDED
265 std::string methodName;
266 xmlrpc_c::paramList paramList;
269 class rpcPtr : public clientTransactionPtr {
273 explicit rpcPtr(xmlrpc_c::rpc * const rpcP);
275 rpcPtr(std::string const methodName,
276 xmlrpc_c::paramList const& paramList);