WvStreams
|
00001 /* -*- Mode: C++ -*- 00002 * Worldvisions Weaver Software: 00003 * Copyright (C) 1997-2002 Net Integration Technologies, Inc. 00004 * 00005 * A Qt object that invokes its callback whenever it receives 00006 * an event. This is useful for deferring processing to the 00007 * Qt event loop. Use it to avoid problems resulting from the 00008 * non-reentrant nature of WvStream::execute(). 00009 */ 00010 #ifndef __WVQTHOOK_H 00011 #define __WVQTHOOK_H 00012 00013 #include <qobject.h> 00014 #include <qevent.h> 00015 #include "wvtr1.h" 00016 00017 class WvQtHook; 00018 // parameters are: WvQtHook &, int type, void *data 00019 typedef wv::function<void(WvQtHook&, int, void*)> WvQtHookCallback; 00020 00021 class WvQtHook : public QObject 00022 { 00023 Q_OBJECT 00024 WvQtHookCallback callback; 00025 00026 public: 00027 WvQtHook(WvQtHookCallback _callback = NULL); 00028 00029 // sets the callback function to be invoked 00030 void setcallback(WvQtHookCallback _callback); 00031 00032 // posts an event to the Qt event loop to be sent to the 00033 // attached callback later 00034 void post(int type = 0, void *data = NULL); 00035 00036 // sends an event to the attached callback now 00037 void send(int type = 0, void *data = NULL); 00038 00039 // internal 00040 virtual bool event(QEvent *event); 00041 }; 00042 00043 #endif // __WVQTHOOK_H