
158 Chapter 7: Creating an Operation
Creating a New Data-Centric Operation iTool Developer’s Guide
NAME='Example Data Operation', ICON='sum', $
_EXTRA = _extra) NE 1) THEN $
RETURN, 0
; Register a property that holds a byte value.
self->RegisterProperty, 'ByteTop', $
DESCRIPTION='An example property', $
NAME='Byte Threshold', SENSITIVE = 1
; Unhide the SHOW_EXECUTION_UI property.
self->SetPropertyAttribute, 'SHOW_EXECUTION_UI', HIDE=0
; Return success
RETURN, 1
END
Discussion
The
ExampleDataOp class is based on the IDLitDataOperation class (discussed in
“Subclassing from the IDLitDataOperation Class” on page 153). As a result, all of
the standard features of an iTool data operation are already present. We don’t define
any keyword values to be handled explicitly in the Init method, but we do use the
keyword inheritance mechanism to pass keyword values through to methods called
within the Init method. The
ExampleDataOp Init method does the following things:
1. Calls the Init method of the superclass, IDLitDataOperation. We use the
TYPES keyword to specify that our operation works on data that has the iTool
data type
'IDLIMAGE', provide a name for the object instance, and provide an
icon. Finally, we use the _EXTRA keyword inheritance mechanism to pass
through any keywords provided when the
ExampleDataOp Init method is
called.
2. Registers a property that holds a byte value.
3. Returns the integer 1, indicating successful initialization.
Creating a Cleanup Method
The operation class Cleanup method handles any cleanup required by the operation
object, and should do the following:
• destroy any pointers or objects created by the operation
• call the superclass’ Cleanup method
Calling the superclass’ cleanup method will destroy any objects created when the
superclass was initialized.