Returning Object Type and Validity
Three IDL routines allow you to obtain information about an existing object: OBJ_CLASS, OBJ_ISA, and OBJ_VALID.
OBJ_CLASS
Use the OBJ_CLASS function to obtain the class name of a specified object, or to obtain the names of a specified object's direct superclasses. For example, if we create the following class structures:
We can now create an object and use OBJ_CLASS to determine its class and superclass membership.
IDL prints:
Or you can print as superclasses:
IDL prints:
See "OBJ_CLASS" (IDL Reference Guide) for further details.
OBJ_ISA
Use the OBJ_ISA function to determine whether a specified object is an instance or subclass of a specified object. For example, if we have defined the object A as above:
IDL prints:
See "OBJ_ISA" (IDL Reference Guide) for further details.
OBJ_VALID
Use the OBJ_VALID function to verify that one or more object references refer to valid and currently existing object heap variables. If supplied with a single object reference as its argument, OBJ_VALID returns TRUE (1) if the reference refers to a valid object heap variable, or FALSE (0) otherwise. If supplied with an array of object references, OBJ_VALID returns an array of TRUE and FALSE values corresponding to the input array. For example:
; Create a class structure. struct = {cname, data:0.0} ; Create a new object. A = OBJ_NEW('CNAME') IF OBJ_VALID(A) PRINT, "A refers to a valid object." $ ELSE PRINT, "A does not refer to a valid object."
IDL prints:
If we destroy the object:
; Destroy the object. OBJ_DESTROY, A IF OBJ_VALID(A) PRINT, "A refers to a valid object." $ ELSE PRINT, "A does not refer to a valid object."
IDL prints:
See "OBJ_VALID" (IDL Reference Guide) for further details.