HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
rootNode.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_VDF_ROOT_NODE_H
8 #define PXR_EXEC_VDF_ROOT_NODE_H
9 
10 /// \file
11 
12 #include "pxr/pxr.h"
13 
14 #include "pxr/exec/vdf/api.h"
15 #include "pxr/exec/vdf/node.h"
16 
18 
19 /// \class VdfRootNode
20 ///
21 /// Base class for root nodes.
22 ///
23 /// A root node is a node that does not have any inputs and Compute() method.
24 /// Instead it has output(s) that are manually initialized. As such, the
25 /// outputs can never be passed. Downstream nodes might see no data (ie.
26 /// VdfContext::HasInputValue() will return false), if outputs have not been
27 /// initialized manually.
28 ///
30 {
31 public:
32 
33  /// Returns \c true if the given node is a VdfRootNode. This method is
34  /// an accelerated alternative to IsA<VdfRootNode>() or dynamic_cast.
35  ///
36  static bool IsARootNode(const VdfNode &node) {
37  return node.GetNumInputs() == 0 && node.IsA<VdfRootNode>();
38  }
39 
40 protected:
41 
42  /// Note that VdfRootNodes don't have inputs.
43  ///
45  VdfNetwork *network,
46  const VdfOutputSpecs &outputSpecs)
47  : VdfNode(network, VdfInputSpecs(), outputSpecs) {}
48 
49  VDF_API
50  ~VdfRootNode() override;
51 
52 private:
53 
54  // VdfRootNodes can't be computed. Therefore this class overrides
55  // the Compute() method finally which only produces an error message.
56  VDF_API
57  void Compute(const VdfContext &context) const override final;
58 };
59 
61 
62 #endif
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
bool IsA() const
Definition: node.h:147
Definition: node.h:52
virtual void Compute(const VdfContext &context) const =0
#define VDF_API
Definition: api.h:25
VdfRootNode(VdfNetwork *network, const VdfOutputSpecs &outputSpecs)
Definition: rootNode.h:44
size_t GetNumInputs() const
Definition: node.h:289
static bool IsARootNode(const VdfNode &node)
Definition: rootNode.h:36
#define VDF_API_TYPE
Definition: api.h:26
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74