Bifrost SDK
Bifrost SDK documentation
BifrostGraph::Executor::Job Class Referencefinal

The Job class that executes a graph with inputs/outputs coming/going from/to host. More...

#include <Job.h>

Classes

struct  Input
 A Job input descriptor. More...
 
struct  Output
 A Job output descriptor. More...
 
struct  TerminalState
 A Job Terminal State descriptor. More...
 

Public Types

using Inputs = Amino::Array< Input >
 A collection of Job inputs. More...
 
using Outputs = Amino::Array< Output >
 A collection of Job outputs. More...
 
using TerminalStates = Amino::Array< TerminalState >
 A collection of Job Terminal States. More...
 

Public Member Functions

 ~Job () noexcept
 Destructor. More...
 
bool isValid () const noexcept
 Check if this Job has been successfully initialized. More...
 
void enableRuntimeLogging (bool enable) noexcept
 Set whether runtime logging should be enabled when executing the job. During a job execution, some operators may report messages to the Amino::RuntimeServices. If the runtime logging is disabled, those messages will not be reported to the Workspace. More...
 
bool isRuntimeLoggingEnabled () const noexcept
 Query whether or not runtime logging is enabled when executing the job. More...
 
const InputsgetInputs () const noexcept
 Get the Job inputs. More...
 
bool setInputValue (const Input &input, const TypeTranslation::ValueData *valueData) noexcept
 Set the given Job input value. More...
 
JobExecutionStatus execute (JobExecutionMode mode=JobExecutionMode::kDefault) noexcept
 Execute the job with current inputs. More...
 
const OutputsgetOutputs () const noexcept
 Get the Job outputs. More...
 
bool getOutputValue (const Output &output, TypeTranslation::ValueData *valueData) const noexcept
 Retrieve the given Job output value. More...
 
bool setTerminalStates (const TerminalStates &terminalStates) noexcept
 Set the terminal states. More...
 
const GraphContainergetGraphContainer () const noexcept
 Access the GraphContainer which owns this Job. More...
 
GraphContainergetGraphContainer () noexcept
 Access the GraphContainer which owns this Job. More...
 
const WorkspacegetWorkspace () const noexcept
 Access this Job's Workspace ancestor, i.e. the one that owns the GraphContainer associated with this Job. More...
 
WorkspacegetWorkspace () noexcept
 Access this Job's Workspace ancestor, i.e. the one that owns the GraphContainer associated with this Job. More...
 
const Private::IRestrictedJobServices & getRestrictedServices () const noexcept
 Obtain an interface giving access to private Job services. More...
 
Private::IRestrictedJobServices & getRestrictedServices () noexcept
 Obtain an interface giving access to private Job services. More...
 

Static Public Member Functions

static JobgetInvalid () noexcept
 Get a statically allocated Job that is uninitialized, invalid and not owned by any GraphContainer. Any operation on this instance will always fail and Job::isValid will return false. More...
 

Detailed Description

The Job class that executes a graph with inputs/outputs coming/going from/to host.

Definition at line 52 of file Job.h.

Member Typedef Documentation

◆ Inputs

A collection of Job inputs.

Definition at line 62 of file Job.h.

◆ Outputs

A collection of Job outputs.

Definition at line 72 of file Job.h.

◆ TerminalStates

A collection of Job Terminal States.

Definition at line 80 of file Job.h.

Constructor & Destructor Documentation

◆ ~Job()

BifrostGraph::Executor::Job::~Job ( )
noexcept

Destructor.

The destructor should not be called directly since a Job is managed by the GraphContainer.

Member Function Documentation

◆ enableRuntimeLogging()

void BifrostGraph::Executor::Job::enableRuntimeLogging ( bool  enable)
noexcept

Set whether runtime logging should be enabled when executing the job. During a job execution, some operators may report messages to the Amino::RuntimeServices. If the runtime logging is disabled, those messages will not be reported to the Workspace.

Parameters
[in]enableThe desired state of runtime logging.

◆ execute()

JobExecutionStatus BifrostGraph::Executor::Job::execute ( JobExecutionMode  mode = JobExecutionMode::kDefault)
noexcept

Execute the job with current inputs.

Each Job input value is consumed by the execution and needs to be set prior to the next execution (see Job::getInputs and Job::setInputValue).

Parameters
[in]modeThe mode on how to execute the job (see JobExecutionMode).
Returns
The job execution status (see JobExecutionStatus).
Note
The GraphContainer needs to be compiled (see GraphContainer::compile) for the job to be executable.
Warning
If the Job is executed asynchronously (for example, calling execute from a separate thread), no changes may be made to the GraphContainer that owns this Job while this execution is taking place (e.g. no change like a call to GraphContainer::setGraph, to Workspace::deleteGraphContainer, or even deleting the Workspace that owns the GraphContainer).

◆ getGraphContainer() [1/2]

const GraphContainer & BifrostGraph::Executor::Job::getGraphContainer ( ) const
noexcept

Access the GraphContainer which owns this Job.

Returns
A reference to the GraphContainer which owns this Job, if this instance is valid (see BifrostGraph::Executor::Job::isValid); an invalid GraphContainer otherwise.

◆ getGraphContainer() [2/2]

GraphContainer & BifrostGraph::Executor::Job::getGraphContainer ( )
noexcept

