2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
6 #ifndef __WVQTSTREAMCLONE_H
7 #define __WVQTSTREAMCLONE_H
11 #include <qsocketnotifier.h>
13 #include <qmetaobject.h>
14 #include "wvstreamclone.h"
17 * Wraps another WvStream and attaches it to the normal Qt event loop.
19 * If you are using this object exclusively to manage all of your
20 * streams, then you do not need to have a normal WvStreams
21 * select()/callback() loop in your application at all.
23 * However, should you leave the Qt event loop and wish to continue
24 * using this WvStream, call qt_detach() first, then run a normal
25 * WvStreams event loop. If you do not do this, events may be
26 * lost! Later, you may resume the Qt event loop at any time
27 * by leaving your WvStreams event loop and calling qt_attach().
29 * Multiple instances of this object may coexist to wrap different
30 * WvStream's or WvStreamList's.
33 class WvQtStreamClone
: public QObject
, public WvStreamClone
39 bool pending_callback
;
41 bool select_in_progress
;
43 QIntDict
<QSocketNotifier
> notify_readable
;
44 QIntDict
<QSocketNotifier
> notify_writable
;
45 QIntDict
<QSocketNotifier
> notify_exception
;
50 * WvQtStreamClone takes ownership of the stream you give it
51 * just like WvStreamClone. See comments there.
53 * Timeout sets the time between polls with select().
54 * A value less than zero is regarded as an infinite timeout.
56 WvQtStreamClone(IWvStream
*_cloned
= NULL
, int msec_timeout
= -1);
57 virtual ~WvQtStreamClone();
59 // Call this to stop managing this stream via the Qt event loop.
60 // Afterwards you may run a normal WvStream event loop based
64 // Call this to resume managing this stream via the Qt event loop.
65 // This is the default state when the object is constructed.
68 // Changes the timeout
69 // You may need to adjust the timeout when using badly behaved streams
70 void set_timeout(int msec_timeout
);
73 // Called before the Qt event loop does its select()
75 // Called after the Qt event loop has finished its notifications
79 /** These things mark the beginning of a select pass **/
80 // Qt event loop hook (happens before each iteration)
81 void qt_begin_event_loop_hook();
83 /** These things mark the end of a select pass **/
84 // Qt select timeout expired
85 void select_timer_expired();
86 // Called when a file descriptor has been marked readable
87 void fd_readable(int fd
);
88 // Called when a file descriptor has been marked writable
89 void fd_writable(int fd
);
90 // Called when a file descriptor has been marked with an exception
91 void fd_exception(int fd
);
93 // Needed or certain assertions fail ;)
94 virtual void execute();
97 virtual void setclone(IWvStream
*clone
);
100 #endif // __WVQTSTREAMCLONE_H