The class which encapsulates data and functionality required for posting component-specific events to perform arbitrary operations in the main GUI thread. More...
#include <SALOME_Event.h>
Inherited by CloseEvent, InitEvent, TActionEvent, TActionIdEvent, TActivateModuleEvent, TActivateView, TActivateViewManagerAndView, TAddGlobalPrefEvent, TAddPrefEvent, TAddPrefParamEvent, TCloneView, TCloseView, TCreateActionEvent, TCreateActionGroupEvent, TCreateEmptyObjectEvent, TCreateMenuEvent, TCreateObjectEvent, TCreateSepEvent, TCreateToolEvent, TCreateView, TCreateViewWg, TDefMenuGroupEvent, TDeleteCurve, TDisplayCurve, TDumpViewEvent, TEnableSelectorEvent, TEraseCurve, TFindViews, TFitRangeByCurves, TFitRangeCurrent, TGetActiveComponentEvent, TGetActivePyModuleEvent, TGetActiveStudyNameEvent, TGetActiveView, TGetBoolSettingEvent, TGetByteArraySettingEvent, TGetChildrenEvent, TGetColorEvent, TGetColorSettingEvent, TGetComponentNameEvent, TGetComponentsEvent, TGetConstantEvent, TGetDblSettingEvent, TGetDesktopEvent, TGetExistingDirectoryEvent, TGetFileNameEvent, TGetFontSettingEvent, TGetIntSettingEvent, TGetMainFrameEvent, TGetMainMenuBarEvent, TGetNameEvent, TGetObjectBrowserEvent, TGetObjectPositionEvent, TGetOpenFileNamesEvent, TGetPlot2dTitle, TGetPopupMenuEvent, TGetRefEvent, TGetRenderWindowEvent, TGetRenderWindowInteractorEvent, TGetRendererEvent, TGetSelectedEvent, TGetSelectionEvent, TGetSettingEvent, TGetStrSettingEvent, TGetToolTipEvent, TGetViewParameters, TGetViewTitle, TGetViewType, TGetViewWidget, TGetViews, TGetVisibilityStateEvent, TGroupAllViews, THasDesktopEvent, THasSettingEvent, THideNotifyEvent, TInfoAddActionEvent, TInfoAddGroupEvent, TInfoAddLabel2paramEvent, TInfoAddLabel3paramEvent, TIsInViewerEvent, TIsModifiedEvent, TIsViewClosable, TIsViewVisible, TLoadIconEvent, TMemFun1ArgEvent< TObject, TRes, TArg, TStoreArg >, TMemFun2ArgEvent< TObject, TRes, TArg, TArg1, TStoreArg, TStoreArg1 >, TMemFunEvent< TObject, TRes >, TMoveView, TNeighbourViews, TParametersEvent, TPlot2dFitRange, TPrefPropEvent, TPutInfoEvent, TRemoveChildEvent, TRemoveObjectEvent, TSetColorEvent, TSetIconEvent, TSetNameEvent, TSetPlot2dTitle, TSetRefEvent, TSetSelectionEvent, TSetToolTipEvent, TSetViewRotationPoint, TSetViewSize, TSetViewTitle, TShowNotifyEvent, TSplitView, TVoidMemFun1ArgEvent< TObject, TArg, TStoreArg >, TVoidMemFun2ArgEvent< TObject, TArg, TArg1, TStoreArg, TStoreArg1 >, TVoidMemFunEvent< TObject >, and TdisableSelectorEvent.
Public Member Functions | |
| SALOME_Event () | |
| Constructor. More... | |
| virtual | ~SALOME_Event () |
| Destructor. More... | |
| void | ExecutePostedEvent () |
| This method should be called by the main GUI thread in order to execute the code specific for this event and finally to inform the calling thread that the event has been processed waking it up with help of the semaphore . More... | |
| virtual void | Execute ()=0 |
| This method should be redefined in the successor classes to do real work. More... | |
| void | process () |
| Post the event and wait for its completion. process() should be called from a secondary thread only. More... | |
Static Public Member Functions | |
| static bool | IsSessionThread () |
| Check if the processing is in the main application thread. More... | |
Protected Member Functions | |
| void | processed () |
| Use this method to signal that this event has been processed. More... | |
Static Protected Member Functions | |
| static void | GetSessionThread () |
| Initialize event mechanism. More... | |
Private Attributes | |
| QSemaphore * | mySemaphore |
| internal semaphore More... | |
The class which encapsulates data and functionality required for posting component-specific events to perform arbitrary operations in the main GUI thread.
SALOME_Event objects can be posted by any thread belonging to the GUI process.
It is necessary to derive a custom event class from SALOME_Event and re-implement virtual Execute() method. This method should actually perform the desirable operation. To pass all the required data to Execute() and store a return value, arbitrary data fields can be added to the custom event class. There is no need to protect such fields with a mutex, for only one thread working with a SALOME_Event object is active at any moment.
Usage:
true to automatically wake up desktop after process().The method processed() is used by the desktop to signal that event processing has been completed.
To make all this work, it is necessary to call static method GetSessionThread() during the application initialization, i.e. from main() function. It is important to call this method from the primary application thread.
Caveats:
| SALOME_Event::SALOME_Event | ( | ) |
Constructor.
References mySemaphore, and NumberOfResources.
|
virtual |
Destructor.
References mySemaphore, and NumberOfResources.
|
pure virtual |
This method should be redefined in the successor classes to do real work.
Implemented in CloseEvent, TGetViewParameters, TIsInViewerEvent, TGetSelectedEvent, TGetComponentNameEvent, TGetActiveStudyNameEvent, THasDesktopEvent, TGetObjectPositionEvent, TGetVisibilityStateEvent, TPlot2dFitRange, TFitRangeCurrent, TFitRangeByCurves, TSetPlot2dTitle, TGetPlot2dTitle, TDeleteCurve, TEraseCurve, TDisplayCurve, TGetChildrenEvent, TRemoveObjectEvent, TRemoveChildEvent, TGetColorEvent, TGetRefEvent, TGetToolTipEvent, TGetNameEvent, TSetColorEvent, TSetRefEvent, TSetToolTipEvent, TSetIconEvent, TSetNameEvent, TCreateObjectEvent, TCreateEmptyObjectEvent, TNeighbourViews, TMoveView, TSplitView, TGroupAllViews, TIsViewClosable, TIsViewVisible, TCloneView, TCloseView, TCreateViewWg, TCreateView, TGetViewWidget, TActivateViewManagerAndView, TActivateView, TFindViews, TGetViewTitle, TSetViewRotationPoint, TSetViewSize, TSetViewTitle, TGetViewType, TGetActiveView, TGetViews, TDumpViewEvent, TInfoAddGroupEvent, TInfoAddActionEvent, TInfoAddLabel3paramEvent, TInfoAddLabel2paramEvent, TPrefPropEvent, TAddPrefParamEvent, TAddPrefEvent, TAddGlobalPrefEvent, TActionIdEvent, TActionEvent, TCreateActionGroupEvent, TCreateActionEvent, TCreateSepEvent, TCreateMenuEvent, TCreateToolEvent, TDefMenuGroupEvent, TLoadIconEvent, TGetExistingDirectoryEvent, TGetOpenFileNamesEvent, TGetFileNameEvent, TParametersEvent, THasSettingEvent, TGetFontSettingEvent, TGetByteArraySettingEvent, TGetColorSettingEvent, TGetStrSettingEvent, TGetBoolSettingEvent, TGetDblSettingEvent, TGetIntSettingEvent, TGetConstantEvent, TGetSettingEvent, TIsModifiedEvent, TActivateModuleEvent, TGetActivePyModuleEvent, TGetActiveComponentEvent, TGetComponentsEvent, THideNotifyEvent, TShowNotifyEvent, TPutInfoEvent, TdisableSelectorEvent, TEnableSelectorEvent, TSetSelectionEvent, TGetSelectionEvent, TGetObjectBrowserEvent, TGetPopupMenuEvent, TGetMainMenuBarEvent, TGetMainFrameEvent, TGetDesktopEvent, TGetRenderWindowInteractorEvent, TGetRenderWindowEvent, TGetRendererEvent, TVoidMemFun2ArgEvent< TObject, TArg, TArg1, TStoreArg, TStoreArg1 >, TMemFun2ArgEvent< TObject, TRes, TArg, TArg1, TStoreArg, TStoreArg1 >, TVoidMemFun1ArgEvent< TObject, TArg, TStoreArg >, TMemFun1ArgEvent< TObject, TRes, TArg, TStoreArg >, TVoidMemFunEvent< TObject >, TMemFunEvent< TObject, TRes >, and InitEvent.
| void SALOME_Event::ExecutePostedEvent | ( | ) |
This method should be called by the main GUI thread in order to execute the code specific for this event and finally to inform the calling thread that the event has been processed waking it up with help of the semaphore .
References Execute(), IsSessionThread(), and processed().
|
staticprotected |
|
static |
Check if the processing is in the main application thread.
true if this method is called from the main application thread References myThread.
| void SALOME_Event::process | ( | ) |
Post the event and wait for its completion. process() should be called from a secondary thread only.
References IsSessionThread(), mySemaphore, and SALOME_EVENT.
|
protected |
Use this method to signal that this event has been processed.
References mySemaphore.
|
private |
internal semaphore