HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
shaderNodeDiscoveryResult.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 
8 #ifndef PXR_USD_SDR_NODE_DISCOVERY_RESULT_H
9 #define PXR_USD_SDR_NODE_DISCOVERY_RESULT_H
10 
11 /// \file sdr/shaderNodeDiscoveryResult.h
12 ///
13 /// \note
14 /// All Ndr objects are deprecated in favor of the corresponding Sdr objects
15 /// in this file. All existing pxr/usd/ndr implementations will be moved to
16 /// pxr/usd/sdr.
17 
18 #include "pxr/usd/sdr/declare.h"
20 
22 
23 /// Represents the raw data of a node, and some other bits of metadata, that
24 /// were determined via a `SdrDiscoveryPlugin`.
26  /// Constructor.
29  const SdrVersion& version,
30  const std::string& name,
31  const TfToken& family,
32  const TfToken& discoveryType,
33  const TfToken& sourceType,
34  const std::string& uri,
35  const std::string& resolvedUri,
36  const std::string &sourceCode=std::string(),
38  const std::string& blindData=std::string(),
40  ) : identifier(identifier),
41  version(version),
42  name(name),
43  family(family),
44  discoveryType(discoveryType),
45  sourceType(sourceType),
46  uri(uri),
47  resolvedUri(resolvedUri),
52  { }
53 
54  /// The node's identifier.
55  ///
56  /// How the node is identified. In many cases this will be the
57  /// name of the file or resource that this node originated from.
58  /// E.g. "mix_float_2_1". The identifier must be unique for a
59  /// given sourceType.
61 
62  /// The node's version. This may or may not be embedded in the
63  /// identifier, it's up to implementations. E.g a node with
64  /// identifier "mix_float_2_1" might have version 2.1.
66 
67  /// The node's name.
68  ///
69  /// A version independent identifier for the node type. This will
70  /// often embed type parameterization but should not embed the
71  /// version. E.g a node with identifier "mix_float_2_1" might have
72  /// name "mix_float".
73  std::string name;
74 
75  /// The node's family.
76  ///
77  /// A node's family is an optional piece of metadata that specifies a
78  /// generic grouping of nodes. E.g a node with identifier
79  /// "mix_float_2_1" might have family "mix".
81 
82  /// The node's discovery type.
83  ///
84  /// The type could be the file extension, or some other type of metadata
85  /// that can signify a type prior to parsing. See the documentation for
86  /// `SdrParserPlugin` and `SdrParserPlugin::DiscoveryTypes` for more
87  /// information on how this value is used.
89 
90  /// The node's source type.
91  ///
92  /// This type is unique to the parsing plugin
93  /// (`SdrParserPlugin::SourceType`), and determines the source of the node.
94  /// See `SdrShaderNode::GetSourceType()` for more information.
96 
97  /// The node's origin.
98  ///
99  /// This may be a filesystem path, a URL pointing to a resource in the
100  /// cloud, or some other type of resource identifier.
101  std::string uri;
102 
103  /// The node's fully-resolved URI.
104  ///
105  /// For example, this might be an absolute path when the original URI was
106  /// a relative path. In most cases, this is the path that `Ar`'s
107  /// `Resolve()` returns. In any case, this path should be locally
108  /// accessible.
109  std::string resolvedUri;
110 
111  /// The node's entire source code.
112  ///
113  /// The source code is parsed (if non-empty) by parser plugins when the
114  /// resolvedUri value is empty.
115  std::string sourceCode;
116 
117  /// The node's metadata collected during the discovery process.
118  ///
119  /// Additional metadata may be present in the node's source, in the asset
120  /// pointed to by resolvedUri or in sourceCode (if resolvedUri is empty).
121  /// In general, parsers should override this data with metadata from the
122  /// shader source.
124 
125  /// An optional detail for the parser plugin. The parser plugin
126  /// defines the meaning of this data so the discovery plugin must
127  /// be written to match.
128  std::string blindData;
129 
130  /// The subIdentifier is associated with a particular asset and refers to a
131  /// specific definition within the asset. The asset is the one referred to
132  /// by `SdrRegistry::GetNodeFromAsset()`. The subIdentifier is not needed
133  /// for all cases where the node definition is not associated with an asset.
134  /// Even if the node definition is associated with an asset, the
135  /// subIdentifier is only needed if the asset specifies multiple definitions
136  /// rather than a single definition.
138 
139  /// Helper function to translate SdrShaderNodeDiscoveryResult to
140  /// NdrNodeDiscoveryResult values.
141  ///
142  /// \deprecated
143  /// This function is deprecated and will be removed with the removal of
144  /// the Ndr library.
146  return NdrNodeDiscoveryResult(
147  identifier,
148  SdrToNdrVersion(version),
149  name,
150  family,
151  discoveryType,
152  sourceType,
153  uri,
154  resolvedUri,
155  sourceCode,
156  metadata,
157  blindData,
159  );
160  }
161 
162  /// Helper function to translate NdrNodeDiscoveryResult to
163  /// SdrShaderNodeDiscoveryResult values.
164  ///
165  /// \deprecated
166  /// This function is deprecated and will be removed with the removal of
167  /// the Ndr library.
170  ) {
172  result.identifier,
173  NdrToSdrVersion(result.version),
174  result.name,
175  result.family,
176  result.discoveryType,
177  result.sourceType,
178  result.uri,
179  result.resolvedUri,
180  result.sourceCode,
181  result.metadata,
182  result.blindData,
183  result.subIdentifier
184  );
185  }
186 };
187 
188 typedef std::vector<SdrShaderNodeDiscoveryResult> SdrShaderNodeDiscoveryResultVec;
189 
191 
192 #endif // PXR_USD_SDR_NODE_DISCOVERY_RESULT_H
std::vector< SdrShaderNodeDiscoveryResult > SdrShaderNodeDiscoveryResultVec
**But if you need a result
Definition: thread.h:622
SdrVersion.
Definition: declare.h:73
Definition: token.h:70
GLuint const GLchar * name
Definition: glcorearb.h:786
SDR_API NdrVersion SdrToNdrVersion(SdrVersion version)
SdrShaderNodeDiscoveryResult(const SdrIdentifier &identifier, const SdrVersion &version, const std::string &name, const TfToken &family, const TfToken &discoveryType, const TfToken &sourceType, const std::string &uri, const std::string &resolvedUri, const std::string &sourceCode=std::string(), const SdrTokenMap &metadata=SdrTokenMap(), const std::string &blindData=std::string(), const TfToken &subIdentifier=TfToken())
Constructor.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
NdrNodeDiscoveryResult ToNdrNodeDiscoveryResult() const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
static SdrShaderNodeDiscoveryResult FromNdrNodeDiscoveryResult(const NdrNodeDiscoveryResult &result)
std::unordered_map< TfToken, std::string, TfToken::HashFunctor > SdrTokenMap
Definition: declare.h:47
SDR_API SdrVersion NdrToSdrVersion(NdrVersion version)