next up previous contents
Next: Class Methods Up: Users View of Previous: Users View of

The Class

Applications generally deal with data in a particular data model. The more general purpose the program the fewer requirements it makes that all elements of the data model be present. A subsetting program doesn't need to access astrometric data for example, but a source searching program certainly does.

ADI provides a environment for defining data models, the operations on those models and interfaces with the file system (if any). A particular data model is known as a class. gif Applications using ADI manipulate instances of a class, which correspond to particular datasets or other data objects. The creation of a new instance of a class is often called instantiation. For an application to be usable across multiple file formats it should access only the abstract data model, or at least make the requirement for data outside the model optional.

The class most frequently accessed by Asterix applications will be the binned dataset, which has a class name of BinDS . A class is a container for other named data objects called data members, each of which can itself be the instance of a class, or simply primitive data (integers, reals and so on). The crucial point is that data members need be neither present, nor have counterparts in the file format if they are. Such data members will often be referred to as virtual data members. Generally applications are unconcerned whether data are "real" or "virtual". A good example of a virtual data member is the Error array of a BinDS . In the NDF format their exists a variance array which ADI presents as a virtual data member by taking the square root of the values.

The ADI class system also exhibits inheritance, meaning that new classes can be derived from existing classes. Inheritance can use be used in two subtly different ways,

In the first new components are added to those of existing class. The new class inherits all the data from the its parent or superclass. gif This is not used that much in the proposed ADI design (and is only present because the method of implementation is identical to the second). Constraining behaviour allows a new class to be defined where the the values of the class data members can take on only a subset of the values in the superclass. This subsetting can occur explicitly be setting the values of data members to specific values in the new class definition, or implicitly be allowing procedures which operate on the new class to constrain the values of those members. The example below demonstrates both aspects of inheritance using a pseudo-class definition,
   CLASS Array                          ; top-level class, no inheritance
     _INTEGER    ndim
     _INTEGER    dims[ndim]
     <NUMERIC>   data[...]     
   END CLASS

   CLASS MagicArray INHERITS Array      ; Extend the Array data model
     <NUMERIC>   magic                  ; new member 'magic' to hold array
   END CLASS                            ; special value

   CLASS VectorisedArray INHERITS Array ; Constrain the existing class
     _INTEGER    ndim = 1
   END CLASS
The MagicArray shows the first form of inheritance, the VectorisedArray the second. The latter form is heavily used in ADI to provide useful constraining classes for applications. The constraints built in to the derived class can relieve much of the burden of checking inputs from applications.



next up previous contents
Next: Class Methods Up: Users View of Previous: Users View of



Web Master
Wed Oct 8 09:22:23 BST 1997