Bifrost SDK
Bifrost SDK documentation
BifrostGraph::Executor::GraphContainer Class Reference

The GraphContainer class that loads a graph to be executed and manages the Jobs that execute this graph. More...

#include <GraphContainer.h>

Classes

struct  SetGraphInfo
 The information that is passed to onBeginSetGraph and onEndSetGraph notification handlers. More...
 

Public Member Functions

virtual ~GraphContainer () noexcept
 Destructor. More...
 
virtual bool isValid () const noexcept
 Check if this GraphContainer has been successfully initialized. More...
 
bool setGraph (const Amino::String &name, SetGraphMode mode=SetGraphMode::kDefault) noexcept
 Set the graph in this GraphContainer. More...
 
Amino::String getGraphName () const noexcept
 Get the name of the graph currently set in this GraphContainer. More...
 
Amino::String getGraphQualifiedName () const noexcept
 Get the fully qualified name of the graph currently set in this GraphContainer. More...
 
GraphCompilationStatus compile (GraphCompilationMode mode) noexcept
 Compile the graph for job execution. More...
 
const WorkspacegetWorkspace () const noexcept
 Access the Workspace which owns this GraphContainer. More...
 
WorkspacegetWorkspace () noexcept
 Access the Workspace which owns this GraphContainer. More...
 
const JobgetJob () const noexcept
 Get a reference to the Job currently set in this GraphContainer. More...
 
JobgetJob () noexcept
 Get a reference to the Job currently set in this GraphContainer. More...
 
const Private::IRestrictedGraphContainerServices & getRestrictedServices () const noexcept
 Obtain an interface giving access to private GraphContainer services. More...
 
Private::IRestrictedGraphContainerServices & getRestrictedServices () noexcept
 Obtain an interface giving access to private GraphContainer services. More...
 

Static Public Member Functions

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

Protected Member Functions

 GraphContainer (Private::IGraphContainerOwner &owner) noexcept
 Construct a GraphContainer. The new GraphContainer is owned and managed by the Workspace. More...
 
 GraphContainer (Uninitialized uninitialized) noexcept
 Constructor that leaves the GraphContainer in an uninitialized state. More...
 
 EXECUTOR_DECLARE_MAKE_OWNER_FRIENDSHIP ()
 Allow the makeOwner<> factory functions to access the constructors of this class. More...
 
void reportMessage (MessageCategory category, const Amino::String &message) const noexcept
 Report a message from this GraphContainer to its Workspace owner. The source of the reported message will be set to MessageSource::kGraphContainer. More...
 

Private Member Functions

virtual void onBeginSetGraph (const SetGraphInfo &graphInfo) noexcept
 The notification method called by setGraph just before a new graph is set. More...
 
virtual void onEndSetGraph (const SetGraphInfo &graphInfo) noexcept
 The notification method called by setGraph just after a new graph is set. More...
 
virtual void onBeginCompileGraph () noexcept
 The notification method called by compile when the graph is about to be compiled. More...
 
virtual void onEndCompileGraph (GraphCompilationStatus status) noexcept
 The notification method called by compile once the graph has been compiled. More...
 

Friends

class Private::GraphContainerImpl
 

Detailed Description

The GraphContainer class that loads a graph to be executed and manages the Jobs that execute this graph.

Definition at line 54 of file GraphContainer.h.

Constructor & Destructor Documentation

◆ GraphContainer() [1/2]

BifrostGraph::Executor::GraphContainer::GraphContainer ( Private::IGraphContainerOwner &  owner)
explicitprotectednoexcept

Construct a GraphContainer. The new GraphContainer is owned and managed by the Workspace.

If an error occurs during the construction of this GraphContainer then BifrostGraph::Executor::GraphContainer::isValid will return false and all future operations on this GraphContainer will fail. If a class is derived from GraphContainer, it is recommended to keep protected the constructors on the derived class, and still use the factory functions BifrostGraph::Executor::makeOwner (see Factory.h) to create a derived class instance.

