1 2 #ifndef _XMLRPCSOURCE_H_ 3 #define _XMLRPCSOURCE_H_ 4 // 5 // XmlRpc++ Copyright (c) 2002-2003 by Chris Morley 6 // 7 #if defined(_MSC_VER) 8 # pragma warning(disable:4786) // identifier was truncated in debug info 9 #endif 10 11 namespace XmlRpc { 12 13 //! An RPC source represents a file descriptor to monitor 14 class XmlRpcSource { 15 public: 16 //! Constructor 17 //! @param fd The socket file descriptor to monitor. 18 //! @param deleteOnClose If true, the object deletes itself when close is called. 19 XmlRpcSource(int fd = -1, bool deleteOnClose = false); 20 21 //! Destructor 22 virtual ~XmlRpcSource(); 23 24 //! Return the file descriptor being monitored. 25 int getfd() const { return _fd; } 26 //! Specify the file descriptor to monitor. 27 void setfd(int fd) { _fd = fd; } 28 29 //! Return whether the file descriptor should be kept open if it is no longer monitored. 30 bool getKeepOpen() const { return _keepOpen; } 31 //! Specify whether the file descriptor should be kept open if it is no longer monitored. 32 void setKeepOpen(bool b=true) { _keepOpen = b; } 33 34 //! Close the owned fd. If deleteOnClose was specified at construction, the object is deleted. 35 virtual void close(); 36 37 //! Return true to continue monitoring this source 38 virtual unsigned handleEvent(unsigned eventType) = 0; 39 40 private: 41 42 // Socket. This should really be a SOCKET (an alias for unsigned int*) on windows... 43 int _fd; 44 45 // In the server, a new source (XmlRpcServerConnection) is created 46 // for each connected client. When each connection is closed, the 47 // corresponding source object is deleted. 48 bool _deleteOnClose; 49 50 // In the client, keep connections open if you intend to make multiple calls. 51 bool _keepOpen; 52 }; 53 } // namespace XmlRpc 54 55 #endif //_XMLRPCSOURCE_H_ 56