user manual
Chapter 9: Creating a File Reader 239
iTool Developer’s Guide Creating a New File Reader
Passing Through Caller-Supplied Property Settings
If you have included the _REF_EXTRA keyword in your function definition, you can
use IDL’s keyword inheritance mechanism to pass any “extra” keyword values
included in the call to the Init method through to other routines. This mechanism
allows you to specify property settings when the Init method is called; simply include
each property’s keyword/value pair when calling the Init method, and include the
following in the body of the Init method:
IF (N_ELEMENTS(_extra) GT 0) THEN $
self->
MyReader
::SetProperty, _EXTRA = _extra
where MyReader is the name of your file reader class. This line has the effect of
passing any “extra” keyword values to your file reader class’ SetProperty method,
where they can either be handled directly or passed through to the SetProperty
methods of the superclasses of your class. See “Creating a SetProperty Method” on
page 241 for details.
Example Init Method
FUNCTION ExampleReader::Init, _REF_EXTRA = _extra
IF (self->IDLitReader::Init('ppm', $
DESCRIPTION="PPM File Reader", $
_EXTRA = _extra) EQ 0) THEN $
RETURN, 0
RETURN, 1
END
Discussion
The
ExampleReader class is based on the IDLitReader class (discussed in
“Subclassing from the IDLitReader Class” on page 234). As a result, all of the
standard features of an iTool file reader class 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
ExampleReader Init method does the following things:
1. Calls the Init method of the superclass, IDLitReader. We specify a list of
accepted filename extensions (only
ppm, in this case) via the Extensions
argument. We include a description of the reader via the DESCRIPTION
keyword. Finally, we use the _EXTRA keyword inheritance mechanism to
pass through any keywords provided when the
ExampleReader Init method
is called.