user manual

242 Chapter 9: Creating a File Reader
Creating a New File Reader iTool Developer’s Guide
Note
Any property registered with a call to the RegisterProperty method must be listed as
a keyword to the SetProperty method either of the visualization class or one of its
superclasses.
Note
A file reader need not register any properties at all, if the read operation is simple.
Many of the standard iTool image file readers work without registering any
properties.
See “IDLitReader::SetProperty (IDL Reference Guide) for additional details.
Example SetProperty Method
PRO ExampleReader::SetProperty, _REF_EXTRA = _extra
IF (N_ELEMENTS(_extra) GT 0) THEN $
self->IDLitReader::SetProperty, _EXTRA = _extra
END
Discussion
The SetProperty method first defines the keywords it will accept. There must be a
keyword for each property of the visualization type. Since the file reader we are
creating has no properties of its own, no keywords are explicitly defined. The
keyword inheritance mechanism allows properties to be set on the
ExampleReader
class’ superclasses without knowing the names of the properties.
Using the N_ELEMENTS function, we check to see whether any properties were
specified via the keyword inheritance mechanism. If any keywords were specified,
we call the superclass’ SetProperty method, passing in all of the keywords stored in
the
_extra structure.
Creating an IsA Method
The file reader IsA method must accept a string containing the name of the file to be
read as its only parameter, and must determine whether the file is of the proper type
to be read by your file reader. If the file is of the correct type, the IsA method must
return 1; if the file is not of the correct type, the IsA method should display an error
message and return 0.
See “IDLitReader::IsA” (IDL Reference Guide) for additional details.