Salome HOME
Process multi-selection in pop-up menu
[modules/shaper.git] / src / PyInterp / PyInterp_Dispatcher.h
1
2 #ifndef PYINTERP_DISPATCHER_H
3 #define PYINTERP_DISPATCHER_H
4
5 #include "PyInterp.h"   // !!! WARNING !!! THIS INCLUDE MUST BE THE VERY FIRST !!!
6
7 #include "PyInterp_Request.h"   // full include instead of forward declaration
8                                 // everyone inc'ing the Dispatcher will get the requests for free.
9
10 #include <QMutex>
11 #include <QThread>
12 #include <QQueue>
13
14 class QObject;
15 class PyInterp_Watcher;
16
17 class PYINTERP_EXPORT PyInterp_Dispatcher : protected QThread
18 {
19   PyInterp_Dispatcher(); // private constructor
20
21 public:
22   static PyInterp_Dispatcher* Get();
23
24   virtual                     ~PyInterp_Dispatcher();
25
26   bool                        IsBusy() const;  
27   void                        Exec( PyInterp_Request* );
28
29 private:
30   virtual void                run();
31   void                        processRequest( PyInterp_Request* );
32   void                        objectDestroyed( const QObject* );
33
34 private:
35   typedef PyInterp_Request*   RequestPtr;
36
37   QQueue<RequestPtr>          myQueue;
38   QMutex                      myQueueMutex;
39   PyInterp_Watcher*           myWatcher;
40
41   static PyInterp_Dispatcher* myInstance;
42
43   friend class PyInterp_Watcher;
44 };
45
46 #endif // PYINTERP_DISPATCHER_H