2 #ifndef PyEvent_PYEVENT_H
3 #define PyEvent_PYEVENT_H
9 //! SALOME custom event type
10 #define PyEvent_EVENT QEvent::Type( QEvent::User + 10000 )
13 class PyEvent_CustomEvent : public QEvent
16 PyEvent_CustomEvent( int type );
17 PyEvent_CustomEvent( QEvent::Type type, void* data );
20 void setData( void* data );
23 void *d; //!< internal data
33 virtual ~PyEvent_Event();
35 void ExecutePostedEvent();
36 virtual void Execute() = 0;
38 static bool IsSessionThread();
43 static void GetSessionThread();
46 QSemaphore* mySemaphore; //!< internal semaphore
49 template<class TObject, typename TRes> class TMemFunEvent : public PyEvent_Event
54 typedef TResult (TObject::* TAction)();
55 TMemFunEvent(TObject* theObject, TAction theAction,
56 TResult theResult = TResult()):
61 virtual void Execute()
63 myResult = (myObject->*myAction)();
70 template<class TObject> class TVoidMemFunEvent : public PyEvent_Event
73 typedef void (TObject::* TAction)();
74 TVoidMemFunEvent(TObject* theObject, TAction theAction):
78 virtual void Execute()
80 (myObject->*myAction)();
87 template<class TObject, typename TRes, typename TArg, typename TStoreArg = TArg>
88 class TMemFun1ArgEvent : public PyEvent_Event
93 typedef TResult (TObject::* TAction)(TArg);
94 TMemFun1ArgEvent(TObject* theObject, TAction theAction, TArg theArg,
95 TResult theResult = TResult()):
101 virtual void Execute()
103 myResult = (myObject->*myAction)(myArg);
111 template<class TObject, typename TArg, typename TStoreArg = TArg>
112 class TVoidMemFun1ArgEvent : public PyEvent_Event
115 typedef void (TObject::* TAction)(TArg);
116 TVoidMemFun1ArgEvent(TObject* theObject, TAction theAction, TArg theArg):
121 virtual void Execute()
123 (myObject->*myAction)(myArg);
131 template<class TObject, typename TRes, typename TArg, typename TArg1, typename TStoreArg = TArg, typename TStoreArg1 = TArg1>
132 class TMemFun2ArgEvent: public PyEvent_Event
135 typedef TRes TResult;
137 typedef TResult (TObject::* TAction)(TArg,TArg1);
138 TMemFun2ArgEvent(TObject* theObject, TAction theAction,
139 TArg theArg, TArg1 theArg1,
140 TResult theResult = TResult()):
147 virtual void Execute()
149 myResult = (myObject->*myAction)(myArg,myArg1);
158 template<class TObject, typename TArg, typename TArg1, typename TStoreArg = TArg, typename TStoreArg1 = TArg1>
159 class TVoidMemFun2ArgEvent : public PyEvent_Event
162 typedef void (TObject::* TAction)(TArg,TArg1);
163 TVoidMemFun2ArgEvent(TObject* theObject, TAction theAction, TArg theArg, TArg1 theArg1):
169 virtual void Execute()
171 (myObject->*myAction)(myArg,myArg1);
180 template<class TEvent> inline typename TEvent::TResult ProcessEvent(TEvent* theEvent)
182 typename TEvent::TResult aResult;
183 if(PyEvent_Event::IsSessionThread()) {
185 aResult = theEvent->myResult;
189 aResult = theEvent->myResult;
195 inline void ProcessVoidEvent(PyEvent_Event* theEvent)
197 if(PyEvent_Event::IsSessionThread()) {
206 #endif // PyEvent_PYEVENT_H