TQtEvent.cxx

Go to the documentation of this file.
00001 // @(#)root/qt:$Id: TQtEvent.cxx 28205 2009-04-14 19:38:00Z brun $
00002 // Author: Valeri Fine   21/01/2002
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
00006  * Copyright (C) 2002 by Valeri Fine.                                    *
00007  * All rights reserved.                                                  *
00008  *                                                                       *
00009  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00010  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00011  *************************************************************************/
00012 
00013 #include <QObject>
00014 #include "TQtEvent.h"
00015 #include "TWaitCondition.h"
00016 #include <assert.h>
00017 
00018 //////////////////////////////////////////////////////////////////////////////
00019 //
00020 //  class TQtEvent to send an event between two Qt threads
00021 //
00022 //////////////////////////////////////////////////////////////////////////////
00023 
00024 //______________________________________________________________________________
00025 TQtEvent::TQtEvent(int code):QEvent(QEvent::Type(QEvent::User+code)), fCondition(0), fResult(0)
00026          , fReceiver(0),fThatEvent(0)
00027 { }
00028 //______________________________________________________________________________
00029 TQtEvent::TQtEvent(QObject *o, QEvent *e): QEvent(QEvent::User), fCondition(0)
00030          , fResult(0), fReceiver(o),fThatEvent(e)
00031 { }
00032 //______________________________________________________________________________
00033 bool TQtEvent::Notify()
00034 {
00035   bool r = FALSE;
00036   if (fReceiver)
00037   {
00038     r = fReceiver->event(fThatEvent);
00039     SetResult();
00040   }
00041   return r;
00042 }
00043 //______________________________________________________________________________
00044 void TQtEvent::SetResult(unsigned long e)
00045 {
00046   if (fResult)   *fResult = e;
00047   if (fCondition) fCondition->wakeOne();
00048 }
00049 //______________________________________________________________________________
00050 void TQtEvent::SetWait(TWaitCondition &condition)
00051 {
00052   fCondition = &condition;
00053 }
00054 //______________________________________________________________________________
00055 void TQtEvent::SetWait(TWaitCondition &condition,unsigned long &result)
00056 {
00057   SetWait(condition);
00058   fResult    = &result;
00059 }

Generated on Tue Jul 5 14:14:36 2011 for ROOT_528-00b_version by  doxygen 1.5.1