Workspace 6.21.5
Classes | Public Types | Signals | Public Member Functions | Static Public Member Functions | Protected Slots | Protected Member Functions | Static Protected Member Functions | List of all members
OperationRunner Class Reference

Runs an operation or workspace. The OperationRunner can be used to run a workspace or operation. To use simply construct the with a path to a workspace file, existing workspace or operation. WARNING: If your client code decides to perform its own wait logic then use the OperationRunner isRunning method and not the isRunning method on your provided Workspace.

#include <Workspace/DataExecution/Execution/operationrunner.h>

Inherits QObject.

Classes

struct  OperationRunnerDeleter
 

Public Types

using unique_ptr = std::unique_ptr< OperationRunner, OperationRunnerDeleter >
 

Signals

void errorReported ()
 
void failed ()
 
void finished (bool success)
 
void succeeded ()
 

Public Member Functions

 OperationRunner ()=delete
 
 OperationRunner (const OperationFactory &)
 
 OperationRunner (const OperationRunner &)=delete
 
 OperationRunner (const QString &workspacePath)
 
 OperationRunner (Workspace &workspace)
 
 ~OperationRunner () override
 
IOBasegetGlobalNameIOBase (const QString &globalName)
 
template<typename T >
T & getGlobalNameValue (const QString &globalName)
 
InputScalargetInput (const QString &inputName, int index=0)
 
InputArraygetInputArray (const QString &inputName)
 
template<typename T >
T & getInputValue (const QString &inputName, int index=0)
 
OperationgetOperation ()
 
template<typename O >
O * getOperation ()
 
OutputgetOutput (const QString &outputName)
 
template<typename T >
T & getOutputValue (const QString &outputName)
 
UpdatergetUpdater ()
 
WorkspacegetWorkspace ()
 
bool hasInput (const QString &inputName, int index=0)
 
bool hasSucceeded () const
 
bool isLoaded () const
 
bool isRunning ()
 
OperationRunneroperator= (const OperationRunner &)=delete
 
bool runContinuously ()
 
bool runOnce ()
 
bool runOnceAndWait ()
 
void setGlobalNameDataObject (const QString &globalName, const DataObject &dataObject)
 
template<typename T >
void setGlobalNameValue (const QString &globalName, const T &value)
 
template<typename T >
void setGlobalNameValueByReference (const QString &globalName, T &value)
 
template<typename T >
void setInputValue (const QString &inputName, const T &value, int index=0)
 
template<typename T >
void setInputValueByReference (const QString &inputName, T &value, int index=0)
 
void stop ()
 
void stopAndWait ()
 
template<typename F >
UpdatablesObserver< F > * watchUpdatable (F callable, Updatable &updatable, ObserverThreadType threadingModel=UnthreadedObserver, bool singleShot=true)
 
template<typename ReceiverType , typename ReturnType >
UpdatablesMonitor< ReceiverType, ReturnType > * watchUpdatable (ReceiverType &receiver, ReturnType(ReceiverType::*func)(), Updatable &updatable, ObserverThreadType threadingModel=UnthreadedObserver, bool singleShot=true)
 
template<typename F >
UpdatablesObserver< F > * watchUpdatables (F callable, Updatables &updatables, ObserverThreadType threadingModel=UnthreadedObserver, bool singleShot=true)
 
template<typename ReceiverType , typename ReturnType >
UpdatablesMonitor< ReceiverType, ReturnType > * watchUpdatables (ReceiverType &receiver, ReturnType(ReceiverType::*func)(), Updatables &updatables, ObserverThreadType threadingModel=UnthreadedObserver, bool singleShot=true)
 

Static Public Member Functions

template<typename T >
static unique_ptr create ()
 
static unique_ptr create (const OperationFactory &)
 
static unique_ptr create (const QString &workspacePath)
 
static unique_ptr create (Workspace &workspace)
 

Protected Slots

void onAborted (QString, bool hasErrorSource)
 
void onFinished (QString)
 
void onSucceeded (QString)
 

