Parameter helpers

When you write generic operators, you often must obtain the list of types and expressions that are associated with the parameter expressions. The SPL code generation framework provides helper functions within the SPL::CodeGen module to simplify this task.

SPL operators can be configured by user-specified parameters when these operators are used in the source code for an SPL application. A parameter can be assigned a list of expressions.

Besides helper functions, you can perform the same common task using the APIs of the SPL::Operator::Instance::Parameter and Expression classes.

The getParameterCppTypes function takes a Parameter object as input and returns a list of C++ types corresponding to the expressions associated with the parameter object. This function is especially useful for passing types to the emitClass function.

The getParameterCppInitializer function takes a Parameter object as input and returns a C++ expression that can be used as the constructor initializer for an object of type that is returned by the emitClass function.

Continuing with the example from: Helper class generation

// This is an <opname>_cpp.cgt file
<%
 my $partitionByParam = $model->getParameterByName("partitionBy");
 my $partitionByInitializer = SPL::CodeGen::getParameterCppInitializer($partitionByParam);
%>
void MY_OPERATOR::process(Tuple const & tuple, uint32_t port) {
  PartitionByType partition(<%=$partitionByInitializer%>);
  ...
}