Loading...
Searching...
No Matches

A value specifier is an element of an input registration that identifies the value that is requested from a given computation provider. More...

+ Collaboration diagram for Value Specifiers:

Functions

template<typename ResultType >
ValueSpecifier Computation (const TfToken &computationName)
 See Computation().
 
template<typename ResultType >
ValueSpecifier Metadata (const TfToken &metadataKey)
 See Metadata().
 
template<typename ResultType >
ValueSpecifier ConnectionTargetedObjects (const TfToken &computationName)
 See ConnectionTargetedObjects().
 
template<typename ResultType >
ValueSpecifier TargetedObjects (const TfToken &computationName)
 After a Relationship() accessor, requests input values from the computation computationName of type ResultType on the objects targeted by the relationship.
 
 Computation (const TfToken &computationName)
 Requests an input value from the computation computationName of type ResultType.
 
 Metadata (const TfToken &metadataKey)
 Requests an input value from the metadata field indicated by metadataKey, of type ResultType.
 
 Constant (ValueType &&constantValue)
 Requests a constant input value of type ValueType.
 
 Constant (const ValueType &constantValue)
 
 NamespaceAncestor (const TfToken &computationName)
 On a prim computation, requests an input value from the computation computationName of type ResultType on the nearest namespace ancestor prim.
 
template<typename ResultType >
auto ConnectionTargetedObjects (const TfToken &computationName)
 As a direct input to an attribute computation or after an Attribute() accessor, requests input values from the computation computationName of type ResultType on the objects targeted by the attribute's connections.
 

Detailed Description

A value specifier is an element of an input registration that identifies the value that is requested from a given computation provider.

Each computation input registration must contain exactly one value specifier. A value specifier comes after a sequence of zero or more object accessors, which determine the provider. A value specifier may be followed by one or more input options.

Function Documentation

◆ Computation() [1/2]

ValueSpecifier Computation ( const TfToken computationName)
inline

See Computation().

Definition at line 499 of file computationBuilders.h.

◆ Computation() [2/2]

Computation ( const TfToken computationName)
inline

Requests an input value from the computation computationName of type ResultType.

The default input name is computationName; use InputName to specify a different input name.

Example

{
// Register a prim computation that returns the value of another
// prim computation.
self.PrimComputation(_tokens->myComputation)
.Callback<double>(+[](const VdfContext &ctx) {
const double *const valuePtr =
ctx.GetInputValuePtr<double>(_tokens->sourceComputation);
return valuePtr ? *valuePtr : 0.0;
})
.Inputs(
Computation<double>(_tokens->sourceComputation)
}
A context is the parameter bundle passed to callbacks of computations.
Definition: context.h:40
#define EXEC_REGISTER_COMPUTATIONS_FOR_SCHEMA(SchemaType)
Initiates registration of exec computations for the schema SchemaType.
Computation value specifier, valid for providing input to any computation.

Definition at line 864 of file computationBuilders.h.

◆ ConnectionTargetedObjects() [1/2]

ValueSpecifier ConnectionTargetedObjects ( const TfToken computationName)
inline

See ConnectionTargetedObjects().

Definition at line 559 of file computationBuilders.h.

◆ ConnectionTargetedObjects() [2/2]

auto ConnectionTargetedObjects ( const TfToken computationName)

As a direct input to an attribute computation or after an Attribute() accessor, requests input values from the computation computationName of type ResultType on the objects targeted by the attribute's connections.

The default input name is computationName; use InputName to specify a different input name.

Example

{
// Register an attribute computation on the attribute 'myAttr' that
// sums the results of the integer-valued 'computeValue' computations
// on the objects targeted by myAttr's connections.
self.AttributeComputation(_tokens->myAttr, _tokens->computeSum)
.Callback<int>(+[](const VdfContext &ctx) {
int sum = 0;
ExecBuiltinComputations->computeValue);
!it.IsAtEnd(); ++it) {
sum += *it;
}
return sum;
})
.Inputs(
ConnectionTargetedObjects<int>(
ExecBuiltinComputations->computeValue));
}
An iterator that provides read access to input values using a context.
Definition: readIterator.h:39
bool IsAtEnd() const
Returns true if the iterator is done iterating and false otherwise.
Definition: readIterator.h:95

Definition at line 1206 of file computationBuilders.h.

◆ Constant() [1/2]

Constant ( const ValueType &  constantValue)
inline

Definition at line 1034 of file computationBuilders.h.

◆ Constant() [2/2]

Constant ( ValueType &&  constantValue)
inline

Requests a constant input value of type ValueType.

Note
No default input name is assigned. Constant(value) must be followed by .InputName(name).

