00001
00002
00003
00004
00005 #ifndef _XMLRPCSERVER_H_
00006 #define _XMLRPCSERVER_H_
00007
00008
00009
00010 #if defined(_MSC_VER)
00011 # pragma warning(disable:4786) // identifier was truncated in debug info
00012 #endif
00013
00014 #ifndef MAKEDEPEND
00015 # include <map>
00016 # include <string>
00017 #endif
00018
00019 #include "XmlRpcDispatch.h"
00020 #include "XmlRpcSource.h"
00021 #include "XmlRpcDecl.h"
00022
00023 namespace XmlRpc {
00024
00025
00026
00027 class XmlRpcServerMethod;
00028
00029
00030 class XmlRpcServerConnection;
00031
00032
00033 class XmlRpcValue;
00034
00035
00037 class XMLRPCPP_DECL XmlRpcServer : public XmlRpcSource {
00038 public:
00040 XmlRpcServer();
00042 virtual ~XmlRpcServer();
00043
00045 void enableIntrospection(bool enabled=true);
00046
00048 void addMethod(XmlRpcServerMethod* method);
00049
00051 void removeMethod(XmlRpcServerMethod* method);
00052
00054 void removeMethod(const std::string& methodName);
00055
00057 XmlRpcServerMethod* findMethod(const std::string& name) const;
00058
00061 bool bindAndListen(int port, int backlog = 5);
00062
00064 void work(double msTime);
00065
00067 void exit();
00068
00070 void shutdown();
00071
00073 void listMethods(XmlRpcValue& result);
00074
00075
00076
00078 virtual unsigned handleEvent(unsigned eventType);
00079
00081 virtual void removeConnection(XmlRpcServerConnection*);
00082
00083 inline int get_port() { return _port; }
00084
00085 XmlRpcDispatch *get_dispatch() { return &_disp; }
00086
00087 protected:
00088
00090 virtual void acceptConnection();
00091
00093 virtual XmlRpcServerConnection* createConnection(int socket);
00094
00095
00096 bool _introspectionEnabled;
00097
00098
00099 XmlRpcDispatch _disp;
00100
00101
00102 typedef std::map< std::string, XmlRpcServerMethod* > MethodMap;
00103 MethodMap _methods;
00104
00105
00106 XmlRpcServerMethod* _listMethods;
00107 XmlRpcServerMethod* _methodHelp;
00108
00109 int _port;
00110
00111 };
00112 }
00113
00114 #endif //_XMLRPCSERVER_H_