Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
berryISelectionListener.h
Go to the documentation of this file.
1 /*===================================================================
2 
3 BlueBerry Platform
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 BERRYISELECTIONLISTENER_H_
18 #define BERRYISELECTIONLISTENER_H_
19 
20 #include <berryMessage.h>
21 
23 
24 #include "berryIWorkbenchPart.h"
25 #include "berryISelection.h"
26 
27 namespace berry
28 {
29 
43 {
44 
45  struct Events
46  {
47 
50 
51  void AddListener(ISelectionListener* listener);
52  void RemoveListener(ISelectionListener* listener);
53 
56  };
57 
58  virtual ~ISelectionListener();
59 
74  virtual void SelectionChanged(const IWorkbenchPart::Pointer& part,
75  const ISelection::ConstPointer& selection) = 0;
76 };
77 
103 template<typename R>
105 {
106 
107  typedef R Listener;
108  typedef void
110 
111  SelectionChangedAdapter(R* l, Callback c) :
112  listener(l), callback(c)
113  {
114  poco_assert(listener);
115  poco_assert(callback);
116  }
117 
118  void SelectionChanged(const IWorkbenchPart::Pointer& part, const ISelection::ConstPointer& selection) override
119  {
120  (listener->*callback)(part, selection);
121  }
122 
123 private:
124 
125  Listener* listener;
126  Callback callback;
127 };
128 
129 }
130 
131 #endif /*BERRYISELECTIONLISTENER_H_*/
void SelectionChanged(const IWorkbenchPart::Pointer &part, const ISelection::ConstPointer &selection) override
void(R::* Callback)(const IWorkbenchPart::Pointer &, const ISelection::ConstPointer &)
Message2< const IWorkbenchPart::Pointer &, const ISelection::ConstPointer & > selectionChanged
MessageDelegate2< ISelectionListener, const IWorkbenchPart::Pointer &, const ISelection::ConstPointer & > Delegate
#define BERRY_UI_QT