Medical Imaging Interaction Toolkit  2018.4.99-a28b433c
Medical Imaging Interaction Toolkit
berryISelectionListener.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 BERRYISELECTIONLISTENER_H_
14 #define BERRYISELECTIONLISTENER_H_
15 
16 #include <berryMessage.h>
17 
19 
20 #include "berryIWorkbenchPart.h"
21 #include "berryISelection.h"
22 
23 namespace berry
24 {
25 
39 {
40 
41  struct Events
42  {
43 
46 
47  void AddListener(ISelectionListener* listener);
48  void RemoveListener(ISelectionListener* listener);
49 
52  };
53 
54  virtual ~ISelectionListener();
55 
70  virtual void SelectionChanged(const IWorkbenchPart::Pointer& part,
71  const ISelection::ConstPointer& selection) = 0;
72 };
73 
99 template<typename R>
101 {
102 
103  typedef R Listener;
104  typedef void
105  (R::*Callback)(const IWorkbenchPart::Pointer&, const ISelection::ConstPointer&);
106 
107  SelectionChangedAdapter(R* l, Callback c) :
108  listener(l), callback(c)
109  {
110  poco_assert(listener);
111  poco_assert(callback);
112  }
113 
114  void SelectionChanged(const IWorkbenchPart::Pointer& part, const ISelection::ConstPointer& selection) override
115  {
116  (listener->*callback)(part, selection);
117  }
118 
119 private:
120 
121  Listener* listener;
122  Callback callback;
123 };
124 
125 }
126 
127 #endif /*BERRYISELECTIONLISTENER_H_*/
berry::SmartPointer< const Self > ConstPointer
Definition: berryObject.h:83
void SelectionChanged(const IWorkbenchPart::Pointer &part, const ISelection::ConstPointer &selection) override
Message2< const IWorkbenchPart::Pointer &, const ISelection::ConstPointer & > selectionChanged
MessageDelegate2< ISelectionListener, const IWorkbenchPart::Pointer &, const ISelection::ConstPointer & > Delegate
#define BERRY_UI_QT