7#ifndef PXR_EXEC_VDF_NODE_H
8#define PXR_EXEC_VDF_NODE_H
14#include "pxr/exec/vdf/api.h"
37PXR_NAMESPACE_OPEN_SCOPE
71 class InputMapIterator {
73 typedef _TokenInputMap::const_iterator const_iterator;
74 typedef _TokenInputMap::const_reverse_iterator const_reverse_iterator;
77 const_iterator begin()
const {
return _map.begin(); }
78 const_iterator end()
const {
return _map.end(); }
79 const_reverse_iterator rbegin()
const {
return _map.rbegin(); }
80 const_reverse_iterator rend()
const {
return _map.rend(); }
89 class OutputMapIterator {
91 typedef _TokenOutputMap::const_iterator const_iterator;
92 typedef _TokenOutputMap::const_reverse_iterator const_reverse_iterator;
95 const_iterator begin()
const {
return _map.begin(); }
96 const_iterator end()
const {
return _map.end(); }
97 const_reverse_iterator rbegin()
const {
return _map.rbegin(); }
98 const_reverse_iterator rend()
const {
return _map.rend(); }
146 template<
typename TYPE>
149 return dynamic_cast<const TYPE *
>(
this);
158 return _specs->GetInputSpecs();
165 return const_cast<VdfNode *
>(
this)->GetInput(inputName);
178 return InputMapIterator(_inputs);
185 if (i->second->GetNumConnections())
195 if (output->second->GetConnections().size())
220 return _specs->GetOutputSpecs();
228 return const_cast<VdfNode *
>(
this)->GetOutput(name);
250 return const_cast<VdfNode *
>(
this)->GetOptionalOutput(name);
261 return const_cast<VdfNode *
>(
this)->GetOutput();
278 return OutputMapIterator(_outputs);
284 return _outputs.size();
290 return _inputs.size();
389 const VdfMask &inputDependencyMask,
399 const VdfMask &inputDependencyMask,
400 VdfMaskedOutputVector *outputDependencies)
const;
430 bool skipAssociatedInputs)
const;
438 const VdfMaskedOutputVector &request)
const;
469 std::vector<VdfInput*> *resultingInputs = NULL);
479 std::vector<VdfOutput*> *resultingOutputs = NULL);
527 _id = (
static_cast<VdfId>(version) << 32) |
static_cast<VdfId>(index);
586 template <
typename BaseClassType,
typename ClassType>
589 return c.BaseClassType::GetMemoryUsage() +
590 (
sizeof(ClassType) -
sizeof(BaseClassType)) +
617 const VdfMask &inputDependencyMask,
630 const VdfMask &inputDependencyMask,
631 VdfMaskedOutputVector *outputDependencies)
const;
641 const VdfMaskedOutputVector &request)
const;
679 bool skipAssociatedInputs)
const;
711struct Tf_ShouldIterateOverCopy<
VdfNode::InputMapIterator> : std::true_type {};
713struct Tf_ShouldIterateOverCopy<
VdfNode::OutputMapIterator> : std::true_type {};
717PXR_NAMESPACE_CLOSE_SCOPE
A simple iterator adapter for STL containers.
Fast, compressed bit array which is capable of performing logical operations without first decompress...
Token for efficient comparison, assignment, and hashing of known strings.
A class that fully represents a connection between two VdfNodes.
A context is the parameter bundle passed to callbacks of computations.
Abstract base class for classes that execute a VdfNetwork to compute a requested set of values.
A VdfMask is placed on connections to specify the data flowing through them.
Class to hold on to an externally owned output and a mask.
A VdfNetwork is a collection of VdfNodes and their connections.
This is the base class for all nodes in a VdfNetwork.
virtual VDF_API bool _ComputeOutputDependencyMasks(const VdfConnection &inputConnection, const VdfMask &inputDependencyMask, VdfMaskedOutputVector *outputDependencies) const
Vectorized version of _ComputeOutputDependencyMask.
VDF_API VdfConnectionVector GetInputConnections() const
Returns a flat vector of all input connections.
void _SetId(const VdfVersion version, const VdfIndex index)
Sets the node id.
const InputMapIterator GetInputsIterator() const
Returns an iterator class that can be used with TF_FOR_ALL to iterate through the inputs.
void SetDebugNameCallback(F &&f)
Sets the debug name for this node with a lazily invoked callback.
virtual VDF_API VdfConnectionAndMaskVector _ComputeInputDependencyMasks(const VdfMaskedOutput &maskedOutput, bool skipAssociatedInputs) const
Vectorized version of _ComputeInputDependencyMask.
bool HasInputConnections() const
Returns true if the node has input connections, false otherwise.
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 ...
virtual VDF_API void _WillRemoveInputConnection(const VdfConnection *c)
Notifies a node that one connection will be removed.
VDF_API VdfConnectionAndMaskVector ComputeInputDependencyRequest(const VdfMaskedOutputVector &request) const
Vectorized version of ComputeInputDependencyMasks().
VDF_API void _ReplaceInputSpecs(const VdfInputSpecs &inputSpecs)
Replaces the node's input specs with inputSpecs and rebuilds all inputs.
VDF_API VdfOutput * GetOptionalOutput(const TfToken &name)
Returns the output object named name.
VDF_API void _ClearInputAndOutputSpecsPointer()
Clears the input/output specs pointer.
static VdfIndex GetIndexFromId(const VdfId id)
Get the node index from the node id.
const VdfInputSpecs & GetInputSpecs() const
Returns the list of input specs.
virtual VDF_API bool _IsDerivedEqual(const VdfNode &rhs) const
Can be overridden by derived classes to facilitate equality comparision.
VDF_API void SetDebugNameCallback(VdfNodeDebugNameCallback &&callback)
Sets the debug name for this node with a lazily invoked callback.
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 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 ...
static size_t _GetMemoryUsage(const ClassType &c, size_t dynamicSize)
Helper method for determining the amount of memory that a node uses.
VDF_API const std::string GetDebugName() const
Returns the debug name for this node, if one is registered.
size_t GetNumOutputs() const
Returns the number of outputs that this node currently has.
const VdfOutput * GetOutput(const TfToken &name) const
Returns the output object named name.
virtual VDF_API void _ReleaseInputAndOutputSpecsPointer(const VdfInputAndOutputSpecs *specs)
Releases an input/output specs pointer that was acquired with a previous call to _AcquireInputAndOutp...
bool IsA() const
Returns true, if this node is of type TYPE.
bool HasOutputConnections() const
Returns true if the node has output connections, false otherwise.
virtual VDF_API void _DidAddInputConnection(const VdfConnection *c, int atIndex)
Notifies a node that one connection has been added.
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,...
VdfId GetId() const
Returns the unique id of this node in its network.
const VdfOutput * GetOptionalOutput(const TfToken &name) const
Returns the output object named name.
size_t GetNumInputs() const
Returns the number of inputs that this node currently has.
VDF_API void SetDebugName(const std::string &name)
Sets the debug name for this node.
VDF_API VdfConnectionVector GetOutputConnections() const
Returns a flat vector of all output connections.
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...
VDF_API VdfOutput * GetOutput(const TfToken &name)
Returns the output object named name.
VdfNetwork & GetNetwork()
Returns the network to which this node belongs.
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 elemen...
const VdfInput * GetInput(const TfToken &inputName) const
Returns the connector named inputName, returns NULL if no input of that name exists.
virtual VDF_API VdfConnectionAndMaskVector _ComputeInputDependencyRequest(const VdfMaskedOutputVector &request) const
Vectorized version of _ComputeOutputDependencyMasks.
VDF_API void ComputeOutputDependencyMasks(const VdfConnection &inputConnection, const VdfMask &inputDependencyMask, VdfMaskedOutputVector *outputDependencies) const
Vectorized version of ComputeOutputDependencyMask.
const VdfNetwork & GetNetwork() const
Returns the network to which this node belongs.
VDF_API bool IsEqual(const VdfNode &rhs) const
Returns true, if rhs and this node compute the same value(s).
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 outputS...
const OutputMapIterator GetOutputsIterator() const
Returns an iterator class that can be used with TF_FOR_ALL to iterator through the output connectors.
const VdfOutput * GetOutput() const
Returns the only output object that this node contains.
const VdfOutputSpecs & GetOutputSpecs() const
Returns the list of output specs.
VDF_API VdfNode(VdfNetwork *network)
Protected constructor.
VDF_API VdfOutput * GetOutput()
Returns the only output object that this node contains.
VDF_API void _InitializeInputAndOutputSpecs(const VdfInputAndOutputSpecs *specs)
Initializes the input/output specs pointer for this node.
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 f...
virtual VDF_API bool IsSpeculationNode() const
Returns true if this node performs speculation.
static VdfVersion GetVersionFromId(const VdfId id)
Get the node version from the node id.
virtual VDF_API size_t GetMemoryUsage() const
Returns the amount of memory used by the node in bytes.
VDF_API VdfConnectionAndMaskVector ComputeInputDependencyMasks(const VdfMaskedOutput &maskedOutput, bool skipAssociatedInputs) const
Vectorized version of ComputeInputDependencyMask.
VDF_API VdfInput * GetInput(const TfToken &inputName)
Returns the input named inputName, returns NULL if no input of that name exists.
virtual VDF_API ~VdfNode()
Protected Destructor.
virtual void Compute(const VdfContext &context) const =0
This is the method called to perform computation.
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 elemen...
A VdfOutput represents an output on a node.
VdfOutputSpecs is a container for VdfOutputSpec objects.
This class is used to abstract away knowledge of the cache data used for each node.
Demangle C++ typenames generated by the typeid() facility.
std::function< std::string()> VdfNodeDebugNameCallback
Type of callback for building a node debug name.
std::vector< VdfConnectionAndMask > VdfConnectionAndMaskVector
A vector of VdfConnectionAndMasks.
uint64_t VdfId
The unique identifier type for Vdf objects.
uint32_t VdfIndex
The index type for Vdf objects.
uint32_t VdfVersion
The version type for Vdf objects.
Define preprocessor function name macros.
#define TF_FOR_ALL(iter, c)
Macro for iterating over a container.
#define TF_MALLOC_TAG_NEW(name1, name2)
Enable lib/tf memory management.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...