HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
attributeQuery.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_ESF_ATTRIBUTE_QUERY_H
8 #define PXR_EXEC_ESF_ATTRIBUTE_QUERY_H
9 
10 /// \file
11 
12 #include "pxr/pxr.h"
13 
14 #include "pxr/exec/esf/api.h"
16 
17 #include "pxr/base/ts/spline.h"
18 #include "pxr/base/vt/value.h"
19 #include "pxr/usd/sdf/path.h"
20 #include "pxr/usd/usd/timeCode.h"
21 
22 #include <optional>
23 
25 
26 /// Attribute query abstraction for scene adapter implementations.
27 ///
28 /// This abstraction closely resembles the UsdAttributeQuery.
29 ///
30 /// The public methods of this class are called during initialization of inputs
31 /// to the execution network and during authored value invalidation.
32 ///
35 {
36 public:
38 
39  /// Returns `true` if the query object is valid.
40  ///
41  /// \see UsdAttributeQuery::IsValid
42  ///
43  bool IsValid() const {
44  return _IsValid();
45  }
46 
47  /// Returns the path of the attribute that is being queried.
48  SdfPath GetPath() const {
49  return _GetPath();
50  }
51 
52  /// Reinitialize the query object from the attribute it was initially
53  /// constructed with.
54  ///
55  /// This enables clients to "revive" the query object after changes that
56  /// affect value resolution previously invalidated it.
57  ///
58  void Initialize() {
59  _Initialize();
60  }
61 
62  /// Gets the resolved value of the attribute at a given time.
63  ///
64  /// \see UsdAttribute::Get
65  ///
66  bool Get(VtValue *value, UsdTimeCode time) const {
67  return _Get(value, time);
68  }
69 
70  /// Gets the authored spline if the strongest opinion is a spline.
71  ///
72  /// \see UsdAttribute::GetSpline
73  ///
74  std::optional<TsSpline> GetSpline() const {
75  return _GetSpline();
76  }
77 
78  /// Returns `true` if the attribute value might be varying over time, and
79  /// `false` if the value is *definitely* not varying over time.
80  ///
81  /// \see UsdAttribute::ValueMightBeTimeVarying
82  ///
83  bool ValueMightBeTimeVarying() const {
84  return _ValueMightBeTimeVarying();
85  }
86 
87  /// Returns `true` if the resolved value of the attribute is different on
88  /// time \p from and time \p to.
89  ///
90  /// \note
91  /// This does *not* examine times between \p from and \p to in order to
92  /// determine if there is a difference in resolved values on in-between
93  /// times.
94  ///
95  bool IsTimeVarying(UsdTimeCode from, UsdTimeCode to) const {
96  return _IsTimeVarying(from, to);
97  }
98 
99 protected:
100  /// This constructor may only be called by the scene adapter implementation.
101  EsfAttributeQueryInterface() = default;
102 
103 private:
104  // These methods must be implemented by the scene adapter implementation.
105  virtual bool _IsValid() const = 0;
106  virtual SdfPath _GetPath() const = 0;
107  virtual void _Initialize() = 0;
108  virtual bool _Get(VtValue *value, UsdTimeCode time) const = 0;
109  virtual std::optional<TsSpline> _GetSpline() const = 0;
110  virtual bool _ValueMightBeTimeVarying() const = 0;
111  virtual bool _IsTimeVarying(UsdTimeCode from, UsdTimeCode to) const = 0;
112 };
113 
114 /// Holds an implementation of EsfAttributeQueryInterface in a fixed-size
115 /// buffer.
116 ///
117 /// The buffer is large enough to fit an implementation that wraps a
118 /// UsdAttributeQuery. The size is specified as an integer literal to prevent
119 /// introducing Usd as a dependency.
120 ///
122  : public EsfFixedSizePolymorphicHolder<EsfAttributeQueryInterface, 168>
123 {
124 public:
126 };
127 
129 
130 #endif
GT_API const UT_StringHolder time
bool IsTimeVarying(UsdTimeCode from, UsdTimeCode to) const
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
GLsizei const GLfloat * value
Definition: glcorearb.h:824
#define ESF_API_TYPE
Definition: api.h:26
SdfPath GetPath() const
Returns the path of the attribute that is being queried.
bool Get(VtValue *value, UsdTimeCode time) const
std::optional< TsSpline > GetSpline() const
Definition: path.h:280
bool ValueMightBeTimeVarying() const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
#define ESF_API
Definition: api.h:25
Definition: value.h:89