8#ifndef PXR_USD_SDR_SHADER_NODE_QUERY_H
9#define PXR_USD_SDR_SHADER_NODE_QUERY_H
12#include "pxr/usd/sdr/api.h"
13#include "pxr/base/tf/type.h"
14#include "pxr/base/vt/value.h"
19PXR_NAMESPACE_OPEN_SCOPE
64 typedef std::function<bool (SdrShaderNodeConstPtr)> FilterFn;
134 template <
typename T>
143 const std::vector<VtValue>& values);
155 template <
typename T>
165 const std::vector<VtValue>& values);
191 std::vector<std::pair<TfToken, VtValue>> _hasValues;
192 std::vector<std::pair<TfToken, std::vector<VtValue>>> _hasOneOfValues;
193 std::vector<std::pair<TfToken, VtValue>> _lacksValues;
194 std::vector<std::pair<TfToken, std::vector<VtValue>>> _lacksAllOfValues;
195 std::vector<TfToken> _selectKeys;
196 std::vector<FilterFn> _customFilters;
223 const std::vector<std::vector<VtValue>>&
GetValues() const & {
return _values; }
227 return std::move(_values);
239 std::vector<std::vector<T>> result;
240 result.reserve(_values.size());
241 for (
const std::vector<VtValue>& row : _values) {
242 std::vector<T> convertedRows;
243 convertedRows.reserve(row.size());
244 for (
const VtValue& value : row) {
245 const VtValue convertedValue = VtValue::Cast<T>(value);
246 if (convertedValue.
IsEmpty()) {
248 "Failed to get value of type %s from value '%s'",
252 convertedRows.push_back(convertedValue);
254 result.push_back(convertedRows);
282 std::vector<TfToken> _keys;
283 std::vector<std::vector<VtValue>> _values;
284 std::vector<SdrShaderNodePtrVec> _nodes;
287PXR_NAMESPACE_CLOSE_SCOPE
The registry provides access to shader node information.
SdrShaderNodeQuery is a constraint-based query builder object that operates on all SdrShaderNodes con...
SDR_API SdrShaderNodeQuery & NodeValueIsNot(const TfToken &key, const VtValue &value)
Only keep SdrShaderNodes whose value returned from SdrShaderNode::GetDataForKey(key) doesn't match th...
SDR_API SdrShaderNodeQuery & CustomFilter(FilterFn fn)
Supply a custom filter to this query.
SDR_API SdrShaderNodeQuery & NodeHasNoValueFor(const TfToken &key)
Only keep SdrShaderNodes that don't have an existing value for for the given key.
SDR_API SdrShaderNodeQuery & NodeHasValueFor(const TfToken &key)
Only keep SdrShaderNodes that have an existing value for for the given key.
SDR_API SdrShaderNodeQuery & NodeValueIs(const TfToken &key, const VtValue &value)
Only keep SdrShaderNodes whose value returned from SdrShaderNode::GetDataForKey(key) matches the give...
SDR_API SdrShaderNodeQuery & NodeValueIsNotIn(const TfToken &key, const std::vector< VtValue > &values)
Only keep SdrShaderNodes whose value returned from SdrShaderNode::GetDataForKey(key) doesn't match an...
SDR_API SdrShaderNodeQuery & NodeValueIsIn(const TfToken &key, const std::vector< VtValue > &values)
Only keep SdrShaderNodes whose value returned from SdrShaderNode::GetDataForKey(key) matches any of t...
SDR_API SdrShaderNodeQuery & SelectDistinct(const std::vector< TfToken > &key)
Specify multiple keys to query data for.
SDR_API SdrShaderNodeQueryResult Run()
Convenience to run this query on the SdrRegistry.
SDR_API SdrShaderNodeQuery & SelectDistinct(const TfToken &key)
SelectDistinct asks for distinct information from SdrShaderNodes via the SdrShaderNode::GetDataForKey...
SdrShaderNodeQueryResult stores the results of an SdrShaderNodeQuery.
SDR_API std::vector< SdrShaderNodePtrVec > GetShaderNodesByValues() const
Gets shader nodes, grouped by value rows.
std::vector< std::vector< T > > GetValuesAs() const
Convenience to convert all values to T.
SDR_API std::vector< std::vector< std::string > > GetStringifiedValues() const
Get string representations of all values, as provided by TfStringify.
TfTokenVector GetKeys() &&
Overload for rvalues, move out the keys.
std::vector< std::vector< VtValue > > GetValues() &&
Overload for rvalues, move out the values.
const std::vector< std::vector< VtValue > > & GetValues() const &
Returns distinct "list of values" extracted from SdrShaderNodes corresponding to keys requested by Se...
const TfTokenVector & GetKeys() const &
Returns keys requested by SelectDistinct calls on SdrShaderNodeQuery in the order they were added to ...
SDR_API SdrShaderNodePtrVec GetAllShaderNodes() const
Returns all shader nodes that match the constraints of the query.
Token for efficient comparison, assignment, and hashing of known strings.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
bool IsEmpty() const
Returns true iff this value is empty.
#define TF_CODING_ERROR(fmt, args)
Issue an internal programming error, but continue execution.
std::string TfStringify(const T &v)
Convert an arbitrary type into a string.
std::vector< TfToken > TfTokenVector
Convenience types.