13 #ifndef mitkNonBlockingAlgorithm_h
14 #define mitkNonBlockingAlgorithm_h
19 #include <itkObjectFactory.h>
38 #define mitkAlgorithmNewMacro(classname) \
43 classname *rawPtr = new classname(); \
44 Pointer smartPtr = rawPtr; \
45 rawPtr->UnRegister(); \
46 rawPtr->Initialize(); \
51 virtual::itk::LightObject::Pointer \
52 CreateAnother(void) const override \
55 Pointer smartPtr = classname::New(); \
56 ::itk::LightObject::Pointer lightPtr = smartPtr.GetPointer(); \
57 smartPtr->Initialize(this); \
104 m_ParameterListMutex.lock();
106 m_ParameterListMutex.unlock();
114 void SetPointerParameter(
const char *parameter,
BaseData *value);
117 template <
typename TPixel,
unsigned int VImageDimension>
125 SetPointerParameter(parameter, mitkImage);
129 template <
typename TPixel,
unsigned int VImageDimension>
138 SetPointerParameter(parameter, mitkImage);
143 template <
typename T>
158 std::string error(
"There is no parameter \"");
161 throw std::invalid_argument(error);
164 template <
typename T>
184 std::string error(
"There is no parameter \"");
187 throw std::invalid_argument(error);
192 virtual void Reset();
194 void StartAlgorithm();
196 void StartBlockingAlgorithm();
197 void StopAlgorithm();
199 void TriggerParameterModified(
const itk::EventObject &);
201 void ThreadedUpdateSuccessful(
const itk::EventObject &);
202 void ThreadedUpdateFailed(
const itk::EventObject &);
208 void DefineTriggerParameter(
const char *);
209 void UnDefineTriggerParameter(
const char *);
212 virtual bool ReadyToRun();
214 virtual bool ThreadedUpdateFunction();
215 virtual void ThreadedUpdateSuccessful();
216 virtual void ThreadedUpdateFailed();
225 typedef std::map<std::string, unsigned long> MapTypeStringUInt;
227 MapTypeStringUInt m_TriggerPropertyConnections;
229 std::mutex m_ParameterListMutex;
231 int m_UpdateRequests;
232 std::thread m_Thread;