1 #ifndef REGISTRY_HPP_INCLUDED
2 #define REGISTRY_HPP_INCLUDED
8 #include <xmlrpc-c/server.h>
9 #include <xmlrpc-c/girmem.hpp>
10 #include <xmlrpc-c/base.hpp>
15 class method : public girmem::autoObject {
16 /*----------------------------------------------------------------------------
19 This base class is abstract. You can't create an object in it.
20 Define a useful method with this as a base class, with an
22 -----------------------------------------------------------------------------*/
29 execute(xmlrpc_c::paramList const& paramList,
30 xmlrpc_c::value * const resultP) = 0;
32 std::string signature() const { return _signature; };
33 std::string help() const { return _help; };
36 std::string _signature;
40 /* Example of a specific method class:
42 class sample_add : public xmlrpc_c::method {
45 this->_signature = "ii";
46 this->_help = "This method adds two integers together";
49 execute(xmlrpc_c::param_list const paramList,
50 const xmlrpc_c::value * const retvalP) {
52 int const addend(paramList.getInt(0));
53 int const adder(paramList.getInt(1));
55 *retvalP = xmlrpc_c::value(addend, adder);
60 Example of creating such a method:
62 methodPtr const sampleAddMethodP(new sample_add);
64 You pass around, copy, etc. the handle sampleAddMethodP and when
65 the last copy of the handle is gone, the sample_add object itself
71 class methodPtr : public girmem::autoObjectPtr {
74 methodPtr(xmlrpc_c::method * const methodP);
80 class defaultMethod : public girmem::autoObject {
83 virtual ~defaultMethod();
86 execute(std::string const& methodName,
87 xmlrpc_c::paramList const& paramList,
88 xmlrpc_c::value * const resultP) = 0;
91 class defaultMethodPtr : public girmem::autoObjectPtr {
96 defaultMethodPtr(xmlrpc_c::defaultMethod * const methodP);
98 xmlrpc_c::defaultMethod *
101 xmlrpc_c::defaultMethod *
105 class registry : public girmem::autoObject {
106 /*----------------------------------------------------------------------------
107 An Xmlrpc-c server method registry. An Xmlrpc-c server transport
108 (e.g. an HTTP server) uses this object to process an incoming
110 -----------------------------------------------------------------------------*/
118 addMethod(std::string const name,
119 xmlrpc_c::methodPtr const methodP);
122 setDefaultMethod(xmlrpc_c::defaultMethodPtr const methodP);
125 disableIntrospection();
128 processCall(std::string const& body,
129 std::string * const responseP) const;
133 /* This is meant to be private except to other objects in the
139 xmlrpc_registry * c_registryP;
140 /* Pointer to the C registry object we use to implement this
144 std::list<xmlrpc_c::methodPtr> methodList;
145 /* This is a list of all the method objects (actually, pointers
146 to them). But since the real registry is the C registry object,
147 all this list is for is to maintain references to the objects
148 to which the C registry points so that they continue to exist.
150 xmlrpc_c::defaultMethodPtr defaultMethodP;
151 /* The real identifier of the default method is the C registry
152 object; this member exists only to maintain a reference to the
153 object to which the C registry points so that it will continue
159 class registryPtr : public girmem::autoObjectPtr {
164 registryPtr(xmlrpc_c::registry * const registryP);