Medical Imaging Interaction Toolkit  2023.12.00
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
106 
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::ISelectionListener
Definition: berryISelectionListener.h:38
org_blueberry_ui_qt_Export.h
berry::SelectionChangedAdapter::Callback
void(R::* Callback)(const IWorkbenchPart::Pointer &, const ISelection::ConstPointer &)
Definition: berryISelectionListener.h:105
berry::SmartPointer
Implements transparent reference counting.
Definition: berryICommandCategoryListener.h:21
berryMessage.h
berry::ISelectionListener::Events
Definition: berryISelectionListener.h:41
berry::ISelectionListener::Events::Delegate
MessageDelegate2< ISelectionListener, const IWorkbenchPart::Pointer &, const ISelection::ConstPointer & > Delegate
Definition: berryISelectionListener.h:51
berry::Message2< const IWorkbenchPart::Pointer &, const ISelection::ConstPointer & >
berry::SelectionChangedAdapter::SelectionChangedAdapter
SelectionChangedAdapter(R *l, Callback c)
Definition: berryISelectionListener.h:107
BERRY_UI_QT
#define BERRY_UI_QT
Definition: org_blueberry_ui_qt_Export.h:26
berryIWorkbenchPart.h
berry::MessageDelegate2
Definition: berryMessage.h:216
berry::SelectionChangedAdapter
Definition: berryISelectionListener.h:100
berry::SelectionChangedAdapter::SelectionChanged
void SelectionChanged(const IWorkbenchPart::Pointer &part, const ISelection::ConstPointer &selection) override
Definition: berryISelectionListener.h:114
berry::ISelectionListener::Events::selectionChanged
Message2< const IWorkbenchPart::Pointer &, const ISelection::ConstPointer & > selectionChanged
Definition: berryISelectionListener.h:45
berry::Object::Pointer
berry::SmartPointer< Self > Pointer
Definition: berryObject.h:82
berry::SelectionChangedAdapter::Listener
R Listener
Definition: berryISelectionListener.h:103
berry
Definition: QmitkPropertyItemModel.h:24
berryISelection.h