Parameters
[in]ownerThe GraphContainer's owner. Only the Workspace can create an IGraphContainerOwner object required by this constructor, hence only the Workspace can initiate the construction of a GraphContainer (see Workspace's addGraphContainer template method).

◆ GraphContainer() [2/2]

BifrostGraph::Executor::GraphContainer::GraphContainer ( Uninitialized  uninitialized)
explicitprotectednoexcept

Constructor that leaves the GraphContainer in an uninitialized state.

After this constructor returns, the method BifrostGraph::Executor::GraphContainer::isValid will return false and all future operations on the GraphContainer will fail.

Parameters
[in]uninitializedan Uninitialized enum value.
Warning
This constructor is used internally by the Executor. Use with caution.

◆ ~GraphContainer()

virtual BifrostGraph::Executor::GraphContainer::~GraphContainer ( )
virtualnoexcept

Destructor.

The destructor should not be called directly since the GraphContainers are managed by the Workspace. To delete a GraphContainer, use the Workspace's method Workspace::deleteGraphContainer.

Member Function Documentation

◆ compile()

GraphCompilationStatus BifrostGraph::Executor::GraphContainer::compile ( GraphCompilationMode  mode)
noexcept

Compile the graph for job execution.

The onBeginCompileGraph and onEndCompileGraph notification handlers will be called respectively just before and after compiling the graph of this GraphContainer, allowing a class derived from GraphContainer to do any additional work it may need to do when the graph is compiled.

Parameters
[in]modeThe mode on how to compile the graph (i.e. full compile or update), (see GraphCompilationMode).
Returns
The graph compilation status (see GraphCompilationStatus).
Note
When the graph is compiled, whatever is the specified mode, the inputs and outputs of the associated Job are updated. This implies that the Job input values must be set again (see Job::getInputs and Job::setInputValue) and the Job must be executed again (see Job::execute) in order to retrieve the Job output values (see Job::getOutputs and Job::getOutputValue).

◆ EXECUTOR_DECLARE_MAKE_OWNER_FRIENDSHIP()

BifrostGraph::Executor::GraphContainer::EXECUTOR_DECLARE_MAKE_OWNER_FRIENDSHIP ( )
protected

Allow the makeOwner<> factory functions to access the constructors of this class.

◆ getGraphName()

Amino::String BifrostGraph::Executor::GraphContainer::getGraphName ( ) const
noexcept

Get the name of the graph currently set in this GraphContainer.

Returns
The name of the currently set graph, if any, an empty string otherwise.

◆ getGraphQualifiedName()

Amino::String BifrostGraph::Executor::GraphContainer::getGraphQualifiedName ( ) const
noexcept

Get the fully qualified name of the graph currently set in this GraphContainer.

Returns
The fully qualified name of the currently set graph, if any, an empty string otherwise.

◆ getInvalid()

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

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

Referenced by BifrostGraph::Executor::Workspace::addGraphContainerT().

◆ getJob() [1/2]

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

Get a reference to the Job currently set in this GraphContainer.

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

◆ getJob() [2/2]

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

Get a reference to the Job currently set in this GraphContainer.

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

◆ getRestrictedServices() [1/2]

const Private::IRestrictedGraphContainerServices & BifrostGraph::Executor::GraphContainer::getRestrictedServices ( ) const
noexcept

Obtain an interface giving access to private GraphContainer services.

Precondition
This GraphContainer must be valid (BifrostGraph::Executor::GraphContainer::isValid). Calling this method on an invalid GraphContainer will produce undefined behavior.
Note
This is an internal method used by the Executor SDK.
Returns
A reference to the IRestrictedGraphContainerServices interface of this GraphContainer.

◆ getRestrictedServices() [2/2]

Private::IRestrictedGraphContainerServices & BifrostGraph::Executor::GraphContainer::getRestrictedServices ( )
noexcept

Obtain an interface giving access to private GraphContainer services.

