Loading...
Searching...
No Matches
ExecIrControllerBuilder Class Reference

Builder class used to register invertible controller computations. More...

#include <controllerBuilder.h>

Public Types

using Callback = ExecIrResult(*)(const VdfContext &)
 The type for forward and inverse controller computation calbacks.
 

Public Member Functions

EXECIR_API ExecIrControllerBuilder (ExecComputationBuilder &self, Callback forwardCallback, Callback inverseCallback)
 Constructs a builder that is used to register computations that implement an invertible controller.
 
template<typename ValueType >
void InvertibleInputAttribute (const TfToken &attributeName)
 Registers an invertible input attribute.
 
template<typename ValueType >
void NonInvertibleInputAttribute (const TfToken &attributeName)
 Registers a non-invertible input attribute.
 
template<typename ValueType >
void InvertibleInputAttributes (const TfTokenVector &attributeNames)
 Registers multiple invertible input attributes.
 
template<typename ValueType >
void InvertibleOutputAttribute (const TfToken &attributeName)
 Registers an invertible output attribute.
 
template<typename ValueType >
void InvertibleOutputAttributes (const TfTokenVector &attributeNames)
 Registers multiple invertible output attributes.
 
template<typename ValueType >
void SwitchAttribute (const TfToken &attributeName)
 Registers a switch attribute.
 
template<typename ValueType >
void PassthroughAttributes (const TfToken &inAttributeName, const TfToken &outAttributeName)
 Registers a pair of input, output passthrough attributes.
 

Detailed Description

Builder class used to register invertible controller computations.

This class can only be used in the context of schema computation registration. The constructor takes the self builder object that is defined by the EXEC_REGISTER_COMPUTATIONS_FOR_SCHEMA macro. The constructor also takes the callbacks that implement the forward and inverse computations for the controller. The client uses member functions to register controller attributes as inputs, outputs, switches, etc. (see the documentation on the corresonding registration methods for details). These registrations, in turn, generate the computation inputs for the callbacks (as documented in the member function documentation), as well as other computations that are required to implement invertible controllers within OpenExec.

Example

// A simple invertible controller where the forward compute takes an input
// value and produces an output value that is one greater than the input.
// Forward declare forward and inverse functions.
static ExecIrResult _ForwardCompute(const VdfContext &ctx);
static ExecIrResult _InverseCompute(const VdfContext &ctx);
{
auto builder = ExecIrControllerBuilder(
self, _ForwardCompute, _InverseCompute);
// Register one invertible input and one invertible output.
builder.InvertibleInputAttribute(_tokens->input);
builder.InvertibleOutputAttribute(_tokens->output);
}
// The forward compute callback function.
//
// The VdfContext provides values for all inputs. The function is
// responsible for computing all output values, returning the values in a
// map from output name to VtValue.
//
_ForwardCompute(const VdfContext & ctx)
{
// Extract the input value.
const double input = ctx.GetInputValue<double>(_tokens->input);
// Create a map to store the results.
ExecIrResult result;
// Compute and store the output value.
result[_tokens->output] = input + 1.0;
return result;
}
// The inverse compute callback function.
//
// The context provides desired values for all invertible outputs. The
// function is responsible for computing the invertible input values that
// satisfy the desired output values, returning the values in a map from
// invertible input name to VtValue.
//
_InverseCompute(const VdfContext & ctx)
{
// Extract the output value.
const double output = ctx.GetInputValue<double>(_tokens->output);
// Create a map to store the results
ExecIrResult result;
// Compute and store the input value
result[_tokens->input] = output - 1.0;
return result;
}
EXECIR_API ExecIrControllerBuilder(ExecComputationBuilder &self, Callback forwardCallback, Callback inverseCallback)
Constructs a builder that is used to register computations that implement an invertible controller.
This is a space efficient container that mimics the TfHashMap API that uses a vector for storage when...
A context is the parameter bundle passed to callbacks of computations.
Definition context.h:40
VdfByValueOrConstRef< T > GetInputValue(const TfToken &name) const
Returns a value from the input named name of type T.
Definition context.h:299
#define EXEC_REGISTER_COMPUTATIONS_FOR_SCHEMA(SchemaType)
Initiates registration of exec computations for the schema SchemaType.

Definition at line 159 of file controllerBuilder.h.

Member Typedef Documentation

◆ Callback

using Callback = ExecIrResult(*)(const VdfContext &)

The type for forward and inverse controller computation calbacks.

Definition at line 163 of file controllerBuilder.h.

Constructor & Destructor Documentation

◆ ExecIrControllerBuilder()

EXECIR_API ExecIrControllerBuilder ( ExecComputationBuilder & self,
Callback forwardCallback,
Callback inverseCallback )

Constructs a builder that is used to register computations that implement an invertible controller.

self is the builder that is defined by EXEC_REGISTER_COMPUTATIONS_FOR_SCHEMA. forwardCallback and inverseCallback are the callbacks that define the forward and inverse computations that implement the controller to be registered by the constructed instance.

Member Function Documentation

◆ InvertibleInputAttribute()

template<typename ValueType >
void InvertibleInputAttribute ( const TfToken & attributeName)

Registers an invertible input attribute.

  • Invertible input attributes provide input to the forward computation.
  • Invertible input values are produced by the inverse computation.

Definition at line 288 of file controllerBuilder.h.

◆ InvertibleInputAttributes()

template<typename ValueType >
void InvertibleInputAttributes ( const TfTokenVector & attributeNames)
inline

Registers multiple invertible input attributes.

Definition at line 208 of file controllerBuilder.h.

◆ InvertibleOutputAttribute()

template<typename ValueType >
void InvertibleOutputAttribute ( const TfToken & attributeName)

Registers an invertible output attribute.

  • Output attributes produce computed values that are the results of the forward computation and provide input to the inverse computation.

TODO: Non-invertible output attributes are not yet implemented.

Definition at line 375 of file controllerBuilder.h.

◆ InvertibleOutputAttributes()

template<typename ValueType >
void InvertibleOutputAttributes ( const TfTokenVector & attributeNames)
inline

Registers multiple invertible output attributes.

Definition at line 231 of file controllerBuilder.h.

◆ NonInvertibleInputAttribute()

template<typename ValueType >
void NonInvertibleInputAttribute ( const TfToken & attributeName)

Registers a non-invertible input attribute.

  • All input attributes provide input to the forward computation.
  • Non-invertible input attributes also provide input to the inverse computation.

Definition at line 360 of file controllerBuilder.h.

◆ PassthroughAttributes()

template<typename ValueType >
void PassthroughAttributes ( const TfToken & inAttributeName,
const TfToken & outAttributeName )

Registers a pair of input, output passthrough attributes.

  • The passthrough input attribute provides input to both the forward and inverse computations.
  • The passthrough output attribute produces the value of the input attribute.

Definition at line 439 of file controllerBuilder.h.

◆ SwitchAttribute()

template<typename ValueType >
void SwitchAttribute ( const TfToken & attributeName)

Registers a switch attribute.

Switch attributes hold values that change the behavior of the forward and inverse computations.

  • Switch attributes provide input to both the forward and the inverse computation.

Definition at line 423 of file controllerBuilder.h.


The documentation for this class was generated from the following file: