00001 00002 #ifndef _XMLRPCSERVER_H_ 00003 #define _XMLRPCSERVER_H_ 00004 // 00005 // XmlRpc++ Copyright (c) 2002-2003 by Chris Morley 00006 // 00007 #if defined(_MSC_VER) 00008 # pragma warning(disable:4786) // identifier was truncated in debug info 00009 #endif 00010 00011 #ifndef MAKEDEPEND 00012 # include <map> 00013 # include <string> 00014 #endif 00015 00016 #include "XmlRpcDispatch.h" 00017 #include "XmlRpcSource.h" 00018 00019 namespace XmlRpc { 00020 00021 00022 // An abstract class supporting XML RPC methods 00023 class XmlRpcServerMethod; 00024 00025 // Class representing connections to specific clients 00026 class XmlRpcServerConnection; 00027 00028 // Class representing argument and result values 00029 class XmlRpcValue; 00030 00031 00033 class XmlRpcServer : public XmlRpcSource { 00034 public: 00036 XmlRpcServer(); 00038 virtual ~XmlRpcServer(); 00039 00041 void enableIntrospection(bool enabled=true); 00042 00044 void addMethod(XmlRpcServerMethod* method); 00045 00047 void removeMethod(XmlRpcServerMethod* method); 00048 00050 void removeMethod(const std::string& methodName); 00051 00053 XmlRpcServerMethod* findMethod(const std::string& name) const; 00054 00057 bool bindAndListen(int port, int backlog = 5); 00058 00060 void work(double msTime); 00061 00063 void exit(); 00064 00066 void shutdown(); 00067 00069 void listMethods(XmlRpcValue& result); 00070 00071 // XmlRpcSource interface implementation 00072 00074 virtual unsigned handleEvent(unsigned eventType); 00075 00077 virtual void removeConnection(XmlRpcServerConnection*); 00078 00079 protected: 00080 00082 virtual void acceptConnection(); 00083 00085 virtual XmlRpcServerConnection* createConnection(int socket); 00086 00087 // Whether the introspection API is supported by this server 00088 bool _introspectionEnabled; 00089 00090 // Event dispatcher 00091 XmlRpcDispatch _disp; 00092 00093 // Collection of methods. This could be a set keyed on method name if we wanted... 00094 typedef std::map< std::string, XmlRpcServerMethod* > MethodMap; 00095 MethodMap _methods; 00096 00097 // system methods 00098 XmlRpcServerMethod* _listMethods; 00099 XmlRpcServerMethod* _methodHelp; 00100 00101 }; 00102 } // namespace XmlRpc 00103 00104 #endif //_XMLRPCSERVER_H_