Loading...
Searching...
No Matches
leafNode.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_LEAF_NODE_H
8#define PXR_EXEC_EF_LEAF_NODE_H
9
11
12#include "pxr/pxr.h"
13
14#include "pxr/exec/ef/api.h"
15
17#include "pxr/exec/vdf/node.h"
19
20PXR_NAMESPACE_OPEN_SCOPE
21
22#define EF_LEAF_TOKENS \
23 (in)
24
25TF_DECLARE_PUBLIC_TOKENS(EfLeafTokens, EF_API, EF_LEAF_TOKENS);
26
37class EF_API_TYPE EfLeafNode final : public VdfNode
38{
39public:
43 static bool IsALeafNode(const VdfNode &node) {
44 return node.GetNumOutputs() == 0 && node.IsA<EfLeafNode>();
45 }
46
50 static EfLeafNode* AsALeafNode(VdfNode *const node) {
51 if (node && node->GetNumOutputs() == 0) {
52 return dynamic_cast<EfLeafNode *>(node);
53 }
54 return nullptr;
55 }
56
60 static const EfLeafNode* AsALeafNode(const VdfNode *const node) {
61 if (node && node->GetNumOutputs() == 0) {
62 return dynamic_cast<const EfLeafNode *>(node);
63 }
64 return nullptr;
65 }
66
70 static const VdfOutput *GetSourceOutput(const VdfNode &node);
71
75 static VdfMaskedOutput GetSourceMaskedOutput(const VdfNode &node);
76
77 EF_API
78 EfLeafNode(VdfNetwork *network, TfType inputType);
79
80private:
81
83 virtual void Compute(const VdfContext &context) const override;
84
85 // Only a network is allowed to delete nodes.
86 virtual ~EfLeafNode();
87};
88
89inline const VdfOutput *
91{
92 const VdfInput *const input = node.GetInputsIterator().begin()->second;
93 if (input && input->GetNumConnections() > 0) {
94 return &(*input)[0].GetSourceOutput();
95 }
96 return nullptr;
97}
98
99inline VdfMaskedOutput
101{
102 const VdfInput *const input = node.GetInputsIterator().begin()->second;
103 if (input && input->GetNumConnections() > 0) {
104 return (*input)[0].GetSourceMaskedOutput();
105 }
106 return VdfMaskedOutput();
107}
108
109PXR_NAMESPACE_CLOSE_SCOPE
110
111#endif
A terminal node, which is never executed.
Definition: leafNode.h:38
static const EfLeafNode * AsALeafNode(const VdfNode *const node)
If node is an EfLeafNode, returns a pointer to it as a const EfLeafNode*.
Definition: leafNode.h:60
static const VdfOutput * GetSourceOutput(const VdfNode &node)
Returns the single output the leaf node sources its value from.
Definition: leafNode.h:90
static bool IsALeafNode(const VdfNode &node)
Returns true if the given node is an EfLeafNode.
Definition: leafNode.h:43
static EfLeafNode * AsALeafNode(VdfNode *const node)
If node is an EfLeafNode, returns a pointer to it as an EfLeafNode*.
Definition: leafNode.h:50
static VdfMaskedOutput GetSourceMaskedOutput(const VdfNode &node)
Returns the single masked output the leaf node sources its value from.
Definition: leafNode.h:100
TfType represents a dynamic runtime type.
Definition: type.h:48
A context is the parameter bundle passed to callbacks of computations.
Definition: context.h:40
A VdfInput is used to connect a VdfNode to one or more VdfNodes' outputs.
Definition: input.h:36
size_t GetNumConnections() const
Returns the number of connections for this input.
Definition: input.h:58
Class to hold on to an externally owned output and a mask.
Definition: maskedOutput.h:32
A VdfNetwork is a collection of VdfNodes and their connections.
Definition: network.h:60
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
size_t GetNumOutputs() const
Returns the number of outputs that this node currently has.
Definition: node.h:283
bool IsA() const
Returns true, if this node is of type TYPE.
Definition: node.h:147
virtual void Compute(const VdfContext &context) const =0
This is the method called to perform computation.
A VdfOutput represents an output on a node.
Definition: output.h:32
This file defines some macros that are useful for declaring and using static TfTokens.
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
Definition: staticTokens.h:92