XmlRpcServer.h
Go to the documentation of this file.
00001 // this file modified by Morgan Quigley on 22 Apr 2008.
00002 // added features: server can be opened on port 0 and you can read back
00003 // what port the OS gave you
00004 
00005 #ifndef _XMLRPCSERVER_H_
00006 #define _XMLRPCSERVER_H_
00007 //
00008 // XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
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   // An abstract class supporting XML RPC methods
00027   class XmlRpcServerMethod;
00028 
00029   // Class representing connections to specific clients
00030   class XmlRpcServerConnection;
00031 
00032   // Class representing argument and result values
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     // XmlRpcSource interface implementation
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     // Whether the introspection API is supported by this server
00096     bool _introspectionEnabled;
00097 
00098     // Event dispatcher
00099     XmlRpcDispatch _disp;
00100 
00101     // Collection of methods. This could be a set keyed on method name if we wanted...
00102     typedef std::map< std::string, XmlRpcServerMethod* > MethodMap;
00103     MethodMap _methods;
00104 
00105     // system methods
00106     XmlRpcServerMethod* _listMethods;
00107     XmlRpcServerMethod* _methodHelp;
00108 
00109     int _port;
00110 
00111   };
00112 } // namespace XmlRpc
00113 
00114 #endif //_XMLRPCSERVER_H_


xmlrpcpp
Author(s): Chris Morley and Konstantin Pilipchuk, slight modifications and ROS wrapping by Morgan Quigley
autogenerated on Sat Dec 28 2013 17:42:59