Medical Imaging Interaction Toolkit  2022.04.99-194dd5d8
Medical Imaging Interaction Toolkit
mitkCallbackFromGUIThread.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 MITK_CALLBACK_WITHIN_GUI_TREAD_H_INCLUDGEWQ
14 #define MITK_CALLBACK_WITHIN_GUI_TREAD_H_INCLUDGEWQ
15 
16 #include <MitkCoreExports.h>
17 #include <itkCommand.h>
18 #include <itkEventObject.h>
19 
20 namespace mitk
21 {
25  template <class T>
26  class CallbackEventOneParameter : public itk::AnyEvent
27  {
28  public:
30  typedef itk::AnyEvent Superclass;
31 
32  CallbackEventOneParameter(const T t) : m_Data(t) {}
34  const char *GetEventName() const override { return "CallbackEventOneParameter"; }
35  bool CheckEvent(const ::itk::EventObject *e) const override { return dynamic_cast<const Self *>(e); }
36  ::itk::EventObject *MakeObject() const override { return new Self(m_Data); }
37  const T GetData() const { return m_Data; }
38  CallbackEventOneParameter(const Self &s) : itk::AnyEvent(s), m_Data(s.m_Data){};
39 
40  protected:
41  const T m_Data;
42 
43  private:
44  void operator=(const Self &);
45  };
46 
55  {
56  public:
58  virtual void CallThisFromGUIThread(itk::Command *, itk::EventObject *) = 0;
59 
61 
62  protected:
63  private:
64  };
65 
154  {
155  public:
157  static CallbackFromGUIThread *GetInstance();
158 
160  static void RegisterImplementation(CallbackFromGUIThreadImplementation *implementation);
161 
163  void CallThisFromGUIThread(itk::Command *, itk::EventObject *e = nullptr);
164 
165  protected:
168 
169  private:
170  static CallbackFromGUIThreadImplementation *m_Implementation;
171  static CallbackFromGUIThread *m_Instance;
172  };
173 
174 } // namespace
175 
176 #endif
Toolkit specific implementation of mitk::CallbackFromGUIThread.
#define MITKCORE_EXPORT
bool CheckEvent(const ::itk::EventObject *e) const override
DataCollection - Class to facilitate loading/accessing structured data.
Used by CallbackFromGUIThread to pass parameters.
Allows threads to call some method from within the GUI thread.
::itk::EventObject * MakeObject() const override
const char * GetEventName() const override