Loading...
Searching...
No Matches
requiredInputsPredicate.h
Go to the documentation of this file.
1//
2// Copyright 2025 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_EXEC_VDF_REQUIRED_INPUTS_PREDICATE_H
8#define PXR_EXEC_VDF_REQUIRED_INPUTS_PREDICATE_H
9
11
12#include "pxr/pxr.h"
13
14#include "pxr/exec/vdf/input.h"
15
16PXR_NAMESPACE_OPEN_SCOPE
17
26{
27public:
31 return VdfRequiredInputsPredicate(_Selector::AllReads, node, nullptr);
32 }
33
37 return VdfRequiredInputsPredicate(_Selector::NoReads, node, nullptr);
38 }
39
43 const VdfNode &node,
44 const VdfInput &input) {
45 return VdfRequiredInputsPredicate(_Selector::OneRead, node, &input);
46 }
47
51 bool IsRequiredRead(const VdfInput &input) const {
52 return
53 _selector != _Selector::NoReads &&
54 !input.GetAssociatedOutput() &&
55 !input.GetSpec().IsPrerequisite() &&
56 (_selector == _Selector::AllReads ||
57 (_oneRead == &input && &input.GetNode() == &_node));
58 }
59
62 bool HasRequiredReads() const {
63 return _selector != _Selector::NoReads;
64 }
65
68 bool RequiresAllReads() const {
69 return _selector == _Selector::AllReads;
70 }
71
72private:
73 // Denotes how inputs are selected.
74 enum class _Selector {
75 NoReads,
76 AllReads,
77 OneRead
78 };
79
80 // Constructor. \p oneRead is only relevant if \p selector equals
81 // _Selector::OneRead. Otherwise \p oneRead may be \c nullptr.
83 _Selector selector,
84 const VdfNode &node,
85 const VdfInput *oneRead) :
86 _selector(selector),
87 _node(node),
88 _oneRead(oneRead)
89 {}
90
91 // Select inputs based on this choice of selector.
92 _Selector _selector;
93
94 // The owning node.
95 const VdfNode &_node;
96
97 // The input, if _selector is OneRead.
98 const VdfInput *_oneRead;
99};
100
102
103PXR_NAMESPACE_CLOSE_SCOPE
104
105#endif
A VdfInput is used to connect a VdfNode to one or more VdfNodes' outputs.
Definition: input.h:36
VDF_API const VdfInputSpec & GetSpec() const
Returns the spec for this input connector.
const VdfNode & GetNode() const
Returns the owning node for this input connector.
Definition: input.h:86
const VdfOutput * GetAssociatedOutput() const
Returns the output corresponding to this input.
Definition: input.h:82
bool IsPrerequisite() const
Returns whether or not this connector is a prerequisite connector.
Definition: inputSpec.h:96
This is the base class for all nodes in a VdfNetwork.
Definition: node.h:53
This predicate determines whether a given input value is needed to fulfill the input dependencies req...
static VdfRequiredInputsPredicate OneRead(const VdfNode &node, const VdfInput &input)
One specific read input on node is required.
bool IsRequiredRead(const VdfInput &input) const
Is this input a required read? Note that read/writes as well as prerequisite inputs are not required ...
bool HasRequiredReads() const
Are any inputs required?
static VdfRequiredInputsPredicate AllReads(const VdfNode &node)
All read inputs on node are required.
bool RequiresAllReads() const
Are all of the inputs required?
static VdfRequiredInputsPredicate NoReads(const VdfNode &node)
None of the read inputs on node are required.