CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkWorkflowStep.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Library: CTK
4 
5  Copyright (c) Kitware Inc.
6 
7  Licensed under the Apache License, Version 2.0 (the "License");
8  you may not use this file except in compliance with the License.
9  You may obtain a copy of the License at
10 
11  http://www.apache.org/licenses/LICENSE-2.0.txt
12 
13  Unless required by applicable law or agreed to in writing, software
14  distributed under the License is distributed on an "AS IS" BASIS,
15  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  See the License for the specific language governing permissions and
17  limitations under the License.
18 
19 =========================================================================*/
20 
21 #ifndef __ctkWorkflowStep_h
22 #define __ctkWorkflowStep_h
23 
24 // Qt includes
25 class QObject;
26 class QState;
27 
28 // CTK includes
29 #include "ctkPimpl.h"
30 #include "ctkWorkflow_p.h"
31 #include "ctkWorkflowTransitions.h"
32 
33 #include "ctkCoreExport.h"
34 
35 class ctkWorkflow;
36 
37 class ctkWorkflowStepPrivate;
38 
44 
45 class CTK_CORE_EXPORT ctkWorkflowStep
46 {
47 
48 public:
49  explicit ctkWorkflowStep();
50  explicit ctkWorkflowStep(const QString& newId);
51  virtual ~ctkWorkflowStep();
52 
54  ctkWorkflow* workflow()const;
55 
57  QString id()const;
58 
61  void setId(const QString& newStepId);
62 
64  QString name()const;
65  void setName(const QString& newName);
66 
68  QString description()const;
69  void setDescription(const QString& newDescription);
70 
72  QString statusText()const;
73 
77  bool hasValidateCommand()const;
78  void setHasValidateCommand(bool newHasValidateCommand);
79 
83  bool hasOnEntryCommand()const;
84  void setHasOnEntryCommand(bool newHasOnEntryCommand);
85 
90  bool hasOnExitCommand()const;
91  void setHasOnExitCommand(bool newHasOnExitCommand);
92 
94  bool isWidgetType()const;
95 
97  QObject* ctkWorkflowStepQObject();
98 
99 protected:
100 
101  explicit ctkWorkflowStep(ctkWorkflowStepPrivate * pimpl, const QString& newId);
102 
104  void setWorkflow(ctkWorkflow* newWorkflow);
105 
106  void setStatusText(const QString& newText);
107 
111  QState* processingState()const;
112 
116  QState* validationState()const;
117 
130  ctkWorkflowIntrastepTransition* validationTransition()const;
131 
147  ctkWorkflowIntrastepTransition* validationFailedTransition()const;
148 
162  virtual void onEntry(const ctkWorkflowStep* comingFrom, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType);
163 
177  virtual void onExit(const ctkWorkflowStep* goingTo,
179 
190  //
205  virtual void validate(const QString& desiredBranchId = QString());
206 
211  void invokeValidateCommand(const QString& desiredBranchId = QString())const;
212 
217  void validationComplete(bool validationSuceeded, const QString& branchId = QString())const;
218 
223  void invokeOnEntryCommand(const ctkWorkflowStep* comingFrom, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType)const;
224 
229  void onEntryComplete()const;
230 
235  void invokeOnExitCommand(const ctkWorkflowStep* goingTo, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType)const;
236 
241  void onExitComplete()const;
242 
243 protected:
244  QScopedPointer<ctkWorkflowStepPrivate> d_ptr;
245 
246 private:
247  Q_DECLARE_PRIVATE(ctkWorkflowStep);
248  Q_DISABLE_COPY(ctkWorkflowStep);
249  friend class ctkWorkflow; // For access to processingState, validationState, setWorkflow, validate
250  friend class ctkWorkflowPrivate; // For access to invokeOn{Entry,Exit}Command, on{Entry,Exit}
251 };
252 
253 #endif
ctkWorkflow is the basis for a workflow engine, i.e. a state machine with enhancements to support ctk...
Definition: ctkWorkflow.h:39
QScopedPointer< ctkWorkflowStepPrivate > d_ptr
ctkWorkflowStep is the basis for a workflow step.