HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
shaderNodeQueryUtils.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_SHADER_NODE_QUERY_UTILS_H
9 #define PXR_USD_SDR_SHADER_NODE_QUERY_UTILS_H
10 
11 /// \file sdr/shaderNodeQueryUtils.h
12 
13 #include "pxr/pxr.h"
14 #include "pxr/base/vt/dictionary.h"
15 #include "pxr/usd/sdr/api.h"
17 
19 
20 namespace SdrShaderNodeQueryUtils {
21 
22 /// Return shader node query results in a nested tree form.
23 ///
24 /// For example, if a query result contains:
25 /// - values
26 /// `["context1", "id1"]`
27 /// `["context1", "id2"]`
28 /// - one shader node corresponding to the first value row
29 /// - two shader nodes corresponding to the second value row
30 ///
31 /// The grouped result will be a VtDictionary of the form
32 /// \code
33 /// {
34 /// "context1": {
35 /// "id1": [<SdrShaderNodeConstPtr>]
36 /// "id2": [<SdrShaderNodeConstPtr>, <SdrShaderNodeConstPtr>]
37 /// }
38 /// }
39 /// \endcode
40 ///
41 /// where the SdrShaderNodeConstPtr container is a VtValue holding
42 /// std::vector<SdrShaderNodeConstPtr> and is sorted alphabetically by
43 /// node identifier, then shadingSystem.
44 ///
45 /// Values are stringified by SdrShaderNodeQueryResult::GetStringifiedValues.
46 ///
47 /// Note that this utility doesn't help collapse empty values, but will
48 /// rather preserve empty values as keys. For example, a query result
49 /// containing values from a single node might have values:
50 ///
51 /// \code
52 /// [["a", "", "b"]]
53 /// \endcode
54 ///
55 /// For this above example, this function would return
56 ///
57 /// \code
58 /// {"a": {"": {"b": [<SdrShaderNodeConstPtr>] }}}
59 /// \endcode
60 ///
61 /// Note that innermost nodes are always contained in a list structure.
62 ///
63 /// Returns an empty VtDictionary if the given query result has no keys or
64 /// if the result has no nodes.
65 SDR_API
67 
68 } // end namespace SdrShaderNodeQueryUtils
69 
71 
72 #endif // PXR_USD_SDR_SHADER_NODE_QUERY_UTILS_H
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
**But if you need a result
Definition: thread.h:622
SDR_API VtDictionary GroupQueryResults(const SdrShaderNodeQueryResult &result)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
SdrShaderNodeQueryResult stores the results of an SdrShaderNodeQuery.
#define SDR_API
Definition: api.h:23