Medical Imaging Interaction Toolkit  2023.04.00
Medical Imaging Interaction Toolkit
berryISafeRunnable.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef BERRYISAFERUNNABLE_H_
14 #define BERRYISAFERUNNABLE_H_
15 
16 #include <berryObject.h>
17 #include <berryMacros.h>
18 
20 
21 namespace berry
22 {
23 
37 {
38 
40 
52  virtual void HandleException(const ctkException& exception) = 0;
53 
63  virtual void Run() = 0;
64 };
65 
66 template<typename R>
68 {
69  typedef void(R::*RunCallback)();
70  typedef void(R::*HandleExcCallback)(const std::exception&);
71 
72  SafeRunnableDelegate(R* runnable, RunCallback func, HandleExcCallback handleFunc = 0) :
73  m_Runnable(runnable), m_RunFunc(func), m_HandleExcFunc(handleFunc)
74  {
75  }
76 
77  void Run() override
78  {
79  m_Runnable->*m_RunFunc();
80  }
81 
82  void HandleException(const ctkException& exception) override
83  {
84  if (m_HandleExcFunc)
85  m_Runnable->*m_HandleExcFunc(exception);
86  }
87 
88 private:
89 
90  R* m_Runnable;
91  RunCallback m_RunFunc;
92  HandleExcCallback m_HandleExcFunc;
93 
94 };
95 
96 }
97 
98 #endif /* BERRYISAFERUNNABLE_H_ */
org_blueberry_core_runtime_Export.h
berry::SafeRunnableDelegate::HandleException
void HandleException(const ctkException &exception) override
Definition: berryISafeRunnable.h:82
berry::SafeRunnableDelegate::HandleExcCallback
void(R::* HandleExcCallback)(const std::exception &)
Definition: berryISafeRunnable.h:70
berryMacros.h
berry::SafeRunnableDelegate
Definition: berryISafeRunnable.h:67
berry::Object
Light weight base class for most BlueBerry classes.
Definition: berryObject.h:72
org_blueberry_core_runtime_EXPORT
#define org_blueberry_core_runtime_EXPORT
Definition: org_blueberry_core_runtime_Export.h:26
berry::SafeRunnableDelegate::RunCallback
void(R::* RunCallback)()
Definition: berryISafeRunnable.h:69
berry::ISafeRunnable
Definition: berryISafeRunnable.h:36
berryObjectMacro
#define berryObjectMacro(...)
Definition: berryMacros.h:33
berryObject.h
berry
Definition: QmitkPropertyItemModel.h:24
berry::SafeRunnableDelegate::SafeRunnableDelegate
SafeRunnableDelegate(R *runnable, RunCallback func, HandleExcCallback handleFunc=0)
Definition: berryISafeRunnable.h:72
berry::SafeRunnableDelegate::Run
void Run() override
Definition: berryISafeRunnable.h:77
GlobalReinitAction::Run
MITK_QT_APP void Run(berry::IWorkbenchPartSite::Pointer workbenchPartSite, mitk::DataStorage::Pointer dataStorage)