This kind of input isn't necessarily useful when used with a self-contained computation definition. But it becomes useful for more complicated registrations, where one piece of code registers a callback that configures its evaluation-time behavior based on an input value and a separate piece of code registers a constant input that selects the desired behavior.

This can happen:

  • When computation definitions are assembled programatically by parameterized registration code that is called to register various versions of a computation, possibly for multiple schemas
  • When computation definitions are composed from registrations made for different schemas on the same prim (support for composed computation definitions is still TBD in OpenExec)
  • When computation registration is configured (also TBD), allowing registrations for a single schema to be dynamic, depending on metadata values that drive the configuration process

Simple Example

This simple example shows the mechanics of using a constant input, without being suggestive of how it might be useful.

{
// Register a prim computation that returns the value of its
// constant input.
self.PrimComputation(_tokens->myComputation)
.Callback<double>(+[](const VdfContext &ctx) {
return ctx.GetInputValue<double>(_tokens->myConstant);
})
.Inputs(
Constant(42.0).InputName(_tokens->myConstant));
}

Complex Example

This example demonstrate how more complicated registration code might make use of constant inputs to configure the behavior of a callback at evaluation time.

template <typename RegistrationType>
void RegisterCallback(RegistrationType &reg)
{
reg.Callback<std::string>(+[](const VdfContext &ctx) {
const TfToken &mode = ctx.GetInputValue<TfToken>(_tokens->mode);
if (mode == _tokens->mode1) {
return "Mode 1 selected";
else if (mode == _tokens->mode2) {
return "Mode 2 selected";
}
}
template <typename RegistrationType>
void RegisterInput(RegistrationType &reg, const int mode)
{
if (mode == 1) {
reg.Inputs(Constant(_tokens->mode1).InputName(_tokens->mode));
} else if (mode == 2) {
reg.Inputs(Constant(_tokens->mode2).InputName(_tokens->mode));
}
}
{
auto reg = self.PrimComputation(_tokens->myComputation);
// ...
RegisterCallback(reg);
// ...
RegisterInput(reg, mode);
}
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71

Definition at line 1018 of file computationBuilders.h.

◆ Metadata() [1/2]

ValueSpecifier Metadata ( const TfToken metadataKey)
inline

See Metadata().

Definition at line 514 of file computationBuilders.h.

◆ Metadata() [2/2]

Metadata ( const TfToken metadataKey)
inline

Requests an input value from the metadata field indicated by metadataKey, of type ResultType.

The default input name is metadataKey; use InputName to specify a different input name.

Example

self.PrimComputation(_tokens->computeDocMetadata)
.Callback<std::string>(+[](const VdfContext &ctx) {
return ctx.GetInputValue<std::string>(
SdfFieldKeys->Documentation);
})
.Inputs(
Metadata<std::string>(SdfFieldKeys->Documentation).Required()
);
Metadata value specifier, valid on a prim or attribute computation.

Definition at line 906 of file computationBuilders.h.

◆ NamespaceAncestor()

NamespaceAncestor ( const TfToken computationName)
inline

On a prim computation, requests an input value from the computation computationName of type ResultType on the nearest namespace ancestor prim.

The default input name is computationName; use InputName to specify a different input name.

Example

{
// Register a prim computation that finds the nearest namespace
// ancestor that defines a computation 'sourceComputation' with
// an `int` result type. If found, the result is the value of the
// ancestor compuation; otherwise, returns 0.
self.PrimComputation(_tokens->myComputation)
.Callback<int>(+[](const VdfContext &ctx) {
const int *const valuePtr =
ctx.GetInputValuePtr<int>(_tokens->sourceComputation);
return valuePtr ? *valuePtr : 0;
})
.Inputs(
NamespaceAncestor<int>(_tokens->sourceComputation));
}

Definition at line 1099 of file computationBuilders.h.

◆ TargetedObjects()

ValueSpecifier TargetedObjects ( const TfToken computationName)
inline

After a Relationship() accessor, requests input values from the computation computationName of type ResultType on the objects targeted by the relationship.

Relationship forwarding is applied, so if the relationship targets another relationship, the targets are transitively expanded, resulting in the ultimately targeted, non-relationship objects.

The default input name is computationName; use InputName to specify a different input name.

Example

{
// Register a prim computation that looks for the computation
// 'sourceComputation' on all targeted objects of the relationship
// 'myRel' and returns the number of matching targets.
self.PrimComputation(_tokens->myComputation)
.Callback<int>(+[](const VdfContext &ctx) {
VdfReadIterator<int> it(_tokens->sourceComputation);
return static_cast<int>(it.ComputeSize());
})
.Inputs(
Relationship(_tokens->myRel)
.TargetedObjects<int>(_tokens->sourceComputation));
}

Definition at line 623 of file computationBuilders.h.