17 #ifndef MITK_NON_BLOCKING_ALGORITHM_H_INCLUDED_DFARdfWN1tr
18 #define MITK_NON_BLOCKING_ALGORITHM_H_INCLUDED_DFARdfWN1tr
21 #include <itkFastMutexLock.h>
24 #include <itkMultiThreader.h>
25 #include <itkObjectFactory.h>
43 #define mitkAlgorithmNewMacro(classname) \
48 classname *rawPtr = new classname(); \
49 Pointer smartPtr = rawPtr; \
50 rawPtr->UnRegister(); \
51 rawPtr->Initialize(); \
56 virtual::itk::LightObject::Pointer \
57 CreateAnother(void) const override \
60 Pointer smartPtr = classname::New(); \
61 ::itk::LightObject::Pointer lightPtr = smartPtr.GetPointer(); \
62 smartPtr->Initialize(this); \
101 template <typename T>
102 void SetParameter(const
char *parameter, const T &value)
111 template <
typename T>
116 m_ParameterListMutex->Lock();
118 m_ParameterListMutex->Unlock();
126 void SetPointerParameter(
const char *parameter,
BaseData *value);
129 template <
typename TPixel,
unsigned int VImageDimension>
137 SetPointerParameter(parameter, mitkImage);
141 template <
typename TPixel,
unsigned int VImageDimension>
150 SetPointerParameter(parameter, mitkImage);
155 template <
typename T>
170 std::string error(
"There is no parameter \"");
173 throw std::invalid_argument(error);
176 template <
typename T>
196 std::string error(
"There is no parameter \"");
199 throw std::invalid_argument(error);
204 virtual void Reset();
206 void StartAlgorithm();
208 void StartBlockingAlgorithm();
209 void StopAlgorithm();
211 void TriggerParameterModified(
const itk::EventObject &);
213 void ThreadedUpdateSuccessful(
const itk::EventObject &);
214 void ThreadedUpdateFailed(
const itk::EventObject &);
220 void DefineTriggerParameter(
const char *);
221 void UnDefineTriggerParameter(
const char *);
224 virtual bool ReadyToRun();
226 virtual bool ThreadedUpdateFunction();
227 virtual void ThreadedUpdateSuccessful();
228 virtual void ThreadedUpdateFailed();
235 static ITK_THREAD_RETURN_TYPE StaticNonBlockingAlgorithmThread(
void *param);
237 typedef std::map<std::string, unsigned long> MapTypeStringUInt;
239 MapTypeStringUInt m_TriggerPropertyConnections;
244 int m_UpdateRequests;
void SetItkImageAsMITKImagePointerParameter(const char *parameter, const itk::SmartPointer< itk::Image< TPixel, VImageDimension >> &itkImage)
For any kind of ITK images (smartpointers)
itk::SmartPointer< NonBlockingAlgorithm > m_Algorithm
Data management class that handles 'was created by' relations.
itk::SmartPointer< Self > Pointer
Base of all data objects.
void SetItkImageAsMITKImagePointerParameter(const char *parameter, itk::Image< TPixel, VImageDimension > *itkImage)
For any kind of ITK images (C pointers)
DataCollection - Class to facilitate loading/accessing structured data.
static mitk::DataStorage::Pointer GetDataStorage()
WeakPointer< DataStorage > m_DataStorage
Property containing a smart-pointer.
Image::Pointer ImportItkImage(const itk::SmartPointer< ItkOutputImageType > &itkimage, const BaseGeometry *geometry=nullptr, bool update=true)
Imports an itk::Image (with a specific type) as an mitk::Image.Instantiates instance of ITKImageImpor...
#define MITKALGORITHMSEXT_EXPORT
itk::Object::Pointer GetSmartPointer() const
Abstract base class for properties.
#define mitkClassMacroItkParent(className, SuperClassName)
Implements a weak reference to an object.
PropertyList::Pointer m_Parameters
void SetPointerParameter(const char *parameter, const itk::SmartPointer< T > &value)
For any kind of smart pointers.
void GetPointerParameter(const char *parameter, itk::SmartPointer< T > &value) const
void GetParameter(const char *parameter, T &value) const
virtual T GetValue() const