WvStreams
wvqthook.h
1 /* -*- Mode: C++ -*-
2  * Worldvisions Weaver Software:
3  * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4  *
5  * A Qt object that invokes its callback whenever it receives
6  * an event. This is useful for deferring processing to the
7  * Qt event loop. Use it to avoid problems resulting from the
8  * non-reentrant nature of WvStream::execute().
9  */
10 #ifndef __WVQTHOOK_H
11 #define __WVQTHOOK_H
12 
13 #include <qobject.h>
14 #include <qevent.h>
15 #include "wvtr1.h"
16 
17 class WvQtHook;
18 // parameters are: WvQtHook &, int type, void *data
19 typedef wv::function<void(WvQtHook&, int, void*)> WvQtHookCallback;
20 
21 class WvQtHook : public QObject
22 {
23  Q_OBJECT
24  WvQtHookCallback callback;
25 
26 public:
27  WvQtHook(WvQtHookCallback _callback = NULL);
28 
29  // sets the callback function to be invoked
30  void setcallback(WvQtHookCallback _callback);
31 
32  // posts an event to the Qt event loop to be sent to the
33  // attached callback later
34  void post(int type = 0, void *data = NULL);
35 
36  // sends an event to the attached callback now
37  void send(int type = 0, void *data = NULL);
38 
39  // internal
40  virtual bool event(QEvent *event);
41 };
42 
43 #endif // __WVQTHOOK_H
WvQtHook
Definition: wvqthook.h:21