Access the GraphContainer which owns this Job.

Returns
A reference to the GraphContainer which owns this Job, if this instance is valid (see BifrostGraph::Executor::Job::isValid); an invalid GraphContainer otherwise.

◆ getInputs()

const Inputs & BifrostGraph::Executor::Job::getInputs ( ) const
noexcept

Get the Job inputs.

For each Job input, its value can be set using Job::setInputValue, and then the graph can be executed using Job::execute.

Returns
A collection of inputs.
Note
The GraphContainer needs to be compiled (see GraphContainer::compile) for the inputs to be valid, and they will remain valid until another graph is set (see GraphContainer::setGraph) or until the next compilation.

◆ getInvalid()

static Job & BifrostGraph::Executor::Job::getInvalid ( )
staticnoexcept

Get a statically allocated Job that is uninitialized, invalid and not owned by any GraphContainer. Any operation on this instance will always fail and Job::isValid will return false.

◆ getOutputs()

const Outputs & BifrostGraph::Executor::Job::getOutputs ( ) const
noexcept

Get the Job outputs.

Once the graph has been compiled, and the Job input values have been set (see Job::getInputs and Job::setInputValue), and the Job has been executed (see Job::execute), then the value of each Job output can be retrieved using Job::getOutputValue.

Returns
A collection of outputs.
Note
The GraphContainer needs to be compiled (see GraphContainer::compile) for the outputs to be valid, and they will remain valid until another graph is set (see GraphContainer::setGraph) or until the next compilation.

◆ getOutputValue()

bool BifrostGraph::Executor::Job::getOutputValue ( const Output output,
TypeTranslation::ValueData valueData 
) const
noexcept

Retrieve the given Job output value.

This method allows one to retrieve the value of a Job output obtained from Job::getOutputs.

When a Job output value is retrieved, it is converted to a host data by calling TypeTranslation::convertValueToHost on the TypeTranslation shared library that has been registered for the type of this output.

Parameters
[in]outputThe Job output.
[in,out]valueDataThe host data that will be passed to TypeTranslation::convertValueToHost.
Returns
true if the output has been successfully retrieved; false otherwise.

◆ getRestrictedServices() [1/2]

const Private::IRestrictedJobServices & BifrostGraph::Executor::Job::getRestrictedServices ( ) const
noexcept

Obtain an interface giving access to private Job services.

Precondition
This Job must be valid (BifrostGraph::Executor::Job::isValid).
Returns
A reference to the IRestrictedJobServices interface of this Job.

◆ getRestrictedServices() [2/2]

Private::IRestrictedJobServices & BifrostGraph::Executor::Job::getRestrictedServices ( )
noexcept

Obtain an interface giving access to private Job services.

Precondition
This Job must be valid (BifrostGraph::Executor::Job::isValid).
Returns
A reference to the IRestrictedJobServices interface of this Job.

◆ getWorkspace() [1/2]

const Workspace & BifrostGraph::Executor::Job::getWorkspace ( ) const
noexcept

Access this Job's Workspace ancestor, i.e. the one that owns the GraphContainer associated with this Job.

Returns
A reference to the Workspace ancestor of this Job, if this instance is valid (see BifrostGraph::Executor::Job::isValid); an invalid Workspace otherwise.

◆ getWorkspace() [2/2]

Workspace & BifrostGraph::Executor::Job::getWorkspace ( )
noexcept

Access this Job's Workspace ancestor, i.e. the one that owns the GraphContainer associated with this Job.

Returns
A reference to the Workspace ancestor of this Job, if this instance is valid (see BifrostGraph::Executor::Job::isValid); an invalid Workspace otherwise.

◆ isRuntimeLoggingEnabled()

bool BifrostGraph::Executor::Job::isRuntimeLoggingEnabled ( ) const
noexcept

Query whether or not runtime logging is enabled when executing the job.

Returns
true if runtime logging is enabled; false otherwise.
See also
enableRuntimeLogging

◆ isValid()

bool BifrostGraph::Executor::Job::isValid ( ) const
noexcept

Check if this Job has been successfully initialized.

If an error occurs during the construction of a Job, isValid() will return false and all future operations on the Job will fail.

Returns
true if this Job has been successfully initialized and is ready to be used; false otherwise.

◆ setInputValue()

bool BifrostGraph::Executor::Job::setInputValue ( const Input input,
const TypeTranslation::ValueData valueData 
)
noexcept

Set the given Job input value.

This method allows one to manually set the value of a Job input obtained from Job::getInputs.

When a Job input value is set, it is converted from a host data by calling TypeTranslation::convertValueFromHost on the TypeTranslation shared library that has been registered for the type of this input.

If a Job input value is not manually set before Job::execute is called, its default value (coming from the graph, if any) will be used (see Job::Input::defaultValue).

Parameters
[in]inputThe Job input.
[in]valueDataThe host data that will be passed to TypeTranslation::convertValueFromHost.
Returns
true if the input has been successfully set; false otherwise.

◆ setTerminalStates()

bool BifrostGraph::Executor::Job::setTerminalStates ( const TerminalStates terminalStates)
noexcept

Set the terminal states.

Terminals can be explicitly deactivated at the job level.

Parameters
[in]terminalStatesList of terminals that should be activated or deactivated at the job level.