Loading...
Searching...
No Matches
VdfSparseInputTraverser Class Reference

A class used for fast sparse traversals of VdfNetworks in the output-to-input direction. More...

#include <sparseInputTraverser.h>

Public Types

enum  CallbackMode { CallbackModeAllNodes , CallbackModeTerminalNodes }
 Callback mode for the node callback. More...
 

Basic Traversal

using NodeCallback = std::function< bool(const VdfNode &)>
 Callback used when traversing a network.
 
using ConnectionCallback = std::function< bool(const VdfConnection &, const VdfMask &)>
 Callback used when traversing a network.
 
static VDF_API void Traverse (const VdfMaskedOutputVector &outputs, const NodeCallback &nodeCallback, CallbackMode callbackMode=CallbackModeAllNodes)
 Traverses the network in the input direction, starting from the masked outputs in outputs.
 
static VDF_API void TraverseWithConnectionCallback (const VdfMaskedOutputVector &outputs, const ConnectionCallback &connectionCallback)
 Traverses the network in the input direction, starting from the masked outputs in outputs.
 

Traversal with Path Reporting

using NodePathCallback = std::function< bool(const VdfNode &node, const VdfObjectPtrVector &path)>
 Callback used when traversing a network with path information.
 
using ConnectionPathCallback = std::function< bool(const VdfConnection &, const VdfMask &, const VdfObjectPtrVector &)>
 Callback used when traversing a network.
 
static VDF_API void TraverseWithPath (const VdfMaskedOutputVector &outputs, const NodePathCallback &nodePathCallback, const ConnectionPathCallback &connectionPathCallback, CallbackMode callbackMode=CallbackModeAllNodes)
 Traverses the network in the input direction, starting from the masked outputs in outputs, providing the traversal path to each invocation of nodePathCallback.
 

Detailed Description

A class used for fast sparse traversals of VdfNetworks in the output-to-input direction.

A sparse traversal takes affects masks into account and avoids traversing nodes that don't have an affect on the outputs requested for the traversal. This is most often useful for dependency traversals.

In contrast, VdfIsTopologicalSourceNode() does a full topological traversal.

Definition at line 42 of file sparseInputTraverser.h.

Member Typedef Documentation

◆ ConnectionCallback

using ConnectionCallback = std::function< bool (const VdfConnection &, const VdfMask &)>

Callback used when traversing a network.

Called for each connection and dependency mask that is visited while traversing nodes that affect values of the initial masked outputs.

Definition at line 96 of file sparseInputTraverser.h.

◆ ConnectionPathCallback

using ConnectionPathCallback = std::function< bool (const VdfConnection &, const VdfMask &, const VdfObjectPtrVector &)>

Callback used when traversing a network.

Called for each connection and dependency mask that is visited that affects values of the initial masked outputs. Note that the currently visited connection isn't appended to the path yet.

Definition at line 137 of file sparseInputTraverser.h.

◆ NodeCallback

using NodeCallback = std::function<bool (const VdfNode &)>

Callback used when traversing a network.

Called for each node that is visited that affects values of the initial masked outputs.

A return value of false halts traversal locally but allows prior branches of traversal to continue.

Definition at line 68 of file sparseInputTraverser.h.

◆ NodePathCallback

using NodePathCallback = std::function< bool (const VdfNode &node, const VdfObjectPtrVector &path)>

Callback used when traversing a network with path information.

Called for each node that is visited in the sparse traversal.

The path to the visited node from the start is given by path and it only contains nodes that have an affect on the requested outputs.

Definition at line 128 of file sparseInputTraverser.h.

Member Enumeration Documentation

◆ CallbackMode

Callback mode for the node callback.

Enumerator
CallbackModeAllNodes 

Invoke the node callback on all inputs. This is the default.

CallbackModeTerminalNodes 

Invoke the node callback only on terminal nodes.

Definition at line 47 of file sparseInputTraverser.h.

Member Function Documentation

◆ Traverse()

static VDF_API void Traverse ( const VdfMaskedOutputVector &  outputs,
const NodeCallback nodeCallback,
CallbackMode  callbackMode = CallbackModeAllNodes 
)
static

Traverses the network in the input direction, starting from the masked outputs in outputs.

Calls nodeCallback for each node visited in the sparse traversal.

If callbackMode is set to CallbackModeTerminalNodes, then the nodeCallback is only invoked on terminal nodes (i.e. nodes without input connections). If it is set to CallbackModeAllNodes (which is the default), then the callback is invoked on all nodes that are visited by the traverser.

If the callback returns false, then traversal halts locally but prior branches of traversal continue.

◆ TraverseWithConnectionCallback()

static VDF_API void TraverseWithConnectionCallback ( const VdfMaskedOutputVector &  outputs,
const ConnectionCallback connectionCallback 
)
static

Traverses the network in the input direction, starting from the masked outputs in outputs.

The traversal is identical to the one provided by Traverse(), except this method calls a connection callback instad of a node callback.

Calls connectionCallback for each connection visited in the sparse traversal.

If the callback returns false, then traversal along the supplied connection stops, and traversal along sibling connections continues.

◆ TraverseWithPath()

static VDF_API void TraverseWithPath ( const VdfMaskedOutputVector &  outputs,
const NodePathCallback nodePathCallback,
const ConnectionPathCallback connectionPathCallback,
CallbackMode  callbackMode = CallbackModeAllNodes 
)
static

Traverses the network in the input direction, starting from the masked outputs in outputs, providing the traversal path to each invocation of nodePathCallback.

Calls nodePathCallback (if specified) for each node visited in the sparse traversal. A sparse traversal only visits nodes that have an affect on the requested outputs.

Calls connectionCallback (if specified) for each node visited in the sparse traversal. A sparse traversal only visits nodes that have an affect on the requested outputs.

If callbackMode is set to CallbackModeTerminalNodes, then the nodeCallback is only invoked on terminal nodes (i.e. nodes without input connections). If it is set to CallbackModeAllNodes (which is the default), then the callback is invoked on all nodes that are visited by the traverser.


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