]> SALOME platform Git repositories - modules/shaper.git/blob - src/PyInterp/PyInterp_Dispatcher.h
Salome HOME
Connect feature with group, document and index in the group
[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 //PYINTERP_EXPORT
18 class PyInterp_Dispatcher : protected QThread
19 {
20   PyInterp_Dispatcher(); // private constructor
21
22 public:
23   static PyInterp_Dispatcher* Get();
24
25   virtual                     ~PyInterp_Dispatcher();
26
27   bool                        IsBusy() const;  
28   void                        Exec( PyInterp_Request* );
29
30 private:
31   virtual void                run();
32   void                        processRequest( PyInterp_Request* );
33   void                        objectDestroyed( const QObject* );
34
35 private:
36   typedef PyInterp_Request*   RequestPtr;
37
38   QQueue<RequestPtr>          myQueue;
39   QMutex                      myQueueMutex;
40   PyInterp_Watcher*           myWatcher;
41
42   static PyInterp_Dispatcher* myInstance;
43
44   friend class PyInterp_Watcher;
45 };
46
47 #endif // PYINTERP_DISPATCHER_H