Precondition
This GraphContainer must be valid (BifrostGraph::Executor::GraphContainer::isValid). Calling this method on an invalid GraphContainer will produce undefined behavior.
Note
This is an internal method used by the Executor SDK.
Returns
A reference to the IRestrictedGraphContainerServices interface of this GraphContainer.

◆ getWorkspace() [1/2]

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

Access the Workspace which owns this GraphContainer.

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

◆ getWorkspace() [2/2]

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

Access the Workspace which owns this GraphContainer.

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

◆ isValid()

virtual bool BifrostGraph::Executor::GraphContainer::isValid ( ) const
virtualnoexcept

Check if this GraphContainer has been successfully initialized.

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

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

◆ onBeginCompileGraph()

virtual void BifrostGraph::Executor::GraphContainer::onBeginCompileGraph ( )
privatevirtualnoexcept

The notification method called by compile when the graph is about to be compiled.

Note
The default implementation does nothing.

◆ onBeginSetGraph()

virtual void BifrostGraph::Executor::GraphContainer::onBeginSetGraph ( const SetGraphInfo graphInfo)
privatevirtualnoexcept

The notification method called by setGraph just before a new graph is set.

When this method is called, the previously set graph, if any, is still set in this GraphContainer. If the setGraph's mode parameter was SetGraphMode::kCopy and the attempt to copy the existing graph fails, then this notification method will not be called.

Parameters
[in]graphInfoThe information about the graph that is about to be set.
Note
The default implementation does nothing.

◆ onEndCompileGraph()

virtual void BifrostGraph::Executor::GraphContainer::onEndCompileGraph ( GraphCompilationStatus  status)
privatevirtualnoexcept

The notification method called by compile once the graph has been compiled.

Parameters
[in]statusThe status of the compile operation.
Note
The default implementation does nothing.

◆ onEndSetGraph()

virtual void BifrostGraph::Executor::GraphContainer::onEndSetGraph ( const SetGraphInfo graphInfo)
privatevirtualnoexcept

The notification method called by setGraph just after a new graph is set.

If the setGraph's mode parameter was SetGraphMode::kCopy and the attempt to copy the existing graph fails, then this notification method will not be called.

Parameters
[in]graphInfoThe information about the graph that has just been set.
Note
The default implementation does nothing.

◆ reportMessage()

void BifrostGraph::Executor::GraphContainer::reportMessage ( MessageCategory  category,
const Amino::String message 
) const
protectednoexcept

Report a message from this GraphContainer to its Workspace owner. The source of the reported message will be set to MessageSource::kGraphContainer.

Parameters
[in]categoryThe message category.
[in]messageThe message itself.

◆ setGraph()

bool BifrostGraph::Executor::GraphContainer::setGraph ( const Amino::String name,
SetGraphMode  mode = SetGraphMode::kDefault 
)
noexcept

Set the graph in this GraphContainer.

The definition of the graph designated by name must have been previously loaded in the Library (see Workspace::loadConfigFiles or Library::loadDefinitionFile).

If mode is SetGraphMode::kCopy, the copy of the graph will have a new unique fully qualified name to avoid name collisions (see GraphContainer::SetGraphInfo).

If the graph does not exist in the Library, or if the mode is SetGraphMode::kCopy and the attempt to copy the existing graph fails, then this method aborts and does not set the graph. Otherwise, the onBeginSetGraph and onEndSetGraph notification handlers will be called respectively just before and after setting the graph in this GraphContainer, allowing a class derived from GraphContainer to do any additional work it may need to do when the graph is set or replaced by another one.

Parameters
[in]nameThe fully qualified name of the graph to be set.
[in]modeThe mode controlling the behavior of setGraph.
Returns
true if the graph exists and has been successfully copied (if required) and set in this GraphContainer; false otherwise.

Friends And Related Function Documentation

◆ Private::GraphContainerImpl

friend class Private::GraphContainerImpl
friend

Definition at line 220 of file GraphContainer.h.