Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
berryIPropertyChangeListener.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 BERRYIPROPERTYCHANGELISTENER_H_
18 #define BERRYIPROPERTYCHANGELISTENER_H_
19 
20 #include <berryMacros.h>
21 #include <berryMessage.h>
22 
25 
26 namespace berry
27 {
28 
47 {
48 
49  virtual ~IPropertyChangeListener();
50 
52 
54 
55  EventType propertyChange;
56 
57  void AddListener(IPropertyChangeListener* listener);
58  void RemoveListener(IPropertyChangeListener* listener);
59 
60  private:
61 
63  };
64 
75  virtual void PropertyChange(const PropertyChangeEvent::Pointer& event);
76 
77  virtual void PropertyChange(const Object::Pointer& /*source*/, int /*propId*/) {}
78 };
79 
80 template<typename R>
82 {
83 
84  typedef R Listener;
85  typedef void
87 
88  PropertyChangeAdapter(R* l, Callback c) :
89  listener(l), callback(c)
90  {
91  poco_assert(listener);
92  poco_assert(callback);
93  }
94 
96 
97  void PropertyChange(const PropertyChangeEvent::Pointer& event) override
98  {
99  (listener->*callback)(event);
100  }
101 
102 private:
103 
104  Listener* listener;
105  Callback callback;
106 };
107 
108 template<typename R>
110 {
111 
112  typedef R Listener;
113  typedef void
114  (R::*Callback)(const Object::Pointer&, int);
115 
116  PropertyChangeIntAdapter(R* l, Callback c) :
117  listener(l), callback(c)
118  {
119  poco_assert(listener);
120  poco_assert(callback);
121  }
122 
124 
125  void PropertyChange(const Object::Pointer& source, int propId) override
126  {
127  (listener->*callback)(source, propId);
128  }
129 
130 private:
131 
132  Listener* listener;
133  Callback callback;
134 };
135 
136 }
137 
138 #endif /* BERRYIPROPERTYCHANGELISTENER_H_ */
Message1< const PropertyChangeEvent::Pointer & > EventType
virtual void PropertyChange(const Object::Pointer &, int)
void(R::* Callback)(const PropertyChangeEvent::Pointer &)
virtual void PropertyChange(const PropertyChangeEvent::Pointer &event)
void PropertyChange(const PropertyChangeEvent::Pointer &event) override
void PropertyChange(const Object::Pointer &source, int propId) override
berry::SmartPointer< Self > Pointer
Definition: berryObject.h:88
void(R::* Callback)(const Object::Pointer &, int)
#define BERRY_UI_QT