
Chapter 7: Creating an Operation 159
iTool Developer’s Guide Creating a New Data-Centric Operation
Note
If your operation class is based on the IDLitDataOperation class, and does not
create any pointers or objects of its own, the Cleanup method is not strictly
required. It is always safest, however, to create a Cleanup method that calls the
superclass’ Cleanup method.
See “IDLitDataOperation::Cleanup” (IDL Reference Guide) for additional details.
Example Cleanup Method
The following example code shows a very simple Cleanup method for the
ExampleDataOp operation:
PRO ExampleDataOp::Cleanup
; Clean up superclass
self->IDLitDataOperation::Cleanup
END
Discussion
Since our operation’s instance data does not include any pointers or object references,
the Cleanup method simply calls the superclass Cleanup method.
Creating an Execute Method
The operation class Execute method does the computational work of a data-centric
operation; it is called automatically when the iTool user requests an operation based
on the IDLitDataOperation class. The Execute method must accept a single argument
that contains the raw data associated with an item selected by the user.
The fact that the raw data is passed to the execute method means that the Execute
method itself does not need to “unpack” a data object before performing the
operations, allowing rapid and simple operation execution. For example, if the
operation expects data of the iTools data type
IDLARRAY2D, the iTool system will
include the selected two-dimensional array as the Data argument.
The actual processing performed by the Execute method depends entirely on the
operation.
Example Execute Method
The following example code shows a simple Execute method for the
ExampleDataOp operation, which will invert the values of the supplied data. Since