Workspace 6.21.5
Protected Member Functions | Protected Attributes | List of all members
IteratingOperation< Derived > Class Template Reference

#include <Workspace/DataExecution/Operations/Builtin/iteratingoperation.h>

Inheritance diagram for IteratingOperation< Derived >:
[legend]

Protected Member Functions

 IteratingOperation ()
 
 ~IteratingOperation () override
 
virtual bool bringInputsUpToDateImpl ()
 
virtual bool executeImpl ()
 
virtual bool isIterationControlInput (const Input &input) const
 
void performCleanup (Workspace *workspaceToExecute, bool forceStop) override
 
bool performInitialisation (Workspace *workspaceToExecute) override
 
bool preIterations () override
 
virtual void setInputNotUpToDateImpl (InputScalar &input)
 
void setNonIterationControlInputsNotUpToDate () override
 
void terminateExecution ()
 
bool updateInputsForIteration () override
 
- Protected Member Functions inherited from IteratingOperationBase
virtual bool atEndCondition ()=0
 
virtual ExecutionResult executeIteration (Workspace *workspaceToExecute) noexcept(false)=0
 
WorkspacegetWorkspaceToExecute ()
 
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

SimpleInput< bool > enableLoop_
 
SimpleInput< bool > wrap_
 
- Protected Attributes inherited from IteratingOperationBase
bool executing_
 
bool reset_
 

Additional Inherited Members

- Public Types inherited from IteratingOperationBase
enum  ExecutionResult { Abort , Success , Retry }
 Result of an iteration's execution. More...
 
- Public Member Functions inherited from IteratingOperationBase
 IteratingOperationBase ()
 
virtual ~IteratingOperationBase ()=default
 

Constructor & Destructor Documentation

◆ IteratingOperation()

IteratingOperation
protected

◆ ~IteratingOperation()

~IteratingOperation< Derived > ( )
overrideprotecteddefault

Member Function Documentation

◆ bringInputsUpToDateImpl()

bool bringInputsUpToDateImpl
protectedvirtual

Implementation of bringInputsUpToDate. This is needed here because we don't yet know whether or not our class is an operation or workspace type and so we can't simply override it as we usually would.

Returns
true if it was able to bring all inputs up-to-date successfully, false otherwise.

◆ executeImpl()

bool executeImpl
protectedvirtual

Implementation of execute. Defined here so that derived classes can eaisly provide the default implementation. Cannot simply provide execute() method as we don't yet know whether we inherit from Operation or Workspace, so we rely on these classes to invoke this method.

Returns
true if execution completed successfully, false otherwise.

◆ isIterationControlInput()

bool isIterationControlInput ( const Input input) const
protectedvirtual

◆ performCleanup()

void performCleanup ( Workspace workspaceToExecute,
bool  forceStop 
)
overrideprotectedvirtual
Parameters
workspaceToExecuteThe workspace to execute
forceStopWhether or not to force the execution to stop when cleaning up.

Cleanup opportunity following the attempted execution of iterations. Regardless of how the execution terminates (aborted or successful), this method is invoked.

Implements IteratingOperationBase.

Reimplemented in ParallelIteratingOperation< Derived >, and ParallelIteratingOperation< CountedLoop >.

◆ performInitialisation()

bool performInitialisation ( Workspace workspaceToExecute)
overrideprotectedvirtual

Initialisation opportunity prior to executing the iterations. This method is invoked using RAII, so its return value cannot be inspected. Therefore if errors occur, exceptions should be thrown.

Implements IteratingOperationBase.

Reimplemented in ParallelIteratingOperation< Derived >, and ParallelIteratingOperation< CountedLoop >.

◆ preIterations()

bool preIterations ( )
overrideprotectedvirtual

Invoked immediately prior to the commencement of any iterations. If 'wrap' is enabled, this will be invoked prior to each set of iterations.

Returns
false if an error occurs and the loop should be terminated, true otherwise.

Implements IteratingOperationBase.

Reimplemented in ParallelIteratingOperation< Derived >, and ParallelIteratingOperation< CountedLoop >.

◆ setInputNotUpToDateImpl()

void setInputNotUpToDateImpl ( InputScalar input)
protectedvirtual

◆ setNonIterationControlInputsNotUpToDate()

void setNonIterationControlInputsNotUpToDate
overrideprotectedvirtual

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 from IteratingOperationBase.

Reimplemented in ParallelIteratingOperation< Derived >, and ParallelIteratingOperation< CountedLoop >.

◆ terminateExecution()

void terminateExecution
protected

◆ updateInputsForIteration()

bool updateInputsForIteration ( )
overrideprotectedvirtual

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);
Returns
true if the inputs were able to be updated successfully, false otherwise.

Implements IteratingOperationBase.

Member Data Documentation

◆ enableLoop_

SimpleInput<bool> enableLoop_
protected

◆ wrap_

SimpleInput<bool> wrap_
protected