SPH
Public Types | Public Member Functions | List of all members
JobNode Class Reference

Building block of a simulation hierarchy. More...

#include <Node.h>

Inheritance diagram for JobNode:
ShareFromThis< JobNode > INode Polymorphic

Public Types

using Accessor = Function< void(JobNotificationType, const Any &value)>
 
- Public Types inherited from ShareFromThis< JobNode >
using SHARE_FROM_THIS_TAG = void
 

Public Member Functions

 JobNode (AutoPtr< IJob > &&job)
 Creates a new node, given a job object. More...
 
std::string instanceName () const
 Returns the instance name of the job. More...
 
std::string className () const
 Returns the class name of the job. More...
 
VirtualSettings getSettings () const
 Returns settings object allowing to access and modify the state of the job. More...
 
RawPtr< IJobgetJob () const
 Returns the underlying job. More...
 
void addAccessor (const SharedToken &owner, const Accessor &accessor)
 Adds an accessor for entries returned by the getSettings function. More...
 
Optional< ExtJobTypeprovides () const
 Returns the type of the job. More...
 
void connect (SharedPtr< JobNode > dependent, const std::string &slotName)
 Connects this node to given dependent node. More...
 
void disconnect (SharedPtr< JobNode > dependent)
 Disconnects this node from given dependent node. More...
 
void disconnectAll ()
 Disconnects all dependent nodes from this node. More...
 
Size getSlotCnt () const
 Returns the number of provider slots of this node. More...
 
SlotData getSlot (const Size index) const
 Returns the information about given slot. More...
 
Size getDependentCnt () const
 Returns the number of dependent nodes. More...
 
SharedPtr< JobNodegetDependent (const Size index) const
 Returns a dependent node with given index. More...
 
void enumerate (Function< void(const SharedPtr< JobNode > &job)> func)
 Enumerates all nodes in the hierarchy. More...
 
void enumerate (Function< void(const SharedPtr< JobNode > &job, Size depth)> func)
 Enumerates all nodes in the hierarchy. More...
 
virtual void run (const RunSettings &global, IJobCallbacks &callbacks) override
 Evaluates the node and all its providers. More...
 
virtual void prepare (const RunSettings &global, IJobCallbacks &callbacks)
 Evaluates all provides, without executing the node itself. More...
 
- Public Member Functions inherited from ShareFromThis< JobNode >
void setWeakPtr (const WeakPtr< JobNode > &weakPtr)
 
SharedPtr< JobNodesharedFromThis () const
 
WeakPtr< JobNodeweakFromThis () const
 
- Public Member Functions inherited from Polymorphic
virtual ~Polymorphic ()
 

Detailed Description

Building block of a simulation hierarchy.

Each node can have any number of providers (preconditions of the job).

Definition at line 88 of file Node.h.

Member Typedef Documentation

◆ Accessor

using JobNode::Accessor = Function<void(JobNotificationType, const Any& value)>

Definition at line 90 of file Node.h.

Constructor & Destructor Documentation

◆ JobNode()

NAMESPACE_SPH_BEGIN JobNode::JobNode ( AutoPtr< IJob > &&  job)
explicit

Creates a new node, given a job object.

Definition at line 7 of file Node.cpp.

Member Function Documentation

◆ addAccessor()

void JobNode::addAccessor ( const SharedToken owner,
const Accessor accessor 
)

Adds an accessor for entries returned by the getSettings function.

Definition at line 52 of file Node.cpp.

◆ className()

std::string JobNode::className ( ) const

Returns the class name of the job.

Definition at line 10 of file Node.cpp.

◆ connect()

void JobNode::connect ( SharedPtr< JobNode dependent,
const std::string &  slotName 
)

Connects this node to given dependent node.

Parameters
dependentDependent node to which this node is connected.
slotNameName of the slot of the dependent node.
Exceptions
InvalidSetupif no such slot exists or it has a different type.

Definition at line 60 of file Node.cpp.

◆ disconnect()

void JobNode::disconnect ( SharedPtr< JobNode dependent)

Disconnects this node from given dependent node.

Parameters
dependentDependent node to be disconnected.
Exceptions
InvalidSetupif the given node is not a dependent.

Definition at line 90 of file Node.cpp.

◆ disconnectAll()

void JobNode::disconnectAll ( )

Disconnects all dependent nodes from this node.

Definition at line 126 of file Node.cpp.

◆ enumerate() [1/2]

void JobNode::enumerate ( Function< void(const SharedPtr< JobNode > &job)>  func)

Enumerates all nodes in the hierarchy.

Function call provided function for this node and recursively for all providers of this node. Each node is visited only once.

◆ enumerate() [2/2]

void JobNode::enumerate ( Function< void(const SharedPtr< JobNode > &job, Size depth)>  func)

Enumerates all nodes in the hierarchy.

Function call provided function for this node and recursively for all providers of this node. Each node is visited only once.

The function is given the visited job and its depth in the hierarchy.

◆ getDependent()

SharedPtr< JobNode > JobNode::getDependent ( const Size  index) const

Returns a dependent node with given index.

Definition at line 158 of file Node.cpp.

◆ getDependentCnt()

Size JobNode::getDependentCnt ( ) const

Returns the number of dependent nodes.

Definition at line 154 of file Node.cpp.

◆ getJob()

RawPtr< IJob > JobNode::getJob ( ) const

Returns the underlying job.

Definition at line 48 of file Node.cpp.

◆ getSettings()

VirtualSettings JobNode::getSettings ( ) const

Returns settings object allowing to access and modify the state of the job.

Definition at line 39 of file Node.cpp.

◆ getSlot()

SlotData JobNode::getSlot ( const Size  index) const

Returns the information about given slot.

Definition at line 136 of file Node.cpp.

◆ getSlotCnt()

Size JobNode::getSlotCnt ( ) const

Returns the number of provider slots of this node.

Definition at line 132 of file Node.cpp.

◆ instanceName()

std::string JobNode::instanceName ( ) const

Returns the instance name of the job.

Definition at line 14 of file Node.cpp.

◆ prepare()

void JobNode::prepare ( const RunSettings global,
IJobCallbacks callbacks 
)
virtual

Evaluates all provides, without executing the node itself.

This functions does not have to be called before run, as it is called from within run. It is useful for manual execution of jobs.

Definition at line 189 of file Node.cpp.

◆ provides()

Optional< ExtJobType > JobNode::provides ( ) const

Returns the type of the job.

Definition at line 56 of file Node.cpp.

◆ run()

void JobNode::run ( const RunSettings global,
IJobCallbacks callbacks 
)
overridevirtual

Evaluates the node and all its providers.

The job is evaluated after all the providers finished and all inputs of the job have been set up.

Parameters
globalGlobal settings, used by all nodes in the hierarchy.
callbacksInterface allowing to get a feedback from evaluated nodes, see IJobCallbacks.

Implements INode.

Definition at line 184 of file Node.cpp.


The documentation for this class was generated from the following files: