NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
Public Member Functions | Static Public Member Functions | List of all members
niftk::InteractionEventObserverMutex Class Reference

Helper class to prevent unwanted simultaneous interactions. More...

Public Member Functions

void Lock (mitk::InteractionEventObserver *guardedObserver)
 Acquires the lock of the mutex. The lock has to be released when this function is called. More...
 
void Unlock (mitk::InteractionEventObserver *guardedObserver)
 Releases the lock of the mutex. The lock has to be owned by guardedObserver when this function is called. More...
 

Static Public Member Functions

static
InteractionEventObserverMutex
GetInstance ()
 Returns the single instance of this class. More...
 

Detailed Description

Helper class to prevent unwanted simultaneous interactions.

This class helps to prevent processing multiple interactions by different state machines at the same time.

This can happen for example if an interactor changes state when a mouse button is pressed and goes back to the start state when the button is released. If another interactor is active at the same time, it can process key events while the mouse button is pressed and the first interactor is doing something.

To prevent simultaneous interactions while someone interacts with the first interactor, this interactor should get a lock of this mutex when the mouse button pressed, and release the lock when the button is released. When the lock of the mutex is acquired, it saves the actual state of the currently registered interactors (whether they are enabled or disabled), and disables them. When the lock is released, it restores the original state of the interactors.

Member Function Documentation

InteractionEventObserverMutex * niftk::InteractionEventObserverMutex::GetInstance ( )
static

Returns the single instance of this class.

void niftk::InteractionEventObserverMutex::Lock ( mitk::InteractionEventObserver *  guardedObserver)

Acquires the lock of the mutex. The lock has to be released when this function is called.

Parameters
guardedObserverThe observer that wants to be active exclusively. The function is supposed to be called by the observer that starts a longer interaction and wants to exclude other observers, so the argument should be 'this'.
void niftk::InteractionEventObserverMutex::Unlock ( mitk::InteractionEventObserver *  guardedObserver)

Releases the lock of the mutex. The lock has to be owned by guardedObserver when this function is called.

Parameters
guardedObserverThe observer that wanted to be active exclusively. The function is supposed to be called by the observer that starts a longer interaction and wants to exclude other observers, so the argument should be 'this'.

The documentation for this class was generated from the following files: