HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
builtinComputations.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_BUILTIN_COMPUTATIONS_H
8 #define PXR_EXEC_EXEC_BUILTIN_COMPUTATIONS_H
9 
10 #include "pxr/pxr.h"
11 
12 #include "pxr/exec/exec/api.h"
13 
14 #include "pxr/base/tf/staticData.h"
15 #include "pxr/base/tf/token.h"
16 
18 
19 class Exec_BuiltinComputationRegistry;
20 
21 /// Tokens representing the built-in computations available on various provider
22 /// types.
23 ///
24 /// \defgroup group_Exec_Builtin_Computations Builtin Exec Computations
25 ///
26 /// These tokens can all be used in [input
27 /// registrations](#group_Exec_InputRegistrations) to request input values for
28 /// plugin computations. They can also be passed to compute APIs to request
29 /// computed values.
30 ///
31 /// These computation tokens are publicly accessible by dereferencing the
32 /// `ExecBuiltinComputationTokens` static data.
33 ///
35 {
36 public:
37  EXEC_API
39 
40  /// \defgroup group_Mf_ExecBuiltinComputations_Stage Stage Computations
41  ///
42  /// Builtin computations for computing information about the provider's
43  /// stage.
44  ///
45  /// \ingroup group_Exec_Builtin_Computations
46  /// @{
47 
48  /// Computes the current time on the stage.
49  ///
50  /// \returns an EfTime value.
51  ///
52  /// \note
53  /// The computation provider must be the stage.
54  ///
55  /// # Example
56  ///
57  /// ```{.cpp}
58  /// self.PrimComputation(_tokens->myComputation)
59  /// .Callback<EfTime>(&_MyCallback)
60  /// .Inputs(
61  /// Stage()
62  /// .Computation<EfTime>(ExecBuiltinComputations->computeTime)
63  /// );
64  /// ```
65  ///
66  /// \hideinitializer
68 
69  /// @} // Stage computations
70 
71 
72  /// \defgroup group_Exec_Attribute_Comptuations Attribute Computations
73  ///
74  /// Builtin computations for computing information about attributes.
75  ///
76  /// \ingroup group_Exec_Builtin_Computations
77  /// @{
78 
79  /// Computes the provider attribute's value.
80  ///
81  /// \returns a value whose type is the provider attribute's scalar value
82  /// type. If the attribute has registered an
83  /// [attribute expression](#ExecComputationBuilder::AttributeExpression),
84  /// this may produce a value of any type.
85  ///
86  /// \note
87  /// The computation provider must be an attribute.
88  ///
89  /// # Example
90  ///
91  /// ```{.cpp}
92  /// self.PrimComputation(_tokens->myComputation)
93  /// .Callback<double>(&_MyCallback)
94  /// .Inputs(
95  /// Attribute(_tokens->myAttribute)
96  /// .Computation<double>(ExecBuiltinComputations->computeValue)
97  /// .Required()
98  /// );
99  /// ```
100  ///
101  /// \hideinitializer
103 
104  /// Computes the provider attribute's resolved value as authored in scene
105  /// description.
106  ///
107  /// This computation always produces the resolved value of an attribute,
108  /// even if an attribute has registered an
109  /// [attribute expression](#ExecComputationBuilder::AttributeExpression).
110  ///
111  /// \returns a value whose type is the provider attribute's scalar value
112  /// type.
113  ///
114  /// # Example
115  ///
116  /// ```{.cpp}
117  /// self.PrimComputation(_tokens->myComputation)
118  /// .Callback<double>(&_MyCallback)
119  /// .Inputs(
120  /// Attribute(_tokens->myAttribute)
121  /// .Computation(ExecBuiltinComputations->computeResolvedValue)
122  /// );
123  /// ```
124  ///
125  /// \hideinitializer
127 
128  /// Computes the provider's scene path.
129  ///
130  /// \returns the path of the provider object, as an SdfPath.
131  ///
132  /// # Example
133  ///
134  /// ```{.cpp}
135  /// self.PrimComputation(_tokens->pathAsString)
136  /// .Callback<std::string>(+[](const VdfContext &ctx) {
137  /// return ctx.GetInputValue<SdfPath>(
138  /// ExecBuiltinComputations->computePath).GetString();
139  /// })
140  /// .Inputs(
141  /// Computation(ExecBuiltinComputations->computePath)
142  /// );
143  /// ```
144  ///
145  /// \hideinitializer
147 
148  /// @} // Attribute computations
149 
150 private:
151  Exec_BuiltinComputationTokens(Exec_BuiltinComputationRegistry &registry);
152 };
153 
154 // Used to publicly access builtin computation tokens.
155 EXEC_API
157 
159 
160 #endif
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
EXEC_API Exec_BuiltinComputationTokens()
Definition: token.h:70
EXEC_API TfStaticData< Exec_BuiltinComputationTokens > ExecBuiltinComputations
#define EXEC_API
Definition: api.h:25
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74