HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
inputSpec.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_INPUT_SPEC_H
8 #define PXR_EXEC_VDF_INPUT_SPEC_H
9 
10 /// \file
11 
12 #include "pxr/pxr.h"
13 
14 #include "pxr/exec/vdf/api.h"
15 
16 #include "pxr/base/tf/mallocTag.h"
17 #include "pxr/base/tf/token.h"
18 #include "pxr/base/tf/type.h"
19 
21 
22 class VdfOutputSpec;
23 
24 ////////////////////////////////////////////////////////////////////////////////
25 ///
26 /// A VdfInputSpec describes an input connector. It stores typing
27 /// information, access information and the connector's name.
28 ///
30 {
31 public:
32  TF_MALLOC_TAG_NEW("Vdf", "new VdfInputSpec");
33 
34  /// Access limits the kinds of operations allowed on the connector.
35  enum Access {
36  READ = 0x1,
37  READWRITE = 0x2
38  };
39 
40  template <typename T>
41  static VdfInputSpec *New(
42  const TfToken &inName,
43  const TfToken &outName,
44  Access access,
45  bool prerequisite)
46  {
47  return new VdfInputSpec(
48  TfType::Find<T>(), inName, outName, access, prerequisite);
49  }
50 
51  static VdfInputSpec *New(
52  TfType type,
53  const TfToken &inName,
54  const TfToken &outName,
55  Access access,
56  bool prerequisite)
57  {
58  return new VdfInputSpec(type, inName, outName, access, prerequisite);
59  }
60 
61  VDF_API
62  ~VdfInputSpec();
63 
64  /// Returns the type of this spec
65  TfType GetType() const { return _type; }
66 
67  /// Returns the name of this connector.
68  const TfToken &GetName() const { return _name; }
69 
70  /// Returns the name of this spec's type.
71  VDF_API
72  std::string GetTypeName() const;
73 
74  /// Returns the access of this connector.
75  const Access &GetAccess() const { return _access; }
76 
77  /// Returns \c true if this connector spec and \p other have the same
78  /// type and \c false otherwise.
79  VDF_API
80  bool TypeMatches(const VdfOutputSpec &other) const;
81 
82  /// Returns the name of the associated output, if any. If not set,
83  /// returns the empty token.
84  ///
86  return _associatedOutputName;
87  }
88 
89  /// Returns whether or not this connector is a prerequisite connector.
90  ///
91  /// Prerequisite outputs are the only ones that can be accessed by
92  /// VdfNode::GetRequiredReadsIterator(VdfContext). Once these
93  /// have been computed, a node provides dynamic input dependency information
94  /// via that method.
95  ///
96  bool IsPrerequisite() const { return _prerequisite; }
97 
98  /// Returns a hash for this instance.
99  VDF_API
100  size_t GetHash() const;
101 
102  /// Returns true, if two input specs are equal.
103  ///
104  bool operator==(const VdfInputSpec &rhs) const {
105  return _type == rhs._type &&
106  _name == rhs._name &&
107  _associatedOutputName == rhs._associatedOutputName &&
108  _access == rhs._access &&
109  _prerequisite == rhs._prerequisite;
110  }
111  bool operator!=(const VdfInputSpec &rhs) const {
112  return !(*this == rhs);
113  }
114 
115 private:
116  VdfInputSpec(
117  TfType type,
118  const TfToken &inName,
119  const TfToken &outName,
120  Access access,
121  bool prerequisite)
122  : _type(type),
123  _name(inName),
124  _associatedOutputName(outName),
125  _access(access),
126  _prerequisite(prerequisite)
127  {}
128 
129 private:
130  // The type accepted by the input.
131  TfType _type;
132 
133  // The name of the connector
134  TfToken _name;
135 
136  // Access to the connector is limited by this value.
137  TfToken _associatedOutputName;
138 
139  // Access to the connector is limited by this value.
140  Access _access;
141 
142  // Whether or not this connector is a prerequisite connector.
143  bool _prerequisite;
144 };
145 
147 
148 #endif
VDF_API ~VdfInputSpec()
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
TfType GetType() const
Returns the type of this spec.
Definition: inputSpec.h:65
VDF_API std::string GetTypeName() const
Returns the name of this spec's type.
#define VDF_API
Definition: api.h:25
bool IsPrerequisite() const
Definition: inputSpec.h:96
static VdfInputSpec * New(const TfToken &inName, const TfToken &outName, Access access, bool prerequisite)
Definition: inputSpec.h:41
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
Definition: token.h:70
VDF_API size_t GetHash() const
Returns a hash for this instance.
const TfToken & GetAssociatedOutputName() const
Definition: inputSpec.h:85
VDF_API bool TypeMatches(const VdfOutputSpec &other) const
GLuint GLint GLboolean GLint GLenum access
Definition: glcorearb.h:2222
bool operator==(const VdfInputSpec &rhs) const
Definition: inputSpec.h:104
bool operator!=(const VdfInputSpec &rhs) const
Definition: inputSpec.h:111
const Access & GetAccess() const
Returns the access of this connector.
Definition: inputSpec.h:75
const TfToken & GetName() const
Returns the name of this connector.
Definition: inputSpec.h:68
TF_MALLOC_TAG_NEW("Vdf","new VdfInputSpec")
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Access
Access limits the kinds of operations allowed on the connector.
Definition: inputSpec.h:35
Definition: type.h:47
static VdfInputSpec * New(TfType type, const TfToken &inName, const TfToken &outName, Access access, bool prerequisite)
Definition: inputSpec.h:51