HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
iterator.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_ITERATOR_H
8 #define PXR_EXEC_VDF_ITERATOR_H
9 
10 /// \file
11 
12 #include "pxr/pxr.h"
13 
14 #include "pxr/exec/vdf/api.h"
15 #include "pxr/exec/vdf/context.h"
16 #include "pxr/exec/vdf/types.h"
17 
19 
20 class TfToken;
21 class VdfConnection;
23 class VdfMask;
24 class VdfNode;
25 class VdfOutput;
26 class VdfVector;
27 
28 ////////////////////////////////////////////////////////////////////////////////
29 ///
30 /// \class VdfIterator
31 ///
32 /// Base class for libVdf iterators. Iterators can derive from this class
33 /// to have access to restricted API from the VdfContext.
34 ///
36 {
37 protected:
38 
39  /// Disallow destruction via base class pointers.
40  ///
41  ~VdfIterator() = default;
42 
43  /// Returns the current node being run.
44  ///
45  const VdfNode &_GetNode(const VdfContext &context) const {
46  return context._GetNode();
47  }
48 
49  /// Returns the executor for the given context.
50  ///
51  const VdfExecutorInterface &_GetExecutor(const VdfContext &context) const {
52  return context._GetExecutor();
53  }
54 
55  /// Returns a vector for reading an input value. This will return \c NULL
56  /// if no value is flowing across the given \p connection, or if the data
57  /// requested with \p mask is unavailable.
58  ///
59  VDF_API
61  const VdfContext &context,
62  const VdfConnection &connection,
63  const VdfMask &mask) const;
64 
65  /// Returns the cached output value for a given \p output, or issues an
66  /// error message if a cache value is not available.
67  ///
68  VDF_API
70  const VdfContext &context,
71  const VdfConnection &connection,
72  const VdfMask &mask) const;
73 
74  /// Returns the output for writing based on the \p name provided. This
75  /// returns the associated output of the input named \p name, if it
76  /// exists. Otherwise, returns the output name \p name. If \p name is the
77  /// empty token, returns the single output on the current node.
78  /// Issues a coding error if the required output does not exist.
79  ///
80  VDF_API
82  const VdfContext &context,
83  const TfToken &name) const;
84 
85  /// Returns a vector for writing an output value into. Note that if this
86  /// method returns \c NULL a data entry has not been created for the given
87  /// \p output. This is not necessarily an error condition, if for example
88  /// the \p output is simply not scheduled.
89  ///
90  VDF_API
92  const VdfContext &context,
93  const VdfOutput &output) const;
94 
95  /// Retrieves the request and affects masks of the given \p output. Note,
96  /// that output must be an output on the current node. Returns \c true if
97  /// the output is scheduled, and \c false otherwise.
98  ///
99  /// The \p requestMask is the mask of the elements requested of a
100  /// particular output.
101  ///
102  /// The \p affectsMask is the mask of the elements that are potentially
103  /// going to be modified by a particular output.
104  ///
105  VDF_API
106  bool _GetOutputMasks(
107  const VdfContext &context,
108  const VdfOutput &output,
109  const VdfMask **requestMask,
110  const VdfMask **affectsMask) const;
111 
112  /// Returns \c true when the \p connection is scheduled and required,
113  /// and \c false otherwise. Used by special iterators to avoid computing
114  /// outputs that aren't necessary.
115  ///
116  VDF_API
117  bool _IsRequiredInput(
118  const VdfContext &context,
119  const VdfConnection &connection) const;
120 
121  /// Returns the request mask of \p output, if the output has been scheduled
122  /// and \c NULL otherwise.
123  ///
124  VDF_API
125  const VdfMask *_GetRequestMask(
126  const VdfContext &context,
127  const VdfOutput &output) const;
128 
129  /// Loops over each scheduled output of \p node and calls \p callback
130  /// with the output and request mask in an efficient manner.
131  ///
132  VDF_API
134  const VdfContext &context,
135  const VdfNode &node,
136  const VdfScheduledOutputCallback &callback) const;
137 };
138 
140 
141 #endif
VDF_API const VdfMask * _GetRequestMask(const VdfContext &context, const VdfOutput &output) const
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
VDF_API void _ForEachScheduledOutput(const VdfContext &context, const VdfNode &node, const VdfScheduledOutputCallback &callback) const
Definition: node.h:52
A VdfMask is placed on connections to specify the data flowing through them.
Definition: mask.h:36
VDF_API VdfVector * _GetOutputValueForWriting(const VdfContext &context, const VdfOutput &output) const
#define VDF_API
Definition: api.h:25
std::function< void(const VdfOutput *, const VdfMask &)> VdfScheduledOutputCallback
Definition: types.h:86
Definition: token.h:70
GLint GLuint mask
Definition: glcorearb.h:124
VDF_API bool _IsRequiredInput(const VdfContext &context, const VdfConnection &connection) const
GLuint const GLchar * name
Definition: glcorearb.h:786
VDF_API const VdfOutput * _GetRequiredOutputForWriting(const VdfContext &context, const TfToken &name) const
VDF_API const VdfVector * _GetInputValue(const VdfContext &context, const VdfConnection &connection, const VdfMask &mask) const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
const VdfNode & _GetNode(const VdfContext &context) const
Definition: iterator.h:45
VDF_API bool _GetOutputMasks(const VdfContext &context, const VdfOutput &output, const VdfMask **requestMask, const VdfMask **affectsMask) const
~VdfIterator()=default
Abstract base class for classes that execute a VdfNetwork to compute a requested set of values...
VDF_API const VdfVector & _GetRequiredInputValue(const VdfContext &context, const VdfConnection &connection, const VdfMask &mask) const
const VdfExecutorInterface & _GetExecutor(const VdfContext &context) const
Definition: iterator.h:51