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