HDK
|
Custom PDG node definitions can evaluate parameters directly within a node callback implementation. At minimum, parameter evaluation only requires the name of the parameter, howevever it's also possible to specify a parameter index, a multiparm index, and a work item to use for expression evaluation.
The PDG_NodeCallback class supports evaluating parameters as strings, integers, floats, booleans, and as a generic templated function. String parameters can also be evaluated as a "raw" string, without variable or backtick expansion. All of the evaluation methods take the same parameters, return a value based on the evaluation type, and have a suffix in the name that identifies the evaluation type. For example, PDG_NodeCallback::evaluateS() or PDG_NodeCallback::evaluateB().
Failures during parameter evaluation are stashed on the thread-local evaluation context, and cause the callback to fail once it finishes executing. It's also possible to call the generic PDG_NodeCallback::evaluate() method, which returns a boolean value indicating whether the parameter evaluated directly and returns its evaluation output via a reference parameter. This variant of parameter evaluation is more verbose, but allows for more immediate handling for failures during evaluation.
For example:
The main way that data flows through a PDG graph is via work item attributes. Internally, a work item's command field, output files and environment variables are also implemented as attributes, but can also be accessed with higher level API.
The attributes on a work item are automatically inherited from their parent, or from their dependencies in the case of a partition. Attributes are stored in a PDG_AttributeMap owned by the work item. The attribute map has high level functions for setting and getting attribute values:
It's also possible to use the lower-level PDG_AttributeRef API to create a reference to a specific attribute on a work item. This is useful when performing multiple operations on the same attribute in bulk. The API also offers other utility methods, like converting values to strings.
The PDG_AttributRef behaves like a smart pointer – it has methods of its own, but also provides a way to access the underlying attribute object using the -> indirection operator.
It's also possible to create a read reference to an attribute without knowing the actual type. This limits the operations that can be performed, for example it's not possible to look up values, however it is possible to call generic methods from the reference itself. For example, this can be useful when writing a comparator function for sorting that operates on arbitrary data.
Writing to an attribute can also be done using the reference API, by acquiring a read-write reference: