Loading...
Searching...
No Matches
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
17#include "pxr/exec/vdf/node.h"
18
19PXR_NAMESPACE_OPEN_SCOPE
20
31template <typename Type>
32Type
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
53PXR_NAMESPACE_CLOSE_SCOPE
54
55#endif
A context is the parameter bundle passed to callbacks of computations.
Definition: context.h:40
const T * GetInputValuePtr(const TfToken &name) const
Returns a pointer to the value from the input named name if the input has a valid value,...
Definition: context.h:319
const T & GetFallback() const
Returns the registered fallback value for T from the registry.
static VDF_API VdfExecutionTypeRegistry & GetInstance()
Returns the VdfExecutionTypeRegistry singleton instance.
Base class for libVdf iterators.
Definition: iterator.h:36
const VdfNode & _GetNode(const VdfContext &context) const
Returns the current node being run.
Definition: iterator.h:45
This is the base class for all nodes in a VdfNetwork.
Definition: node.h:53
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
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.