Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
berryAbstractHandler.cpp
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 #include "berryAbstractHandler.h"
18 
19 #include "berryHandlerEvent.h"
20 
21 namespace berry
22 {
23 
25  baseEnabled(true)
26 {
27 
28 }
29 
31 {
32  handlerListeners.AddListener(handlerListener);
33 }
34 
36 {
37  // Do nothing.
38 }
39 
41 {
42  return baseEnabled;
43 }
44 
45 void AbstractHandler::SetEnabled(const Object::Pointer& /*evaluationContext*/)
46 {
47 }
48 
50 {
51  return true;
52 }
53 
55 {
56  handlerListeners.RemoveListener(handlerListener);
57 }
58 
60 {
61  if (handlerEvent.IsNull())
62  {
63  throw ctkInvalidArgumentException("Cannot fire a null handler event");
64  }
65 
66  handlerListeners.handlerChanged(handlerEvent);
67 }
68 
70 {
71  if (baseEnabled == state)
72  {
73  return;
74  }
75  baseEnabled = state;
76  HandlerEvent::Pointer event(new HandlerEvent(IHandler::Pointer(this), true, false));
77  FireHandlerChanged(event);
78 }
79 
81 {
82  return handlerListeners.handlerChanged.HasListeners();
83 }
84 
85 }
berryObjectMacro(AbstractHandler) private IHandlerListener::Events handlerListeners
void RemoveHandlerListener(IHandlerListener *handlerListener) override
void AddHandlerListener(IHandlerListener *handlerListener) override
virtual bool HasListeners() const
void SetEnabled(const Object::Pointer &evaluationContext) override
bool IsHandled() const override
void FireHandlerChanged(const SmartPointer< HandlerEvent > &handlerEvent)
bool IsEnabled() const override