Workspace 6.21.5
|
Base class for operations that iterate over a workflow one or more times. More...
#include <Workspace/DataExecution/Operations/Builtin/iteratingoperationbase.h>
Public Types | |
enum | ExecutionResult { Abort , Success , Retry } |
Result of an iteration's execution. More... | |
Public Member Functions | |
IteratingOperationBase () | |
virtual | ~IteratingOperationBase ()=default |
Protected Member Functions | |
virtual bool | atEndCondition ()=0 |
virtual ExecutionResult | executeIteration (Workspace *workspaceToExecute) noexcept(false)=0 |
Workspace * | getWorkspaceToExecute () |
bool | isExecuting () const |
virtual bool | isLoopConditionValid () const =0 |
virtual void | performCleanup (Workspace *workspaceToExecute, bool forceStop) noexcept(false)=0 |
virtual bool | performInitialisation (Workspace *workspaceToExecute) noexcept(false)=0 |
virtual bool | postIterationExecute () |
virtual bool | preIterations ()=0 |
virtual void | setNonIterationControlInputsNotUpToDate () |
void | setWorkspaceToExecute (Workspace *workspace) |
virtual bool | updateInputsForIteration ()=0 |
virtual void | updateProgress ()=0 |
Protected Attributes | |
bool | executing_ |
bool | reset_ |
Derived classes are advised not to derive from this directly, but rather used the classes WorkspaceBasedParallelIterator or OperationBasedParallelIterator.
This class does not inherit from either Operation or Workspace, as it leaves this option up to the derived class as to how they want the iteration to be implemented. Instead, derived classes should pass a reference of themselves to the base class constructor. If the WorkspaceBasedParallelIterator or OperationBasedParallelIterator classes are used, this is automatically handled for the developer.
enum ExecutionResult |
|
virtualdefault |
|
protectedpure virtual |
Invoked to test the end condition after each loop iteration.
Implemented in ParallelIteratingOperation< Derived >, and ParallelIteratingOperation< CountedLoop >.
|
protectedpure virtual |
workspaceToExecute | The workspace of which to execute an iteration. This will be provided as 'null' if the derived class does not ensure that setWorkspaceToExecute() is invoked prior to execution. It's up to derived classes whether or not this is an error. |
Invoked for each iteration of the workspace under execution. Derived classes can override this to control exactly how this execution occurs. For example, it could execute immediately, or it could be scheduled for future execution.
Implemented in ParallelIteratingOperation< Derived >, and ParallelIteratingOperation< CountedLoop >.
|
protected |
|
protected |
|
protectedpure virtual |
Derived classes must override this method to specify when a loop termination condition is infinite. Workspace can then terminate the loop with an error if this is achieved. To allow infinite loops, simply return false from this method always.
Implemented in ParallelIteratingOperation< Derived >, and ParallelIteratingOperation< CountedLoop >.
|
protectedpure virtual |
workspaceToExecute | The specific workspace that has been executed for a given iteration. |
forceStop | If true, will force the loop to stop iterating. |
Cleanup opportunity following the attempted execution of iterations. Regardless of how the execution terminates (aborted or successful), this method is invoked. Must not throw exceptions.
Implemented in IteratingOperation< Derived >, IteratingOperation< CountedLoop >, ParallelIteratingOperation< Derived >, and ParallelIteratingOperation< CountedLoop >.
|
protectedpure virtual |
workspaceToExecute | The template workspace of which to execute an iteration. This will be provided as 'null' if the derived class does not ensure that setWorkspaceToExecute() is invoked prior to execution. This may or may not be an error for the specific workspace involved. |
Initialises the loop prior to execution of any iterations.
Implemented in IteratingOperation< Derived >, IteratingOperation< CountedLoop >, ParallelIteratingOperation< Derived >, and ParallelIteratingOperation< CountedLoop >.
|
protectedvirtual |
Invoked immediately following the successful execution of an iteration. Default implementation does nothing, returning true.
Reimplemented in ParallelIteratingOperation< Derived >, and ParallelIteratingOperation< CountedLoop >.
|
protectedpure virtual |
Invoked immediately prior to the commencement of any iterations. If 'wrap' is enabled, this will be invoked prior to each set of iterations.
Implemented in IteratingOperation< Derived >, IteratingOperation< CountedLoop >, ParallelIteratingOperation< Derived >, and ParallelIteratingOperation< CountedLoop >.
|
protectedvirtual |
Sets the non-iteration-control inputs to not-up-to-date at the beginning of each iteration. Derived classes must override this and may choose to not avail of the functionality or perform it differently depending on the need of the specific derived class.
Invoked immediately following preIterations(). Default implementation does nothing. Override if needed.
Reimplemented in IteratingOperation< Derived >, IteratingOperation< CountedLoop >, ParallelIteratingOperation< Derived >, and ParallelIteratingOperation< CountedLoop >.
|
protected |
workspace | The workspace that this iterator should execute repeatedly. Can be null if the derived class supports executing sub-setions of a workflow. |
|
protectedpure virtual |
Forces derived classes to specify how the iteration's input values are updated for each iteration of the loop. For most operations, this will be as simple as assigning a value to an input or an output (for operation-based iterators) and then flipping its up-to-date status to false, then back to true.
For example, in the counted loop:
*outputCounterValue_ = counterValue; outputCounterValue_.setUpToDate(false); outputCounterValue_.setUpToDate(true);
Implemented in CountedLoop, IteratingOperation< Derived >, and IteratingOperation< CountedLoop >.
|
protectedpure virtual |
Updates its parent operation's progress at the start of each iteration. Derived classes must override this to specify how progress is indicated, as it will change depending on how iteration is computed.
Implemented in ParallelIteratingOperation< Derived >, and ParallelIteratingOperation< CountedLoop >.
|
protected |
|
protected |