Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef MITK_CALLBACK_WITHIN_GUI_TREAD_H_INCLUDGEWQ
18 #define MITK_CALLBACK_WITHIN_GUI_TREAD_H_INCLUDGEWQ
19 
20 #include <MitkCoreExports.h>
21 #include <itkCommand.h>
22 #include <itkEventObject.h>
23 
24 namespace mitk
25 {
29  template <class T>
30  class CallbackEventOneParameter : public itk::AnyEvent
31  {
32  public:
34  typedef itk::AnyEvent Superclass;
35 
36  CallbackEventOneParameter(const T t) : m_Data(t) {}
38  virtual const char *GetEventName() const override { return "CallbackEventOneParameter"; }
39  virtual bool CheckEvent(const ::itk::EventObject *e) const override { return dynamic_cast<const Self *>(e); }
40  virtual ::itk::EventObject *MakeObject() const override { return new Self(m_Data); }
41  const T GetData() const { return m_Data; }
42  CallbackEventOneParameter(const Self &s) : itk::AnyEvent(s), m_Data(s.m_Data){};
43 
44  protected:
45  const T m_Data;
46 
47  private:
48  void operator=(const Self &);
49  };
50 
59  {
60  public:
62  virtual void CallThisFromGUIThread(itk::Command *, itk::EventObject *) = 0;
63 
65 
66  protected:
67  private:
68  };
69 
158  {
159  public:
161  static CallbackFromGUIThread *GetInstance();
162 
164  static void RegisterImplementation(CallbackFromGUIThreadImplementation *implementation);
165 
167  void CallThisFromGUIThread(itk::Command *, itk::EventObject *e = nullptr);
168 
169  protected:
172 
173  private:
174  static CallbackFromGUIThreadImplementation *m_Implementation;
175  static CallbackFromGUIThread *m_Instance;
176  };
177 
178 } // namespace
179 
180 #endif
Toolkit specific implementation of mitk::CallbackFromGUIThread.
#define MITKCORE_EXPORT
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.
virtual bool CheckEvent(const ::itk::EventObject *e) const override
virtual const char * GetEventName() const override
virtual ::itk::EventObject * MakeObject() const override