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 
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 
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 
131 
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 
224 
229  void onEntryComplete()const;
230 
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
ctkWorkflowStep is the basis for a workflow step.
void invokeValidateCommand(const QString &desiredBranchId=QString()) const
Signal (emitted by the private implementation) indicating that validation of this step's processing s...
QString statusText() const
Get statusText.
QString description() const
Set/get description.
bool hasValidateCommand() const
void validationComplete(bool validationSuceeded, const QString &branchId=QString()) const
Signal (emitted by the private implementation) indicating that validation of this step's processing h...
virtual void onExit(const ctkWorkflowStep *goingTo, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType)
Reimplement this function for step-specific processing when exiting a step.
QObject * ctkWorkflowStepQObject()
Get QObject associated with this step, to connect signals/slots.
void setWorkflow(ctkWorkflow *newWorkflow)
Set workflow.
bool hasOnExitCommand() const
void setHasOnEntryCommand(bool newHasOnEntryCommand)
QState * processingState() const
Get the step's processing state.
void onExitComplete() const
Signal (emitted by the private implementation) indicating that the step's 'onExit' processing has com...
void setName(const QString &newName)
void setId(const QString &newStepId)
QState * validationState() const
Get the step's validation state.
ctkWorkflowIntrastepTransition * validationTransition() const
Get the step's validation transition.
ctkWorkflowStep(ctkWorkflowStepPrivate *pimpl, const QString &newId)
virtual void validate(const QString &desiredBranchId=QString())
Validates the computation performed in this step's processing state.
void invokeOnExitCommand(const ctkWorkflowStep *goingTo, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType) const
Signal (emitted by the private implementation) indicating that the step's 'onExit' processing should ...
ctkWorkflow * workflow() const
Get the workflow associated with this step.
bool isWidgetType() const
Returns true if the object is a widget; otherwise returns false.
void setHasOnExitCommand(bool newHasOnExitCommand)
void invokeOnEntryCommand(const ctkWorkflowStep *comingFrom, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType) const
Signal (emitted by the private implementation) indicating that the step's 'onEntry' processing should...
QString id() const
Get id.
void onEntryComplete() const
Signal (emitted by the private implementation) indicating that the step's 'onEntry' processing has co...
QString name() const
Set/get name.
QScopedPointer< ctkWorkflowStepPrivate > d_ptr
ctkWorkflowIntrastepTransition * validationFailedTransition() const
Get the step's validation failed transition.
virtual void onEntry(const ctkWorkflowStep *comingFrom, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType)
Reimplement this function for step-specific processing when entering a step.
virtual ~ctkWorkflowStep()
void setHasValidateCommand(bool newHasValidateCommand)
ctkWorkflowStep(const QString &newId)
void setDescription(const QString &newDescription)
bool hasOnEntryCommand() const
void setStatusText(const QString &newText)
ctkWorkflow is the basis for a workflow engine, i.e. a state machine with enhancements to support ctk...
Definition: ctkWorkflow.h:40