HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cacheView.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_EXEC_CACHE_VIEW_H
8 #define PXR_EXEC_EXEC_CACHE_VIEW_H
9 
10 #include "pxr/pxr.h"
11 
12 #include "pxr/exec/exec/api.h"
13 
14 #include "pxr/base/tf/span.h"
16 
17 #include <memory>
18 #include <optional>
19 
21 
22 class Exec_ValueExtractor;
24 class VdfMaskedOutput;
25 class VtValue;
26 
27 /// A view into values cached by ExecSystem.
28 ///
29 /// This class is not intended to be used directly by users but as part of
30 /// higher level libraries. Cache views must not outlive the ExecSystem or
31 /// request from which they were built.
32 ///
34 {
35 public:
36  /// Constructs an invalid cache view.
37  Exec_CacheView() = default;
38 
39  /// Exec_CacheView is move-only.
40  Exec_CacheView(const Exec_CacheView &) = delete;
41 
42  /// Constructs a cache view from another.
43  ///
44  /// The other cache view becomes invalid.
45  ///
46  EXEC_API
48 
49  EXEC_API
51 
52  /// Returns the computed value for the provided extraction \p index.
53  ///
54  /// Emits an error and returns an empty value if the \p index is not
55  /// evaluated.
56  ///
57  EXEC_API
58  VtValue Get(int index) const;
59 
60 private:
61  friend class Exec_RequestImpl;
62 
63  // Constructs a cache view that extracts computed values from
64  // \p dataManager. The data manager must outlive the cache view.
66  const VdfDataManagerFacade dataManager,
69 
70  // Constructs a cache view that assumes ownership of an \p executor, so that
71  // it remains valid while computed values are extracted from it.
73  std::unique_ptr<VdfExecutorInterface> &&executor,
76 
77 private:
78  std::optional<const VdfDataManagerFacade> _dataManager;
79  const TfSpan<const VdfMaskedOutput> _outputs;
80  const TfSpan<const Exec_ValueExtractor> _extractors;
81  std::unique_ptr<VdfExecutorInterface> _executor;
82 };
83 
85 
86 #endif
EXEC_API VtValue Get(int index) const
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
Exec_CacheView()=default
Constructs an invalid cache view.
#define EXEC_API
Definition: api.h:25
EXEC_API ~Exec_CacheView()
Class to hold on to an externally owned output and a mask.
Definition: maskedOutput.h:31
GLuint index
Definition: glcorearb.h:786
#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: value.h:89