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