Medical Imaging Interaction Toolkit  2024.06.00
Medical Imaging Interaction Toolkit
berryIPropertyChangeListener.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 BERRYIPROPERTYCHANGELISTENER_H_
14 #define BERRYIPROPERTYCHANGELISTENER_H_
15 
16 #include <berryMacros.h>
17 #include <berryMessage.h>
18 
21 
22 namespace berry
23 {
24 
43 {
44 
45  virtual ~IPropertyChangeListener();
46 
48 
50 
52 
53  void AddListener(IPropertyChangeListener* listener);
54  void RemoveListener(IPropertyChangeListener* listener);
55 
56  private:
57 
59  };
60 
71  virtual void PropertyChange(const PropertyChangeEvent::Pointer& event);
72 
73  virtual void PropertyChange(const Object::Pointer& /*source*/, int /*propId*/) {}
74 };
75 
76 template<typename R>
78 {
79 
80  typedef R Listener;
81  typedef void
83 
85  listener(l), callback(c)
86  {
87  poco_assert(listener);
88  poco_assert(callback);
89  }
90 
92 
93  void PropertyChange(const PropertyChangeEvent::Pointer& event) override
94  {
95  (listener->*callback)(event);
96  }
97 
98 private:
99 
100  Listener* listener;
101  Callback callback;
102 };
103 
104 template<typename R>
106 {
107 
108  typedef R Listener;
109  typedef void
110  (R::*Callback)(const Object::Pointer&, int);
111 
113  listener(l), callback(c)
114  {
115  poco_assert(listener);
116  poco_assert(callback);
117  }
118 
120 
121  void PropertyChange(const Object::Pointer& source, int propId) override
122  {
123  (listener->*callback)(source, propId);
124  }
125 
126 private:
127 
128  Listener* listener;
129  Callback callback;
130 };
131 
132 }
133 
134 #endif /* BERRYIPROPERTYCHANGELISTENER_H_ */
berry::IPropertyChangeListener
Definition: berryIPropertyChangeListener.h:42
org_blueberry_ui_qt_Export.h
berry::IPropertyChangeListener::PropertyChange
virtual void PropertyChange(const Object::Pointer &, int)
Definition: berryIPropertyChangeListener.h:73
berryMacros.h
berry::SmartPointer
Implements transparent reference counting.
Definition: berryICommandCategoryListener.h:21
berryMessage.h
berry::Message1< const PropertyChangeEvent::Pointer & >
berry::PropertyChangeAdapter
Definition: berryIPropertyChangeListener.h:77
berry::IPropertyChangeListener::PropertyChange
virtual void PropertyChange(const PropertyChangeEvent::Pointer &event)
berry::PropertyChangeIntAdapter::Callback
void(R::* Callback)(const Object::Pointer &, int)
Definition: berryIPropertyChangeListener.h:110
berry::MessageDelegate1
Definition: berryMessage.h:170
berry::PropertyChangeAdapter::PropertyChangeAdapter
PropertyChangeAdapter(R *l, Callback c)
Definition: berryIPropertyChangeListener.h:84
berry::PropertyChangeIntAdapter
Definition: berryIPropertyChangeListener.h:105
BERRY_UI_QT
#define BERRY_UI_QT
Definition: org_blueberry_ui_qt_Export.h:26
berry::PropertyChangeAdapter::PropertyChange
void PropertyChange(const PropertyChangeEvent::Pointer &event) override
Definition: berryIPropertyChangeListener.h:93
berry::PropertyChangeIntAdapter::PropertyChange
void PropertyChange(const Object::Pointer &source, int propId) override
Definition: berryIPropertyChangeListener.h:121
berry::PropertyChangeIntAdapter::PropertyChangeIntAdapter
PropertyChangeIntAdapter(R *l, Callback c)
Definition: berryIPropertyChangeListener.h:112
berry::IPropertyChangeListener::Events::propertyChange
EventType propertyChange
Definition: berryIPropertyChangeListener.h:51
berry::PropertyChangeAdapter::Listener
R Listener
Definition: berryIPropertyChangeListener.h:80
berry::PropertyChangeAdapter::Callback
void(R::* Callback)(const PropertyChangeEvent::Pointer &)
Definition: berryIPropertyChangeListener.h:82
berry::IPropertyChangeListener::Events::EventType
Message1< const PropertyChangeEvent::Pointer & > EventType
Definition: berryIPropertyChangeListener.h:49
berryPropertyChangeEvent.h
berry
Definition: QmitkPropertyItemModel.h:24
berry::PropertyChangeIntAdapter::Listener
R Listener
Definition: berryIPropertyChangeListener.h:108
berry::IPropertyChangeListener::Events
Definition: berryIPropertyChangeListener.h:47