firstValidInputValue.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_EF_FIRST_VALID_INPUT_VALUE_H
8 #define PXR_EXEC_EF_FIRST_VALID_INPUT_VALUE_H
9 
11 
12 #include "pxr/pxr.h"
13 
14 #include "pxr/exec/vdf/context.h"
16 #include "pxr/exec/vdf/iterator.h"
17 #include "pxr/exec/vdf/node.h"
18 
19 PXR_NAMESPACE_OPEN_SCOPE
20 
31 template <typename Type>
32 Type
34 {
35  struct ContextAccess final : public VdfIterator {
36  const VdfNode &GetNode(const VdfContext &context) {
37  return _GetNode(context);
38  }
39  };
40 
41  // Iterate over all inputs, and return the first valid input value.
42  const VdfNode &node = ContextAccess().GetNode(context);
43  for (const std::pair<TfToken, VdfInput *> &in : node.GetInputsIterator()) {
44  if (const Type *value = context.GetInputValuePtr<Type>(in.first)) {
45  return *value;
46  }
47  }
48 
49  // Ask the type registry for the fallback value to use.
51 }
52 
53 PXR_NAMESPACE_CLOSE_SCOPE
54 
55 #endif
This is the base class for all nodes in a VdfNetwork.
Definition: node.h:52
const T * GetInputValuePtr(const TfToken &name) const
Returns a pointer to the value from the input named name if the.
Definition: context.h:318
const T & GetFallback() const
Returns the registered fallback value for T from the registry.
const VdfNode & _GetNode(const VdfContext &context) const
Returns the current node being run.
Definition: iterator.h:45
Type EfGetFirstValidInputValue(const VdfContext &context)
A function that may be used as a callback (or in a callback) to return the first valid input value.
const InputMapIterator GetInputsIterator() const
Returns an iterator class that can be used with TF_FOR_ALL to iterate through the inputs.
Definition: node.h:177
Base class for libVdf iterators.
Definition: iterator.h:35
A context is the parameter bundle passed to callbacks of computations.
Definition: context.h:39
static VDF_API VdfExecutionTypeRegistry & GetInstance()
Returns the VdfExecutionTypeRegistry singleton instance.