Output tuple helpers

During code generation for generic operators, you often must initialize or assign an output tuple that is based on output attribute assignments that are captured in the operator instance model. SPL provides helper functions within the SPL::CodeGen module simplify this task.

The getOutputTupleCppInitializer function takes as an input an output port object and returns a C++ expression, which can be used to initialize a tuple for the port that is based on the output attribute assignments that are captured in the output port object. For example, given an output port with the tuple type tuple<int8 a, int8 b> and output attribute assignments output O : a = x, b = y;, the following is produced by the getOutputTupleCppInitializer($port) call: $iport0.get_x(), $iport0.get_y(), assuming x and y are from the first input port.

The getOutputTupleCppAssignments function takes as input a variable name and an output port object and returns a C++ code segment, which can be used to assign an already initialized tuple for the port with the output attribute assignments captured in the output port object. The variable that holds the tuple is assumed to have the name that is specified as an input to the function. For example, getOutputTupleCppAssignments("fred", $port) produces the following for the running example: fred.set_a($iport0.get_x()); fred.set_b($iport0.get_y());.