Protected Member Functions

void observe (Workspace &)
 
void reset ()
 
template<typename T >
void setInputByReference (InputScalar &input, T &value)
 

Static Protected Member Functions

static void setInputValue (InputScalar &input, const DataObject &dataObject)
 
template<typename T >
static void setInputValue (InputScalar &input, const T &value)
 

Member Typedef Documentation

◆ unique_ptr

Constructor & Destructor Documentation

◆ OperationRunner() [1/5]

OperationRunner ( const QString &  workspacePath)
explicit

forward to internl call

◆ OperationRunner() [2/5]

OperationRunner ( Workspace workspace)
explicit

forward to internl call

◆ OperationRunner() [3/5]

OperationRunner ( const OperationFactory factory)
explicit

forward to internl call

◆ OperationRunner() [4/5]

OperationRunner ( )
delete

◆ OperationRunner() [5/5]

OperationRunner ( const OperationRunner )
delete

◆ ~OperationRunner()

~OperationRunner ( )
override

OperationRunner destructor.

Member Function Documentation

◆ create() [1/4]

Convenience template to create an OperationRunner for a specific Operation type

◆ create() [2/4]

OperationRunner::unique_ptr create ( const OperationFactory factory)
static

Handy creator method to help creating the OperationRunner on the right thread.

See also
OperationRunner::OperationRunner(const OperationFactory& factory)

◆ create() [3/4]

OperationRunner::unique_ptr create ( const QString &  workspacePath)
static

Handy creator method to help creating the OperationRunner on the right thread.

See also
OperationRunner::OperationRunner(const QString& workspacePath)

◆ create() [4/4]

OperationRunner::unique_ptr create ( Workspace workspace)
static

Handy creator method to help creating the OperationRunner on the right thread.

See also
OperationRunner::OperationRunner(Workspace& workspace)

◆ errorReported

void errorReported ( )
signal

◆ failed

void failed ( )
signal

◆ finished

void finished ( bool  success)
signal

◆ getGlobalNameIOBase()

IOBase * getGlobalNameIOBase ( const QString &  globalName)

Gets an IOBase that has the named globalName attached to it.

◆ getGlobalNameValue()

T & getGlobalNameValue ( const QString &  globalName)

Returns the value associated with the provided globalname on an input / output.

See also
Workspace::getGlobalNameValue
Exceptions
InvalidIONameError

◆ getInput()

InputScalar * getInput ( const QString &  inputName,
int  index = 0 
)

Returns an input on the workspace or operation to be run.

See also
Operation::setInput
Exceptions
InvalidIONameError

◆ getInputArray()

InputArray * getInputArray ( const QString &  inputName)

Returns an InputArray on the workspace or operation to be run.

Exceptions
InvalidIONameError

◆ getInputValue()

T & getInputValue ( const QString &  inputName,
int  index = 0 
)

Returns the value associated with the provided input.

See also
InputScalar::getRawData()
Exceptions
InvalidIONameError

◆ getOperation() [1/2]

Operation * getOperation ( )

Returns a pointer to the workspace or operation provided to the OperationRunner.

◆ getOperation() [2/2]

O * getOperation

◆ getOutput()

Output * getOutput ( const QString &  outputName)

Gets an output on the operation or workspace to be run.

See also
Operation::getOutput
Exceptions
InvalidIONameError

◆ getOutputValue()

T & getOutputValue ( const QString &  outputName)
inline

Gets an output value on the operation or workspace to be run.

See also
Operation::getOutput
Exceptions
InvalidIONameError

◆ getUpdater()

Updater * getUpdater ( )

◆ getWorkspace()

Workspace * getWorkspace ( )

Returns a pointer to the root workspace being used by the OperationRunner.

◆ hasInput()

bool hasInput ( const QString &  inputName,
int  index = 0 
)
Parameters
inputNameThe name of the input
indexIf the input is an array, the index being queried
Returns
True if the input exists

◆ hasSucceeded()

bool hasSucceeded ( ) const

Returns true if the workflow has been executed successfully, false otherwise

◆ isLoaded()

bool isLoaded ( ) const

Returns true if the provided workspace (or workspace that hosts a provided operation) has been successfuly loaded / constructed.

◆ isRunning()

bool isRunning ( )

Returns true if the OperationRunner is running.

◆ observe()

void observe ( Workspace workspace)
protected

◆ onAborted

void onAborted ( QString  uuid,
bool  hasErrorSource 
)
protectedslot

◆ onFinished

void onFinished ( QString  uuid)
protectedslot

◆ onSucceeded

void onSucceeded ( QString  uuid)
protectedslot

◆ operator=()

OperationRunner & operator= ( const OperationRunner )
delete

◆ reset()

void reset ( )
protected

◆ runContinuously()

bool runContinuously ( )

Runs the operation continuously in a non-blocking fashion.

◆ runOnce()

bool runOnce ( )

Runs the operation once in a non-blocking fashion.

◆ runOnceAndWait()

bool runOnceAndWait ( )

Performs a single update of the operation in a blocking fashion and returns true if the operation ran successfully or false if it failed.

◆ setGlobalNameDataObject()

void setGlobalNameDataObject ( const QString &  globalName,
const DataObject dataObject 
)
inline

Assigns a DataObject to a globally named InputScalar. The InputScalar's DataObject factory must match the new DataObject's factory.

See also
Workspace::setGlobalNameValue
Exceptions
InvalidIONameError

◆ setGlobalNameValue()

void setGlobalNameValue ( const QString &  globalName,
const T &  value 
)
inline

Sets a global name value on the workspace to be run.

See also
Workspace::setGlobalNameValue
Exceptions
InvalidIONameError

◆ setGlobalNameValueByReference()

void setGlobalNameValueByReference ( const QString &  globalName,
T &  value 
)
inline

Sets a global name value on the workspace to be run.

See also
Workspace::setGlobalNameValue
Exceptions
InvalidIONameError
Precondition
Workspace must not be running

◆ setInputByReference()

void setInputByReference ( InputScalar input,
T &  value 
)
protected
Parameters
inputReference to the input to modify.
valueReference to the data to assign (by reference) to the input. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Setting any input by reference requires the Workspace to be stopped so the status flip can happen immediately. If the flip was delayed the input would clear the new shared data when it is later set out of date.

◆ setInputValue() [1/3]

void setInputValue ( const QString &  inputName,
const T &  value,
int  index = 0 
)

Sets an input value on the operation or workspace to be run.

See also
Operation::setInput
Exceptions
InvalidIONameError

◆ setInputValue() [2/3]

void setInputValue ( InputScalar input,
const DataObject dataObject 
)
inlinestaticprotected

◆ setInputValue() [3/3]

void setInputValue ( InputScalar input,
const T &  value 
)
inlinestaticprotected

◆ setInputValueByReference()

void setInputValueByReference ( const QString &  inputName,
T &  value,
int  index = 0 
)

Sets an input value on the operation or workspace by reference.

See also
Operation::setInput
Exceptions
InvalidIONameError

◆ stop()

void stop ( )

Stops the operation asynchronously.

◆ stopAndWait()

void stopAndWait ( )

Requests to stop the operation, blocking until it has finished running.

◆ succeeded

void succeeded ( )
signal

◆ watchUpdatable() [1/2]

UpdatablesObserver< F > * watchUpdatable ( callable,
Updatable updatable,
ObserverThreadType  threadingModel = UnthreadedObserver,
bool  singleShot = true 
)
inline

A convenience function that calls the function func when the Updatable object provided is simultaneously up-to-date.

Parameters
callableA callable object or function to invoke in response to the updatables being brought up-to-date.
updatableAn updatable object to observe.
threadingModelThe threading model to use for the receiver callback.
singleShotWhether or not the created observer should delete itself once the callback occurs. If false is provided, it is up to the calling code to delete the observer at a safe and appropriate time.

