Base class for algorithms that can run in a background thread.
More...
#include <mitkNonBlockingAlgorithm.h>
|
| | mitkClassMacroItkParent (NonBlockingAlgorithm, itk::Object) |
| |
| void | SetDataStorage (DataStorage &storage) |
| | Set the DataStorage for this algorithm. More...
|
| |
| DataStorage * | GetDataStorage () |
| | Get the DataStorage associated with this algorithm. More...
|
| |
| template<typename T > |
| void | SetParameter (const char *parameter, const T &value) |
| | Set a parameter of any normal (value) type. More...
|
| |
| template<typename T > |
| void | SetPointerParameter (const char *parameter, const itk::SmartPointer< T > &value) |
| | Set a parameter that holds a smart pointer. More...
|
| |
| void | SetPointerParameter (const char *parameter, BaseData *value) |
| | Set a parameter that holds a BaseData pointer (Image, Surface, etc.). More...
|
| |
| template<typename TPixel , unsigned int VImageDimension> |
| void | SetItkImageAsMITKImagePointerParameter (const char *parameter, itk::Image< TPixel, VImageDimension > *itkImage) |
| | Set an ITK image as a MITK Image parameter (raw pointer version). More...
|
| |
| template<typename TPixel , unsigned int VImageDimension> |
| void | SetItkImageAsMITKImagePointerParameter (const char *parameter, const itk::SmartPointer< itk::Image< TPixel, VImageDimension >> &itkImage) |
| | Set an ITK image as a MITK Image parameter (smart pointer version). More...
|
| |
| template<typename T > |
| void | GetParameter (const char *parameter, T &value) const |
| | Get a parameter of any normal (value) type. More...
|
| |
| template<typename T > |
| void | GetPointerParameter (const char *parameter, itk::SmartPointer< T > &value) const |
| | Get a parameter that holds a smart pointer. More...
|
| |
| virtual void | Reset () |
| | Reset the algorithm to its initial state. More...
|
| |
| void | StartAlgorithm () |
| | Start the algorithm asynchronously in a background thread. More...
|
| |
| void | StartBlockingAlgorithm () |
| | Start the algorithm and block until it completes. More...
|
| |
| void | StopAlgorithm () |
| | Wait for the running algorithm thread to finish. More...
|
| |
| void | TriggerParameterModified (const itk::EventObject &event) |
| | Callback invoked when a trigger parameter is modified. More...
|
| |
| void | ThreadedUpdateSuccessful (const itk::EventObject &event) |
| | GUI-thread callback when the threaded update succeeds. More...
|
| |
| void | ThreadedUpdateFailed (const itk::EventObject &event) |
| | GUI-thread callback when the threaded update fails. More...
|
| |
Base class for algorithms that can run in a background thread.
NonBlockingAlgorithm provides a framework for running computations asynchronously. Subclasses implement ThreadedUpdateFunction() with their algorithm logic. The algorithm can be started via StartAlgorithm() (non-blocking) or StartBlockingAlgorithm() (blocking). Upon completion, a ResultAvailable or ProcessingError event is emitted via the GUI thread.
Parameters are stored in a PropertyList and can be set via SetParameter(), SetPointerParameter(), or SetItkImageAsMITKImagePointerParameter(). Trigger parameters can be defined so that modifying them automatically restarts the algorithm.
- Note
- Use the mitkAlgorithmNewMacro() macro for subclass instantiation, as Initialize() cannot be called from the base constructor (virtual dispatch).
- See also
- NonBlockingAlgorithmEvent
-
ResultAvailable
-
ProcessingError
-
SegmentationSink
Definition at line 86 of file mitkNonBlockingAlgorithm.h.
◆ NonBlockingAlgorithm()
| mitk::NonBlockingAlgorithm::NonBlockingAlgorithm |
( |
| ) |
|
|
protected |
◆ ~NonBlockingAlgorithm()
| mitk::NonBlockingAlgorithm::~NonBlockingAlgorithm |
( |
| ) |
|
|
overrideprotected |
◆ DefineTriggerParameter()
| void mitk::NonBlockingAlgorithm::DefineTriggerParameter |
( |
const char * |
| ) |
|
|
protected |
◆ GetDataStorage()
| DataStorage* mitk::NonBlockingAlgorithm::GetDataStorage |
( |
| ) |
|
◆ GetParameter()
template<typename T >
| void mitk::NonBlockingAlgorithm::GetParameter |
( |
const char * |
parameter, |
|
|
T & |
value |
|
) |
| const |
|
inline |
Get a parameter of any normal (value) type.
- Template Parameters
-
| T | The parameter value type. |
- Parameters
-
| [in] | parameter | The parameter name. |
| [out] | value | The retrieved parameter value. |
- Exceptions
-
| std::invalid_argument | if the parameter does not exist. |
Definition at line 201 of file mitkNonBlockingAlgorithm.h.
References mitk::GenericProperty< T >::GetValue().
◆ GetPointerParameter()
template<typename T >
| void mitk::NonBlockingAlgorithm::GetPointerParameter |
( |
const char * |
parameter, |
|
|
itk::SmartPointer< T > & |
value |
|
) |
| const |
|
inline |
Get a parameter that holds a smart pointer.
- Template Parameters
-
| T | The type pointed to by the smart pointer. |
- Parameters
-
| [in] | parameter | The parameter name. |
| [out] | value | The retrieved smart pointer value. |
- Exceptions
-
| std::invalid_argument | if the parameter does not exist. |
Definition at line 229 of file mitkNonBlockingAlgorithm.h.
References mitk::SmartPointerProperty::GetSmartPointer().
◆ Initialize()
◆ mitkClassMacroItkParent()
◆ ReadyToRun()
| virtual bool mitk::NonBlockingAlgorithm::ReadyToRun |
( |
| ) |
|
|
protectedvirtual |
◆ Reset()
| virtual void mitk::NonBlockingAlgorithm::Reset |
( |
| ) |
|
|
virtual |
Reset the algorithm to its initial state.
Calls Initialize() to re-create default parameters.
◆ SetDataStorage()
| void mitk::NonBlockingAlgorithm::SetDataStorage |
( |
DataStorage & |
storage | ) |
|
◆ SetItkImageAsMITKImagePointerParameter() [1/2]
template<typename TPixel , unsigned int VImageDimension>
| void mitk::NonBlockingAlgorithm::SetItkImageAsMITKImagePointerParameter |
( |
const char * |
parameter, |
|
|
const itk::SmartPointer< itk::Image< TPixel, VImageDimension >> & |
itkImage |
|
) |
| |
|
inline |
Set an ITK image as a MITK Image parameter (smart pointer version).
The ITK image is imported into a mitk::Image and stored as a pointer parameter.
- Template Parameters
-
| TPixel | The pixel type of the ITK image. |
| VImageDimension | The dimensionality of the ITK image. |
- Parameters
-
| [in] | parameter | The parameter name. |
| [in] | itkImage | Smart pointer to the ITK image to store. |
Definition at line 182 of file mitkNonBlockingAlgorithm.h.
References mitk::ImportItkImage(), and mitk::Image::New().
◆ SetItkImageAsMITKImagePointerParameter() [2/2]
template<typename TPixel , unsigned int VImageDimension>
| void mitk::NonBlockingAlgorithm::SetItkImageAsMITKImagePointerParameter |
( |
const char * |
parameter, |
|
|
itk::Image< TPixel, VImageDimension > * |
itkImage |
|
) |
| |
|
inline |
Set an ITK image as a MITK Image parameter (raw pointer version).
The ITK image is imported into a mitk::Image and stored as a pointer parameter.
- Template Parameters
-
| TPixel | The pixel type of the ITK image. |
| VImageDimension | The dimensionality of the ITK image. |
- Parameters
-
| [in] | parameter | The parameter name. |
| [in] | itkImage | The ITK image to store. |
Definition at line 161 of file mitkNonBlockingAlgorithm.h.
References mitk::ImportItkImage(), and mitk::Image::New().
◆ SetParameter()
template<typename T >
| void mitk::NonBlockingAlgorithm::SetParameter |
( |
const char * |
parameter, |
|
|
const T & |
value |
|
) |
| |
|
inline |
Set a parameter of any normal (value) type.
- Template Parameters
-
| T | The parameter value type. |
- Parameters
-
| [in] | parameter | The parameter name. |
| [in] | value | The parameter value. |
Definition at line 112 of file mitkNonBlockingAlgorithm.h.
◆ SetPointerParameter() [1/2]
| void mitk::NonBlockingAlgorithm::SetPointerParameter |
( |
const char * |
parameter, |
|
|
BaseData * |
value |
|
) |
| |
◆ SetPointerParameter() [2/2]
template<typename T >
| void mitk::NonBlockingAlgorithm::SetPointerParameter |
( |
const char * |
parameter, |
|
|
const itk::SmartPointer< T > & |
value |
|
) |
| |
|
inline |
◆ StartAlgorithm()
| void mitk::NonBlockingAlgorithm::StartAlgorithm |
( |
| ) |
|
Start the algorithm asynchronously in a background thread.
The algorithm will only start if ReadyToRun() returns true and no kill request is pending. If the thread is already running, additional update requests are queued.
◆ StartBlockingAlgorithm()
| void mitk::NonBlockingAlgorithm::StartBlockingAlgorithm |
( |
| ) |
|
◆ StopAlgorithm()
| void mitk::NonBlockingAlgorithm::StopAlgorithm |
( |
| ) |
|
Wait for the running algorithm thread to finish.
◆ ThreadedUpdateFailed() [1/2]
| virtual void mitk::NonBlockingAlgorithm::ThreadedUpdateFailed |
( |
| ) |
|
|
protectedvirtual |
◆ ThreadedUpdateFailed() [2/2]
| void mitk::NonBlockingAlgorithm::ThreadedUpdateFailed |
( |
const itk::EventObject & |
event | ) |
|
GUI-thread callback when the threaded update fails.
- Parameters
-
| [in] | event | The event object (unused). |
◆ ThreadedUpdateFunction()
| virtual bool mitk::NonBlockingAlgorithm::ThreadedUpdateFunction |
( |
| ) |
|
|
protectedvirtual |
◆ ThreadedUpdateSuccessful() [1/2]
| virtual void mitk::NonBlockingAlgorithm::ThreadedUpdateSuccessful |
( |
| ) |
|
|
protectedvirtual |
◆ ThreadedUpdateSuccessful() [2/2]
| void mitk::NonBlockingAlgorithm::ThreadedUpdateSuccessful |
( |
const itk::EventObject & |
event | ) |
|
GUI-thread callback when the threaded update succeeds.
- Parameters
-
| [in] | event | The event object (unused). |
◆ TriggerParameterModified()
| void mitk::NonBlockingAlgorithm::TriggerParameterModified |
( |
const itk::EventObject & |
event | ) |
|
Callback invoked when a trigger parameter is modified.
Automatically restarts the algorithm.
- Parameters
-
| [in] | event | The modification event (unused). |
◆ UnDefineTriggerParameter()
| void mitk::NonBlockingAlgorithm::UnDefineTriggerParameter |
( |
const char * |
| ) |
|
|
protected |
◆ m_DataStorage
◆ m_Parameters
| PropertyList::Pointer mitk::NonBlockingAlgorithm::m_Parameters |
|
protected |
The documentation for this class was generated from the following file: