Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
berryCommandEvent.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 "berryCommandEvent.h"
14 #include "berryCommand.h"
15 #include "berryCommandCategory.h"
16 #include "berryState.h"
18 #include "berryIHandler.h"
19 
20 namespace berry
21 {
22 
23 int CommandEvent::CHANGED_CATEGORY() { static int i = CommandEvent::LAST_USED_BIT() << 1; return i; }
24 int CommandEvent::CHANGED_HANDLED() { static int i = CommandEvent::LAST_USED_BIT() << 2; return i; }
25 int CommandEvent::CHANGED_PARAMETERS() { static int i = CommandEvent::LAST_USED_BIT() << 3; return i; }
26 int CommandEvent::CHANGED_RETURN_TYPE() { static int i = CommandEvent::LAST_USED_BIT() << 4; return i; }
27 int CommandEvent::CHANGED_HELP_CONTEXT_ID() { static int i = CommandEvent::LAST_USED_BIT() << 5; return i; }
28 int CommandEvent::CHANGED_ENABLED() { static int i = CommandEvent::LAST_USED_BIT() << 6; return i; }
29 
31  bool categoryChanged, bool definedChanged, bool descriptionChanged,
32  bool handledChanged, bool nameChanged, bool parametersChanged,
33  bool returnTypeChanged, bool helpContextIdChanged,
34  bool enabledChanged) :
35  AbstractNamedHandleEvent(definedChanged, descriptionChanged, nameChanged),
36  command(command)
37 {
38 
39  if (!command)
40  {
41  throw Poco::NullPointerException("The command cannot be null");
42  }
43 
44  if (categoryChanged)
45  {
46  changedValues |= CHANGED_CATEGORY();
47  }
48  if (handledChanged)
49  {
50  changedValues |= CHANGED_HANDLED();
51  }
52  if (parametersChanged)
53  {
54  changedValues |= CHANGED_PARAMETERS();
55  }
56  if (returnTypeChanged)
57  {
58  changedValues |= CHANGED_RETURN_TYPE();
59  }
60  if (helpContextIdChanged)
61  {
62  changedValues |= CHANGED_HELP_CONTEXT_ID();
63  }
64  if (enabledChanged)
65  {
66  changedValues |= CHANGED_ENABLED();
67  }
68 }
69 
71 {
72  return command;
73 }
74 
76 {
77  return ((changedValues & CHANGED_CATEGORY()) != 0);
78 }
79 
81 {
82  return ((changedValues & CHANGED_HANDLED()) != 0);
83 }
84 
86 {
87  return ((changedValues & CHANGED_HELP_CONTEXT_ID()) != 0);
88 }
89 
91 {
92  return ((changedValues & CHANGED_PARAMETERS()) != 0);
93 }
94 
96 {
97  return ((changedValues & CHANGED_RETURN_TYPE()) != 0);
98 }
99 
101 {
102  return ((changedValues & CHANGED_ENABLED()) != 0);
103 }
104 
105 }
bool IsHelpContextIdChanged() const
bool IsHandledChanged() const
CommandEvent(const SmartPointer< Command > command, bool categoryChanged, bool definedChanged, bool descriptionChanged, bool handledChanged, bool nameChanged, bool parametersChanged, bool returnTypeChanged=false, bool helpContextIdChanged=false, bool enabledChanged=false)
bool IsParametersChanged() const
bool IsReturnTypeChanged() const
SmartPointer< Command > GetCommand() const
bool IsCategoryChanged() const