Watches an Updatable, invoking the provided function callable when the Updatable is brought into an up-to-date state.

Returns
In the case where singleShot=false, the function will return the UpdatablesObserver object that is monitoring the specified updatable. It is the responsibility of the caller to make sure the monitor is deleted after the attached workspace is stopped. If singleShot=true, the function returns nullptr.
Note
This supercedes the existing UpdatablesMonitor version of watchUpdatables which required a member function pointer to be specified. To upgrade old code, use std::bind() to pass the member function pointer as the func parameter: ``` auto observer = watchUpdatables(std::bind(func, this), updatable, ThreadedObserver, false); ```

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ watchUpdatable() [2/2]

UpdatablesMonitor< ReceiverType, ReturnType > * watchUpdatable ( ReceiverType &  receiver,
ReturnType(ReceiverType::*)()  func,
Updatable updatable,
ObserverThreadType  threadingModel = UnthreadedObserver,
bool  singleShot = true 
)
inline
Parameters
receiverThe receiver of the callback
funcThe address of the function to callback on the receiver
updatableAn Updatable object to watch
threadingModelThe threading model in which the receiver will be called back
singleShotWhether or not the monitor will be invoked only the first time the updatables are brought up-to-date.
Returns
if singleShot=false, the function will return the UpdatablesMonitor object that is monitoring the specified updatables. In this case, It is the responsibility of the caller to make sure the monitor is deleted after the attached workspace is stopped. If singleShot=true, the function returns zero.

Registers a callback function to be invoked when a provided Updatable object is up-to-date. The callback can be invoked only once (singleShot=true) or every time the updatable is brought up-to-date (singleShot=false).

See also
watchUpdatable

◆ watchUpdatables() [1/2]

UpdatablesObserver< F > * watchUpdatables ( callable,
Updatables updatables,
ObserverThreadType  threadingModel = UnthreadedObserver,
bool  singleShot = true 
)
inline

A convenience function that calls the function func when all Updatable objects provided are simultaneously up-to-date.

Parameters
callableA callable object or function to invoke in response to the updatables being brought up-to-date.
updatablesAn updatable object to observe.
threadingModelThe threading model to use for the receiver callback.
singleShotWhether or not the created observer should delete itself once the callback occurs. If false is provided, it is up to the calling code to delete the observer at a safe and appropriate time.

Watches a set of Updatables, invoking the provided function callable when all of the Updatables are brought into an up-to-date state.

Returns
In the case where singleShot=false, the function will return the UpdatablesObserver object that is monitoring the specified updatables. It is the responsibility of the caller to make sure the monitor is deleted after the attached workspace is stopped. If singleShot=true, the function returns nullptr.
Note
This supercedes the existing UpdatablesMonitor version of watchUpdatables which required a member function pointer to be specified. To upgrade old code, use std::bind() to pass the member function pointer as the func parameter: ``` auto observer = watchUpdatables(std::bind(func, this), updatable, ThreadedObserver, false); ```

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ watchUpdatables() [2/2]

UpdatablesMonitor< ReceiverType, ReturnType > * watchUpdatables ( ReceiverType &  receiver,
ReturnType(ReceiverType::*)()  func,
Updatables updatables,
ObserverThreadType  threadingModel = UnthreadedObserver,
bool  singleShot = true 
)
inline
Parameters
receiverThe receiver of the callback
funcThe address of the function to callback on the receiver
updatablesA set of updatable objects to watch
threadingModelThe threading model in which the receiver will be called back
singleShotWhether or not the monitor will be invoked only the first time the updatables are brought up-to-date.
Returns
if singleShot=false, the function will return the UpdatablesMonitor object that is monitoring the specified updatables. In this case, It is the responsibility of the caller to make sure the monitor is deleted after the attached workspace is stopped. If singleShot=true, the function returns zero.

Registers a callback function to be invoked when all provided Updatable objects are up to date. The callback can be invoked only once (singleShot=true) or every time the updatables are brought up-to-date (singleShot=false).

See also
watchUpdatables