Developing custom operators¶
Before you begin
Check out the Types of operators page in the product documentation to evaluate options before proceeding.
If existing operators, including the Custom operator, are insufficent to implement application logic, you can create your own primitive operators using a lower-level programming language like C++, Java, or Python.
Additionally, if you have duplicate sets of operators within one or more applications, you may want to create a composite operator.
Primitive operators¶
The extension provides convenient commands to create primitive operators within your workspace.
Creating a C++ operator¶
- Right-click in an editor or File Explorer
- Hover over
SPL Project - Click
Create C++ Primitive Operatorto open a wizard form - Fill in the namespace, name, and whether to make the operator generic or not
- Click the
Create Operatorbutton
A namespace and operator directory will be created containing an operator model XML file and C++ code generation templates for your operator.
Proceed to implement the code and modify the operator model using these references:
Creating a Java operator¶
- Right-click in an editor or File Explorer
- Hover over
SPL Project - Click
Create Java Primitive Operatorto open a wizard form - Fill in the namespace, name, and processing pattern
- Click the
Create Operatorbutton
An implementation directory will be created containing the operator Java file.
Proceed to implement the code using these references:
Important
Unlike C++ and Python, Java primitive operators must be compiled before they can be used by the SPL compiler. The extension creates a Makefile with a javac command to demonstrate this, but any build system can be used.
Creating a Python operator¶
- Right-click in an editor or File Explorer
- Hover over
SPL Project - Click
Create Python Primitive Operatorto open a wizard form - Fill in the name and processing pattern
- Click the
Create Operatorbutton
An implementation directory will be created containing the operator Python file.
Proceed to implement the code using these references:
Using custom operators in your application¶
After implementing your operator logic, invoke the operator directly in your SPL application. For an example, see the C++ primitive operator at work application.
- After implementing your operator logic, compile the Java operator source code
- Invoke the operator directly in your SPL application
After implementing your operator logic, it is easiest to use a PythonOp operator in your SPL application to call the module. For an example, see the PythonOpScoring application.
Composite operators¶
Composite operators are defined in SPL files and can utilize the SPL language server.
Creating a composite operator¶
- Create or open an SPL file you want the composite operator in
- Activate IntelliSense: enter Ctrl+Space (Windows/Linux) or Cmd+Space (macOS)
- Type
Add new composite with ports - Hit Enter
Tip
Composite operators can have parameters similar to primitive operators. See the Composite operators tutorial in the product documentation and the Multiple composites at work sample for examples.
Using a composite operator in your application¶
After implementing your composite operator, invoke the operator directly in your SPL application. For an example, see the Multiple composites at work application.