HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
rawValueAccessor.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_RAW_VALUE_ACCESSOR_H
8 #define PXR_EXEC_VDF_RAW_VALUE_ACCESSOR_H
9 
10 /// \file
11 
12 #include "pxr/pxr.h"
13 
14 #include "pxr/exec/vdf/api.h"
15 #include "pxr/exec/vdf/iterator.h"
16 
18 
19 class VdfContext;
20 class VdfInput;
21 class VdfMask;
22 class VdfOutput;
23 class VdfVector;
24 
25 ////////////////////////////////////////////////////////////////////////////////
26 ///
27 /// This class grants special access to the raw VdfVector data associated with
28 /// inputs and outputs on a VdfNode.
29 ///
30 /// Note, that input and output data is typically accessed using the VdfContext.
31 /// In some special cases, nodes may require type-agnostic access to the entire
32 /// VdfVector stored for a specific input or output.
33 ///
34 /// We do not want this class to be used in typical plugin code (mover, gprims,
35 /// etc.), thus inputs and outputs are referred to using VdfInput and VdfOutput
36 /// instances, rather than name tokens. Only classes derived from VdfNode will
37 /// typically have access to these objects.
38 ///
40 {
41 public:
42 
43  /// Constructs a VdfRawValueAccessor from a VdfContext.
44  ///
45  VdfRawValueAccessor(const VdfContext &context) : _context(context) {}
46 
47  /// Returns the first VdfVector at the input for \p input. Returns nullptr
48  /// if there is no connection on the supplied input or if the requested
49  /// input does not exist.
50  ///
51  /// Note, this method purposefully accepts a VdfInput instead of a TfToken,
52  /// such that it can only be used where VdfInputs are available.
53  ///
54  VDF_API
56  const VdfInput &input,
57  VdfMask *mask = nullptr) const;
58 
59  /// Sets the \p output value to the given \p value using the passed
60  /// in \p mask.
61  ///
62  /// Note, this method purposefully accepts a VdfOutput instead of a TfToken,
63  /// such that it can only be used where VdfOutputs are available.
64  ///
65  VDF_API
66  void SetOutputVector(
67  const VdfOutput &output,
68  const VdfMask &mask,
69  const VdfVector &value);
70 
71  /// \overload
72  ///
73  VDF_API
74  void SetOutputVector(
75  const VdfOutput &output,
76  const VdfMask &mask,
77  VdfVector &&value);
78 
79 private:
80 
81  // Common implementation of SetOutputVector overloads.
82  template <typename Vector>
83  void _SetOutputVector(
84  const VdfOutput &output,
85  const VdfMask &mask,
86  Vector &&value);
87 
88 private:
89 
90  // The context used to access the input/output data.
91  const VdfContext &_context;
92 
93 };
94 
96 
97 #endif
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
GLsizei const GLfloat * value
Definition: glcorearb.h:824
VDF_API void SetOutputVector(const VdfOutput &output, const VdfMask &mask, const VdfVector &value)
A VdfMask is placed on connections to specify the data flowing through them.
Definition: mask.h:36
#define VDF_API
Definition: api.h:25
Definition: input.h:35
GLint GLuint mask
Definition: glcorearb.h:124
VdfRawValueAccessor(const VdfContext &context)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
VDF_API const VdfVector * GetInputVector(const VdfInput &input, VdfMask *mask=nullptr) const