21 #ifndef __ctkWorkflow_h
22 #define __ctkWorkflow_h
29 #include "ctkCoreExport.h"
32 class ctkWorkflowPrivate;
43 Q_PROPERTY(
bool isRunning READ isRunning DESIGNABLE
false)
44 Q_PROPERTY(
bool goBackToOriginStepUponSuccess READ goBackToOriginStepUponSuccess WRITE setGoBackToOriginStepUponSuccess)
56 Q_INVOKABLE
virtual void start();
63 Q_INVOKABLE
virtual void stop();
91 const QString& branchId = QString(),
105 const QString& branchId = QString(),
121 Q_INVOKABLE
bool hasStep(
const QString&
id)
const;
196 virtual void goForward(
const QString& desiredBranchId = QString());
199 virtual void goBackward(
const QString& desiredBranchId = QString());
247 QScopedPointer<ctkWorkflowPrivate>
d_ptr;
ctkWorkflowStep is the basis for a workflow step.
ctkWorkflow is the basis for a workflow engine, i.e. a state machine with enhancements to support ctk...
Q_INVOKABLE QList< ctkWorkflowStep * > forwardSteps(ctkWorkflowStep *step=0) const
void goToProcessingStateAfterValidationFailed()
Q_INVOKABLE bool hasTransition(ctkWorkflowStep *origin, ctkWorkflowStep *destination, const QString &branchId=QString(), const ctkWorkflow::TransitionDirectionality directionality=ctkWorkflow::Bidirectional)
Determine whether a transition has already been added.
Q_INVOKABLE ctkWorkflowStep * initialStep() const
Set/get the initial step.
ctkWorkflow(QObject *parent=0)
void performTransitionBetweenSteps()
Called when transitioning to the next step upon successful validation, or when transitioning to the p...
Q_INVOKABLE int backwardDistanceToStep(ctkWorkflowStep *fromStep=0, ctkWorkflowStep *origin=0) const
TransitionDirectionality
Transition directionalities.
virtual void goToStepFailed()
Processing that occurs after the attempt to go to a 'goTo' step fails.
virtual Q_INVOKABLE void start()
Start the workflow. The workflow will always start in the initial step, even if it is stopped and res...
Q_INVOKABLE QList< ctkWorkflowStep * > finishSteps() const
Get the steps that are 'finish' steps (i.e. have no step following them)
void setVerbose(bool value)
void currentStepChanged(ctkWorkflowStep *currentStep)
virtual void goToStep(const QString &targetId)
Go to the given step by iteratively calling goForward() until we reach it.
virtual Q_INVOKABLE void stop()
Stops the workflow.
void setGoBackToOriginStepUponSuccess(bool flag)
void goFromGoToStepToStartingStep()
Goes to the step from which the attempt to go to the 'goTo' step was initiated.
virtual Q_INVOKABLE bool addTransition(ctkWorkflowStep *origin, ctkWorkflowStep *destination, const QString &branchId=QString(), const ctkWorkflow::TransitionDirectionality directionality=ctkWorkflow::Bidirectional)
Creates a transition between two steps, and adds the two steps to the workflow if they have not been ...
Q_INVOKABLE QList< ctkWorkflowStep * > steps() const
Returns list of steps managed by the workflow.
virtual void evaluateValidationResults(bool validationSucceeded, const QString &branchId)
Receives the result of a step's validate(const QString&) function.
bool verbose() const
If set debug messages will be displayed on standard output.
Q_INVOKABLE bool canGoBackward(ctkWorkflowStep *step=0) const
Q_INVOKABLE bool canGoToStep(const QString &targetId, ctkWorkflowStep *step=0) const
QScopedPointer< ctkWorkflowPrivate > d_ptr
void stepRegistered(ctkWorkflowStep *step)
void attemptToGoToNextStep()
Q_INVOKABLE bool hasStep(const QString &id) const
void goToNextStepAfterSuccessfulValidation(const QString &branchId)
virtual Q_INVOKABLE void setInitialStep(ctkWorkflowStep *step)
bool goBackToOriginStepUponSuccess() const
virtual void goToStepSucceeded()
Processing that occurs after the attempt to go to a 'goTo' step succeeds.
Q_INVOKABLE ctkWorkflowStep * step(const QString &id) const
bool isRunning() const
Returns whether the workflow is currently running.
virtual void goBackward(const QString &desiredBranchId=QString())
Use this to trigger transition to the previous step (does not require validation)
Q_INVOKABLE QList< ctkWorkflowStep * > backwardSteps(ctkWorkflowStep *step=0) const
Q_INVOKABLE ctkWorkflowStep * currentStep() const
Q_INVOKABLE bool canGoForward(ctkWorkflowStep *step=0) const
virtual void goForward(const QString &desiredBranchId=QString())