HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dataManagerBasedSubExecutor.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_DATA_MANAGER_BASED_SUB_EXECUTOR_H
8 #define PXR_EXEC_VDF_DATA_MANAGER_BASED_SUB_EXECUTOR_H
9 
10 ///\file
11 
12 #include "pxr/pxr.h"
13 
17 
19 
20 class VdfNode;
21 
22 ///////////////////////////////////////////////////////////////////////////////
23 ///
24 /// \class VdfDataManagerSubBasedExecutor
25 ///
26 /// \brief Base class for executors that use a data manager, and support
27 /// reading caches from a parent executor.
28 ///
29 
30 template < typename DataManagerType, typename BaseClass >
32  public VdfDataManagerBasedExecutor < DataManagerType, BaseClass >
33 {
34  // Base type definition
36 
37 public:
38 
39  /// Default constructor
40  ///
42 
43  /// Construct with parent executor
44  ///
46  const VdfExecutorInterface *parentExecutor) :
47  Base(parentExecutor)
48  {}
49 
50  /// Destructor
51  ///
53 
54 protected:
55 
56  /// Returns a value for the cache that flows across \p connection.
57  ///
58  virtual const VdfVector *_GetInputValue(
59  const VdfConnection &connection,
60  const VdfMask &mask) const override {
61  // Lookup the output value in the local data manager, first!
62  if (const VdfVector *data =
63  Base::_dataManager.GetInputValue(connection, mask)) {
64  return data;
65  }
66 
67  // If available, also check the parent executor for the output value.
68  return _GetParentExecutorValue(connection.GetSourceOutput(), mask);
69  }
70 
71  /// Returns an output value for reading.
72  ///
74  const VdfOutput &output,
75  const VdfMask &mask ) const override {
76  // Lookup the output value in the local data manager, first!
77  if (const VdfVector *data =
78  Base::_dataManager.GetOutputValueForReading(
79  Base::_dataManager.GetDataHandle(output.GetId()), mask)) {
80  return data;
81  }
82 
83  // If available, also check the parent executor for the output value.
84  return _GetParentExecutorValue(output, mask);
85  }
86 
87 private:
88 
89  // Query the parent executor for an output value.
90  const VdfVector *_GetParentExecutorValue(
91  const VdfOutput &output,
92  const VdfMask &mask) const {
93  const VdfExecutorInterface *parentExecutor = Base::GetParentExecutor();
94  return parentExecutor
95  ? parentExecutor->GetOutputValue(output, mask)
96  : nullptr;
97  }
98 
99 };
100 
102 
103 #endif
GLboolean * data
Definition: glcorearb.h:131
virtual const VdfVector * _GetInputValue(const VdfConnection &connection, const VdfMask &mask) const override
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
Definition: node.h:52
VdfId GetId() const
Definition: output.h:100
A VdfMask is placed on connections to specify the data flowing through them.
Definition: mask.h:36
virtual const VdfVector * _GetOutputValueForReading(const VdfOutput &output, const VdfMask &mask) const override
VdfDataManagerBasedSubExecutor(const VdfExecutorInterface *parentExecutor)
GLint GLuint mask
Definition: glcorearb.h:124
const VdfOutput & GetSourceOutput() const
Returns the output (ie. source) for this connection.
Definition: connection.h:63
const VdfVector * GetOutputValue(const VdfOutput &output, const VdfMask &mask) const
#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...
Definition: format.h:1821