Medical Imaging Interaction Toolkit  2024.06.00
Medical Imaging Interaction Toolkit
berryCommand.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 BERRYCOMMAND_H_
14 #define BERRYCOMMAND_H_
15 
17 
18 #include <berryICommandListener.h>
19 #include <berryIHandlerListener.h>
21 #include <berryIParameter.h>
22 
23 #include <berryParameterType.h>
24 
25 namespace berry
26 {
27 
28 class CommandCategory;
29 class ExecutionEvent;
30 struct IHandler;
31 
61 { // implements Comparable {
62 
63 public:
64 
66 
72 
77  static bool DEBUG_HANDLERS;
78 
84  static QString DEBUG_HANDLERS_COMMAND_ID;
85 
86 private:
87 
93 
98  //ListenerList executionListeners;
99 
103  ICommandListener::Events commandEvents;
104 
109  SmartPointer<IHandler> handler;
110 
116  QString helpContextId;
117 
123  QList<SmartPointer<IParameter> > parameters;
124 
129  SmartPointer<ParameterType> returnType;
130 
131 protected:
132 
143  Command(const QString& id);
144 
145  friend class CommandManager;
146 
147 public:
148 
156  void AddCommandListener(ICommandListener* commandListener);
157 
165  void AddExecutionListener(IExecutionListener* executionListener);
166 
183  void AddState(const QString& id, const SmartPointer<State>& state) override;
184 
195  bool operator<(const Object* object) const override;
196 
225  void Define(const QString& name, const QString& description,
226  const SmartPointer<CommandCategory> category,
227  const QList<SmartPointer<IParameter> >& parameters = QList<SmartPointer<IParameter> >(),
228  const SmartPointer<ParameterType>& returnType = SmartPointer<ParameterType>(nullptr),
229  const QString& helpContextId = "");
230 
254  Object::Pointer ExecuteWithChecks(const SmartPointer<const ExecutionEvent> event);
255 
256 private:
257 
265  void FireCommandChanged(const SmartPointer<const CommandEvent> commandEvent);
266 
276  void FireNotDefined(const NotDefinedException* e);
277 
286  void FireNotEnabled(const NotEnabledException* e);
287 
296  void FireNotHandled(const NotHandledException* e);
297 
307  void FirePostExecuteFailure(const ExecutionException* e);
308 
316  void FirePostExecuteSuccess(const Object::Pointer returnValue);
317 
325  void FirePreExecute(const SmartPointer<const ExecutionEvent> event);
326 
327 public:
328 
339  SmartPointer<IHandler> GetHandler() const;
340 
349  QString GetHelpContextId() const;
350 
362  SmartPointer<IParameter> GetParameter(const QString& parameterId) const;
363 
373  QList<SmartPointer<IParameter> > GetParameters() const;
374 
389  SmartPointer<ParameterType> GetParameterType(const QString& parameterId) const;
390 
402  SmartPointer<ParameterType> GetReturnType() const;
403 
411  bool IsEnabled() const;
412 
421  void SetEnabled(const Object::Pointer& evaluationContext);
422 
430  bool IsHandled() const;
431 
439  void RemoveCommandListener(ICommandListener* commandListener);
440 
448  void RemoveExecutionListener(IExecutionListener* executionListener);
449 
461  void RemoveState(const QString& stateId) override;
462 
474  bool SetHandler(const SmartPointer<IHandler> handler);
475 
476 private:
477 
481  IHandlerListener* GetHandlerListener();
482 
487  void HandlerChanged(const SmartPointer<HandlerEvent>& handlerEvent) override;
488 
489 
490 public:
491 
498  QString ToString() const override;
499 
505  void Undefine() override;
506 };
507 
508 }
509 #endif /*BERRYCOMMAND_H_*/
berry::CommandManager
Definition: berryCommandManager.h:49
berry::Command::DEBUG_HANDLERS
static bool DEBUG_HANDLERS
Definition: berryCommand.h:77
berryIExecutionListenerWithChecks.h
berry::IExecutionListener
Definition: berryIExecutionListener.h:35
berryICommandListener.h
berryIParameter.h
berry::NamedHandleObjectWithState
Definition: berryNamedHandleObjectWithState.h:32
mitk::modelFit::operator<
bool operator<(const StaticParameterMap::ValueType &a, const StaticParameterMap::ValueType &b)
Compares two var lists and returns true if the first list's first item is lower than the second one's...
Definition: mitkModelFitStaticParameterMap.h:139
berry::SmartPointer
Implements transparent reference counting.
Definition: berryICommandCategoryListener.h:21
berryIHandlerListener.h
BERRY_COMMANDS
#define BERRY_COMMANDS
Definition: org_blueberry_core_commands_Export.h:26
berry::Object
Light weight base class for most BlueBerry classes.
Definition: berryObject.h:72
berry::ICommandListener
Definition: berryICommandListener.h:37
berry::Command::DEBUG_HANDLERS_COMMAND_ID
static QString DEBUG_HANDLERS_COMMAND_ID
Definition: berryCommand.h:84
berry::Command
Definition: berryCommand.h:60
berry::ICommandListener::Events
Definition: berryICommandListener.h:40
berry::IHandlerListener
Definition: berryIHandlerListener.h:37
berry::IExecutionListenerWithChecks::Events
Definition: berryIExecutionListenerWithChecks.h:36
berryObjectMacro
#define berryObjectMacro(...)
Definition: berryMacros.h:31
berryNamedHandleObjectWithState.h
berry
Definition: QmitkPropertyItemModel.h:24
berry::Command::DEBUG_COMMAND_EXECUTION
static bool DEBUG_COMMAND_EXECUTION
Definition: berryCommand.h:71
berryParameterType.h