![]() |
|
This is the base class for all nodes in a VdfNetwork. More...
#include <node.h>
Inheritance diagram for VdfNode:Public Member Functions | |
| TF_MALLOC_TAG_NEW ("Vdf", "new VdfNode") | |
| VDF_API | VdfNode (VdfNetwork *network, const VdfInputSpecs &inputSpecs, const VdfOutputSpecs &outputSpecs) |
Constructs a node in network with the inputs described by inputSpecs and outputs described by outputSpecs. | |
| VdfId | GetId () const |
| Returns the unique id of this node in its network. | |
| const VdfNetwork & | GetNetwork () const |
| Returns the network to which this node belongs. | |
| VdfNetwork & | GetNetwork () |
| Returns the network to which this node belongs. | |
| template<typename TYPE > | |
| bool | IsA () const |
Returns true, if this node is of type TYPE. | |
| VDF_API bool | IsEqual (const VdfNode &rhs) const |
Returns true, if rhs and this node compute the same value(s). | |
Dataflow network management - Input API | |
| const VdfInputSpecs & | GetInputSpecs () const |
| Returns the list of input specs. | |
| const VdfInput * | GetInput (const TfToken &inputName) const |
Returns the connector named inputName, returns NULL if no input of that name exists. | |
| VDF_API VdfInput * | GetInput (const TfToken &inputName) |
Returns the input named inputName, returns NULL if no input of that name exists. | |
| const InputMapIterator | GetInputsIterator () const |
| Returns an iterator class that can be used with TF_FOR_ALL to iterate through the inputs. | |
| bool | HasInputConnections () const |
| Returns true if the node has input connections, false otherwise. | |
| bool | HasOutputConnections () const |
| Returns true if the node has output connections, false otherwise. | |
| VDF_API VdfConnectionVector | GetInputConnections () const |
| Returns a flat vector of all input connections. | |
| VDF_API VdfConnectionVector | GetOutputConnections () const |
| Returns a flat vector of all output connections. | |
Dataflow network management - Output API | |
| const VdfOutputSpecs & | GetOutputSpecs () const |
| Returns the list of output specs. | |
| const VdfOutput * | GetOutput (const TfToken &name) const |
Returns the output object named name. | |
| VDF_API VdfOutput * | GetOutput (const TfToken &name) |
Returns the output object named name. | |
| VDF_API VdfOutput * | GetOptionalOutput (const TfToken &name) |
Returns the output object named name. | |
| const VdfOutput * | GetOptionalOutput (const TfToken &name) const |
Returns the output object named name. | |
| const VdfOutput * | GetOutput () const |
| Returns the only output object that this node contains. | |
| VDF_API VdfOutput * | GetOutput () |
| Returns the only output object that this node contains. | |
| const OutputMapIterator | GetOutputsIterator () const |
| Returns an iterator class that can be used with TF_FOR_ALL to iterator through the output connectors. | |
| size_t | GetNumOutputs () const |
| Returns the number of outputs that this node currently has. | |
| size_t | GetNumInputs () const |
| Returns the number of inputs that this node currently has. | |
Diagnostic API | |
| VDF_API void | SetDebugName (const std::string &name) |
| Sets the debug name for this node. | |
| template<class F > | |
| void | SetDebugNameCallback (F &&f) |
| Sets the debug name for this node with a lazily invoked callback. | |
| VDF_API void | SetDebugNameCallback (VdfNodeDebugNameCallback &&callback) |
| Sets the debug name for this node with a lazily invoked callback. | |
| VDF_API const std::string | GetDebugName () const |
| Returns the debug name for this node, if one is registered. | |
| virtual VDF_API size_t | GetMemoryUsage () const |
| Returns the amount of memory used by the node in bytes. | |
VdfExecutor API | |
| virtual void | Compute (const VdfContext &context) const =0 |
| This is the method called to perform computation. | |
| virtual VDF_API bool | IsSpeculationNode () const |
Returns true if this node performs speculation. | |
| virtual VDF_API VdfRequiredInputsPredicate | GetRequiredInputsPredicate (const VdfContext &context) const |
| Returns a predicate, determining whether a given input and its connections are required in order to fulfill this node's input dependencies. | |
| VDF_API VdfMask | ComputeOutputDependencyMask (const VdfConnection &inputConnection, const VdfMask &inputDependencyMask, const VdfOutput &output) const |
Returns a mask that indicates which elements of the data that flows along output depend on the elements indicated by inputDependencyMask that flow in via inputConnection. | |
| VDF_API void | ComputeOutputDependencyMasks (const VdfConnection &inputConnection, const VdfMask &inputDependencyMask, VdfMaskedOutputVector *outputDependencies) const |
| Vectorized version of ComputeOutputDependencyMask. | |
| VDF_API VdfMask::Bits | ComputeInputDependencyMask (const VdfMaskedOutput &maskedOutput, const VdfConnection &inputConnection) const |
Returns a mask that indicates which elements of the data that flows along inputConnection are needed to compute the data flowing out as indicated by maskedOutput. | |
| VDF_API VdfConnectionAndMaskVector | ComputeInputDependencyMasks (const VdfMaskedOutput &maskedOutput, bool skipAssociatedInputs) const |
| Vectorized version of ComputeInputDependencyMask. | |
| VDF_API VdfConnectionAndMaskVector | ComputeInputDependencyRequest (const VdfMaskedOutputVector &request) const |
| Vectorized version of ComputeInputDependencyMasks(). | |
Static Public Member Functions | |
| static VdfIndex | GetIndexFromId (const VdfId id) |
| Get the node index from the node id. | |
| static VdfVersion | GetVersionFromId (const VdfId id) |
| Get the node version from the node id. | |
Protected Member Functions | |
| VDF_API | VdfNode (VdfNetwork *network) |
| Protected constructor. | |
| VDF_API void | _AppendInputs (const VdfInputSpecs &inputSpecs, std::vector< VdfInput * > *resultingInputs=NULL) |
| Builds inputs from the supplied input specs and appends them to the already-existing set of inputs, if any. | |
| VDF_API void | _AppendOutputs (const VdfOutputSpecs &outputSpecs, std::vector< VdfOutput * > *resultingOutputs=NULL) |
| Builds outputs from the supplied output specs and appends them to the already-existing set of outputs, if any. | |
| virtual VDF_API bool | _IsDerivedEqual (const VdfNode &rhs) const |
| Can be overridden by derived classes to facilitate equality comparision. | |
| virtual VDF_API void | _DidAddInputConnection (const VdfConnection *c, int atIndex) |
| Notifies a node that one connection has been added. | |
| virtual VDF_API void | _WillRemoveInputConnection (const VdfConnection *c) |
| Notifies a node that one connection will be removed. | |
| virtual VDF_API | ~VdfNode () |
| Protected Destructor. | |
| void | _SetId (const VdfVersion version, const VdfIndex index) |
| Sets the node id. | |
| virtual VDF_API VdfMask | _ComputeOutputDependencyMask (const VdfConnection &inputConnection, const VdfMask &inputDependencyMask, const VdfOutput &output) const |
Returns a mask that indicates which elements of the data that flows along output depend on the elements indicated by inputDependencyMask that flow in via inputConnection. | |
| virtual VDF_API bool | _ComputeOutputDependencyMasks (const VdfConnection &inputConnection, const VdfMask &inputDependencyMask, VdfMaskedOutputVector *outputDependencies) const |
| Vectorized version of _ComputeOutputDependencyMask. | |
| virtual VDF_API VdfConnectionAndMaskVector | _ComputeInputDependencyRequest (const VdfMaskedOutputVector &request) const |
| Vectorized version of _ComputeOutputDependencyMasks. | |
| virtual VDF_API VdfMask::Bits | _ComputeInputDependencyMask (const VdfMaskedOutput &maskedOutput, const VdfConnection &inputConnection) const |
Returns a mask that indicates which elements of the data that flows along inputConnection are needed to compute the data flowing out as indicated by maskedOutput. | |
| virtual VDF_API VdfConnectionAndMaskVector | _ComputeInputDependencyMasks (const VdfMaskedOutput &maskedOutput, bool skipAssociatedInputs) const |
| Vectorized version of _ComputeInputDependencyMask. | |
VdfInputAndOutputSpecs management | |
| virtual VDF_API const VdfInputAndOutputSpecs * | _AcquireInputAndOutputSpecsPointer (const VdfInputSpecs &inputSpecs, const VdfOutputSpecs &outputSpecs) |
| Gets an input/output specs pointer that the node can use. | |
| virtual VDF_API void | _ReleaseInputAndOutputSpecsPointer (const VdfInputAndOutputSpecs *specs) |
| Releases an input/output specs pointer that was acquired with a previous call to _AcquireInputAndOutputSpecsPointer(). | |
| VDF_API void | _InitializeInputAndOutputSpecs (const VdfInputAndOutputSpecs *specs) |
| Initializes the input/output specs pointer for this node. | |
| VDF_API void | _ClearInputAndOutputSpecsPointer () |
| Clears the input/output specs pointer. | |
| VDF_API void | _ReplaceInputSpecs (const VdfInputSpecs &inputSpecs) |
Replaces the node's input specs with inputSpecs and rebuilds all inputs. | |
Static Protected Member Functions | |
| template<typename BaseClassType , typename ClassType > | |
| static size_t | _GetMemoryUsage (const ClassType &c, size_t dynamicSize) |
| Helper method for determining the amount of memory that a node uses. | |
Friends | |
| class | VdfNetwork |
This is the base class for all nodes in a VdfNetwork.
| VDF_API VdfNode | ( | VdfNetwork * | network, |
| const VdfInputSpecs & | inputSpecs, | ||
| const VdfOutputSpecs & | outputSpecs | ||
| ) |
Constructs a node in network with the inputs described by inputSpecs and outputs described by outputSpecs.
|
protected |
Protected constructor.
Can be used by derived classes that want to manage their own storage for input/output specs.
The derived constructor should call _InitializeInputAndOutputSpecs because this version of the constructor won't do it.
|
protectedvirtual |
Protected Destructor.
Only the network is allowed to destroy nodes.
|
protectedvirtual |
Gets an input/output specs pointer that the node can use.
This is virtual so that a derived class may specify exactly where the storage comes from. This function is not called during performance-critical code-paths.
Reimplemented in VdfExtensibleNode.
|
protected |
Builds inputs from the supplied input specs and appends them to the already-existing set of inputs, if any.
Pointers to the newly-created VdfInputs are appended to resultingInputs, if resultingInputs is not NULL.
|
protected |
Builds outputs from the supplied output specs and appends them to the already-existing set of outputs, if any.
Pointers to the newly-created VdfOutputs are appended to resultingInputs, if resultingOutputs is not NULL.
|
protected |
Clears the input/output specs pointer.
This can be used in the destructor of derived classes to avoid having their own storage for the input/output specs go through the default destruction pattern of the base class.
|
protectedvirtual |
Returns a mask that indicates which elements of the data that flows along inputConnection are needed to compute the data flowing out as indicated by maskedOutput.
This is only called from ComputeInputDependencyMask(), to handle non-associated inputs.
The default implementation returns the connection mask on inputConnection, indicating that all elements are required. Derived classes can override this method in order to make the resulting dependencies more sparse.
This method should always return a mask that is a subset of the connection mask on inputConnection or an empty mask to indicate no dependencies.
Derived classes must ensure that this method is thread safe, in the sense that _ComputeInputDependencyMask() may be called simultaneously on a single node.
Reimplemented in DependencyCallbackNode.
|
protectedvirtual |
Vectorized version of _ComputeInputDependencyMask.
Unlike _ComputeInputDependencyMask, non-trivial derived nodes do not have to implement this function.
Additional parameter skipAssociatedInputs can control if associated inputs should be considered.
|
protectedvirtual |
Vectorized version of _ComputeOutputDependencyMasks.
Unlike _ComputeDependencyMasks, non-trivial derived nodes do not have to implement this function. If a derived node is capable of supporting this vectorized API, then it can override this function.
|
protectedvirtual |
Returns a mask that indicates which elements of the data that flows along output depend on the elements indicated by inputDependencyMask that flow in via inputConnection.
This is only called from ComputeOutputDependencyMask(), to handle non-associated inputs.
The default implementation does the following:
output has an affects mask, the affects mask is returned, indicating that all affected elements depend on the input.Derived classes can override this method in order to make the resulting dependencies more sparse.
Derived classes must ensure that this method is thread safe, in the sense that _ComputeOutputDependencyMask() may be called simultaneously on a single node.
Reimplemented in DependencyCallbackNode.
|
protectedvirtual |
Vectorized version of _ComputeOutputDependencyMask.
Unlike _ComputeDependencyMask, non-trivial derived nodes do not have to implement this function. If a derived node is capable of supporting this vectorized API, then it must return true. The base class returns false, meaning this is not implemented.
|
protectedvirtual |
Notifies a node that one connection has been added.
atIndex will either contain the atIndex parameter passed to VdfNetwork's Connect() method, which specifies at what index a new connection has been inserted, or VdfNetwork::AppendConnection if the new connection was appended.
|
inlinestaticprotected |
|
protected |
Initializes the input/output specs pointer for this node.
Only to be called from constructors of derived classes that want to manage their own storage for the input/output specs.
|
protectedvirtual |
Can be overridden by derived classes to facilitate equality comparision.
The default implementation will always return false. Note that all connector specs, etc. are already taken care of via VdfNode::IsEqual().
Reimplemented in VdfEmptyInputVector, and CallbackNode.
|
protectedvirtual |
Releases an input/output specs pointer that was acquired with a previous call to _AcquireInputAndOutputSpecsPointer().
This is virtual so that a derived class may specify exactly where the storage comes from. This function is not called during performance-critical code-paths.
Reimplemented in VdfExtensibleNode.
|
protected |
Replaces the node's input specs with inputSpecs and rebuilds all inputs.
|
inlineprotected |
|
protectedvirtual |
|
pure virtual |
This is the method called to perform computation.
Derived classes must ensure that this method is thread safe, in the sense that Compute() may be called simultaneously on a single node.
Implemented in VdfSpeculationNode, and CallbackNode.
| VDF_API VdfMask::Bits ComputeInputDependencyMask | ( | const VdfMaskedOutput & | maskedOutput, |
| const VdfConnection & | inputConnection | ||
| ) | const |
Returns a mask that indicates which elements of the data that flows along inputConnection are needed to compute the data flowing out as indicated by maskedOutput.
This is used for dependency queries in the output-to-input direction.
inputConnection is associated with the output in maskedOutput, returns a mask that is computed based on the semantics of associated input/output pairs.inputConnection must be a connection that connects to an input on this node. The output in maskedOutput must be owned by this node.
| VDF_API VdfConnectionAndMaskVector ComputeInputDependencyMasks | ( | const VdfMaskedOutput & | maskedOutput, |
| bool | skipAssociatedInputs | ||
| ) | const |
Vectorized version of ComputeInputDependencyMask.
Additional parameter skipAssociatedInputs can control if associated inputs should be considered.
| VDF_API VdfConnectionAndMaskVector ComputeInputDependencyRequest | ( | const VdfMaskedOutputVector & | request | ) | const |
Vectorized version of ComputeInputDependencyMasks().
Computes all input dependencies for request in one go.
| VDF_API VdfMask ComputeOutputDependencyMask | ( | const VdfConnection & | inputConnection, |
| const VdfMask & | inputDependencyMask, | ||
| const VdfOutput & | output | ||
| ) | const |
Returns a mask that indicates which elements of the data that flows along output depend on the elements indicated by inputDependencyMask that flow in via inputConnection.
This is used for dependency queries in the input-to-output direction.
output is an associated output, returns a mask that is computed based on the semantics of associated input/output pairs.inputConnection must be a connection that connects to an input on this node. output must be owned by this node.
| VDF_API void ComputeOutputDependencyMasks | ( | const VdfConnection & | inputConnection, |
| const VdfMask & | inputDependencyMask, | ||
| VdfMaskedOutputVector * | outputDependencies | ||
| ) | const |
Vectorized version of ComputeOutputDependencyMask.
For a given inputConnection and inputDependencyMask, returns the outputs and masks that depend on them in outputDependencies.
| VDF_API const std::string GetDebugName | ( | ) | const |
Returns the debug name for this node, if one is registered.
Otherwise, returns the node type name by default.
|
inline |
Returns the input named inputName, returns NULL if no input of that name exists.
| VDF_API VdfConnectionVector GetInputConnections | ( | ) | const |
Returns a flat vector of all input connections.
|
inline |
|
inline |
|
virtual |
Returns the amount of memory used by the node in bytes.
Does not account for data structures to keep track of connections etc.
|
inline |
|
inline |
|
inline |
|
inline |
Returns the output object named name.
Returns NULL if no such output exists, but issues no errors.
| VDF_API VdfOutput * GetOutput | ( | ) |
Returns the only output object that this node contains.
It is only valid to call this method on nodes that contain exactly one output. A coding error will be issued otherwise.
Returns NULL if the node doesn't have exactly one output.
|
inline |
Returns the output object named name.
Returns NULL and issues a coding error if no such output exists.
| VDF_API VdfConnectionVector GetOutputConnections | ( | ) | const |
Returns a flat vector of all output connections.
|
inline |
|
inline |
|
virtual |
Returns a predicate, determining whether a given input and its connections are required in order to fulfill this node's input dependencies.
This method is only allowed to read input values on the inputs that have been marked as prerequisites.
Reimplemented in VdfSpeculationNode.
|
inlinestatic |
|
inline |
|
inline |
|
inline |
| VDF_API bool IsEqual | ( | const VdfNode & | rhs | ) | const |
Returns true, if rhs and this node compute the same value(s).
|
virtual |
Returns true if this node performs speculation.
The default implementation returns false.
Reimplemented in VdfSpeculationNode.
| VDF_API void SetDebugName | ( | const std::string & | name | ) |
Sets the debug name for this node.
By default, a node's debug name is the node type name; this function appends name to the node type name.
|
inline |
| VDF_API void SetDebugNameCallback | ( | VdfNodeDebugNameCallback && | callback | ) |
Sets the debug name for this node with a lazily invoked callback.
By default, a node's debug name is the node type name; this function appends the string returned by callback to the node type name.
If callback is empty, return without setting the debug name.
|
friend |