IDL Object Overview
IDL objects are actually special heap variables, which means that they are global in scope and provide explicit user control over their lifetimes. Object heap variables can only be accessed via object references. Object references are discussed in this chapter. Heap variables in general are discussed in detail in "Heap Variables" (Application Programming).
Briefly, IDL provides support for the object concepts and mechanisms discussed in the following sections.
Classes and Instances
IDL objects are created as instances of a class, which is defined in the form of an IDL structure. The name of the structure is also the class name for the object. The instance data of an object is an IDL structure contained in the object heap variable, and can only be accessed by special functions and procedures, called methods, which are associated with the class. Class structures are discussed in Creating an Object Class Structure.
Encapsulation
Encapsulation is the ability to combine data and the routines that affect the data into a single object. IDL accomplishes this by only allowing access to an object's instance data via that object's methods. Data contained in an object is hidden from all but the object's own methods.
Methods
IDL allows you to define method procedures and functions using all of the programming tools available in IDL. Method routines are identified as belonging to an object class via a routine naming convention. Methods are discussed in detail in Creating Custom Object Method Routines.
Polymorphism
Polymorphism is the ability to create multiple object types that support the same operations. For example, many of IDL's graphics objects support an operation called "Draw," which sends graphics output to a specified place. The "Draw" operation is different in different contexts; sending a graphic to a printer is different from writing it to a file. Polymorphism allows the details of the differences to remain hidden—all you need to know is that a given object supports the "Draw" operation.
Inheritance
Inheritance is the ability of an object class to inherit the behavior of other object classes. This means that when writing a new object class that is very much like an existing object class, you need only program the functions that are different from those in the inherited class. IDL supports multiple inheritance—that is, an object can inherit qualities from any number of other existing object classes. Inheritance is discussed in detail in Inheritance.
Persistence
Persistence is the ability of objects to remain in existence in memory after they have been created, allowing you to alter their behavior or appearance after their creation. IDL objects persist until you explicitly destroy them, or until the end of the IDL session. In practice, object persistence removes the need (in traditional IDL programs) to re-execute IDL commands that create an item (a plot, for example) in order to change a detail of the item. For example, once you have created a graphic object containing a plot, you can alter any aspect of the plot "on the fly," without re-creating it. Similarly, having created an object containing a plot, you need not recreate the plot in order to print, save to an image file, or re-display it.
IDL objects also persist in the sense that you can use the SAVE and RESTORE routines to save and recreate objects between IDL sessions.