HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
speculationExecutorBase.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_SPECULATION_EXECUTOR_BASE_H
8 #define PXR_EXEC_VDF_SPECULATION_EXECUTOR_BASE_H
9 
10 ///\file
11 
12 #include "pxr/pxr.h"
13 
14 #include "pxr/exec/vdf/api.h"
16 
18 
19 ///////////////////////////////////////////////////////////////////////////////
20 ///
21 /// \class VdfSpeculationExecutor
22 ///
23 /// \brief A common base class for all speculation executors.
24 ///
26 {
27 public:
28 
29  /// Destructor.
30  ///
31  VDF_API
32  virtual ~VdfSpeculationExecutorBase();
33 
34  /// Returns true if the given node is a not that this executor (or any
35  /// one of its parents) is speculating about
36  ///
37  inline bool IsSpeculatingNode(const VdfNode *node) const;
38 
39  /// Returns the first executor in the executor hierarchy that is NOT a
40  /// speculation executor.
41  ///
43  return _parentNonSpeculationExecutor;
44  }
45 
46 protected:
47 
48  /// Constructor.
49  ///
50  VDF_API
52  const VdfExecutorInterface *parentExecutor);
53 
54  /// Set this executors speculating node.
55  ///
56  void _SetSpeculationNode(const VdfNode *speculationNode) {
57  _speculationNode = speculationNode;
58  }
59 
60 private:
61 
62  // The speculation node using this executor.
63  const VdfNode *_speculationNode;
64 
65  // The parent speculation executor.
66  const VdfSpeculationExecutorBase *_parentSpeculationExecutor;
67 
68  // The first parent executor that is not a speculation executor.
69  const VdfExecutorInterface *_parentNonSpeculationExecutor;
70 
71 };
72 
73 ///////////////////////////////////////////////////////////////////////////////
74 
75 bool
77 {
78  bool isSpeculatingNode = false;
79  const VdfSpeculationExecutorBase *speculationExecutor = this;
80  while (speculationExecutor) {
81  isSpeculatingNode |= (node == speculationExecutor->_speculationNode);
82  speculationExecutor = speculationExecutor->_parentSpeculationExecutor;
83  }
84  return isSpeculatingNode;
85 }
86 
88 
89 #endif
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
Definition: node.h:52
const VdfExecutorInterface * GetNonSpeculationParentExecutor() const
#define VDF_API
Definition: api.h:25
bool IsSpeculatingNode(const VdfNode *node) const
#define VDF_API_TYPE
Definition: api.h:26
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Abstract base class for classes that execute a VdfNetwork to compute a requested set of values...
void _SetSpeculationNode(const VdfNode *speculationNode)