2
#ifndef _XMLRPCDISPATCH_H_
3
#define _XMLRPCDISPATCH_H_
5
// XmlRpc++ Copyright (c) 2002-2008 by Chris Morley
8
# pragma warning(disable:4786) // identifier was truncated in debug info
15
// An RPC source represents a file descriptor to monitor
18
//! An object which monitors file descriptors for events and performs
19
//! callbacks when interesting events happen.
20
class XmlRpcDispatch {
26
//! Values indicating the type of events a source is interested in
28
ReadableEvent = 1, //!< data available to read
29
WritableEvent = 2, //!< connected/data can be written without blocking
30
Exception = 4 //!< uh oh
33
//! Monitor this source for the event types specified by the event mask
34
//! and call its event handler when any of the events occur.
35
//! @param source The source to monitor
36
//! @param eventMask Which event types to watch for. \see EventType
37
void addSource(XmlRpcSource* source, unsigned eventMask);
39
//! Stop monitoring this source.
40
//! @param source The source to stop monitoring
41
//! The source socket is not closed.
42
void removeSource(XmlRpcSource* source);
44
//! Modify the types of events to watch for on this source
45
void setSourceEvents(XmlRpcSource* source, unsigned eventMask);
48
//! Watch current set of sources and process events for the specified
49
//! duration (in seconds, -1 implies wait forever, or until exit is called)
50
void work(double timeSeconds);
52
//! Exit from work routine
55
//! Clear all sources from the monitored sources list. Sources are closed.
60
//! Wait for I/O on any source, timeout, or interrupt signal.
61
bool waitForAndProcessEvents(double timeoutSeconds);
64
//! Returns current time in seconds since something
67
// A source to monitor and what to monitor it for
68
struct MonitoredSource
70
MonitoredSource(XmlRpcSource* src, unsigned mask) : _src(src), _mask(mask) {}
71
XmlRpcSource* getSource() const { return _src; }
72
unsigned& getMask() { return _mask; }
77
// A list of sources to monitor
78
typedef std::vector< MonitoredSource > SourceList;
80
// Sources being monitored
83
// When work should stop (-1 implies wait forever, or until exit is called)
92
#endif // _XMLRPCDISPATCH_H_