From 922cb5559b9f2f97279fa24cc9c5862c8b666495 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Tue, 8 Mar 2005 10:23:43 +0000 Subject: This commit was generated by cvs2svn to compensate for changes in r2603, which included commits to RCS files with non-trunk default branches. svn path=/trunk/externals/iem/iemxmlrpc/; revision=2604 --- xmlrpc++/src/XmlRpcDispatch.h | 88 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 xmlrpc++/src/XmlRpcDispatch.h (limited to 'xmlrpc++/src/XmlRpcDispatch.h') diff --git a/xmlrpc++/src/XmlRpcDispatch.h b/xmlrpc++/src/XmlRpcDispatch.h new file mode 100644 index 0000000..b3c4ec0 --- /dev/null +++ b/xmlrpc++/src/XmlRpcDispatch.h @@ -0,0 +1,88 @@ + +#ifndef _XMLRPCDISPATCH_H_ +#define _XMLRPCDISPATCH_H_ +// +// XmlRpc++ Copyright (c) 2002-2003 by Chris Morley +// +#if defined(_MSC_VER) +# pragma warning(disable:4786) // identifier was truncated in debug info +#endif + +#ifndef MAKEDEPEND +# include +#endif + +namespace XmlRpc { + + // An RPC source represents a file descriptor to monitor + class XmlRpcSource; + + //! An object which monitors file descriptors for events and performs + //! callbacks when interesting events happen. + class XmlRpcDispatch { + public: + //! Constructor + XmlRpcDispatch(); + ~XmlRpcDispatch(); + + //! Values indicating the type of events a source is interested in + enum EventType { + ReadableEvent = 1, //!< data available to read + WritableEvent = 2, //!< connected/data can be written without blocking + Exception = 4 //!< uh oh + }; + + //! Monitor this source for the event types specified by the event mask + //! and call its event handler when any of the events occur. + //! @param source The source to monitor + //! @param eventMask Which event types to watch for. \see EventType + void addSource(XmlRpcSource* source, unsigned eventMask); + + //! Stop monitoring this source. + //! @param source The source to stop monitoring + void removeSource(XmlRpcSource* source); + + //! Modify the types of events to watch for on this source + void setSourceEvents(XmlRpcSource* source, unsigned eventMask); + + + //! Watch current set of sources and process events for the specified + //! duration (in ms, -1 implies wait forever, or until exit is called) + void work(double msTime); + + //! Exit from work routine + void exit(); + + //! Clear all sources from the monitored sources list. Sources are closed. + void clear(); + + protected: + + // helper + double getTime(); + + // A source to monitor and what to monitor it for + struct MonitoredSource { + MonitoredSource(XmlRpcSource* src, unsigned mask) : _src(src), _mask(mask) {} + XmlRpcSource* getSource() const { return _src; } + unsigned& getMask() { return _mask; } + XmlRpcSource* _src; + unsigned _mask; + }; + + // A list of sources to monitor + typedef std::list< MonitoredSource > SourceList; + + // Sources being monitored + SourceList _sources; + + // When work should stop (-1 implies wait forever, or until exit is called) + double _endTime; + + bool _doClear; + bool _inWork; + + }; +} // namespace XmlRpc + +#endif // _XMLRPCDISPATCH_H_ -- cgit v1.2.1