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. 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,
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 CLASSThe
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.