In order to link a program with the DODS Toolkit library, the DAP's
abstract classes must be subclassed and those subclasses must ensure
that all of the member functions of those classes have valid
definitions. This is necessary because of C++'s rules governing
abstract classes. The next three sections cover sub-classing the
simple, vector and compound classes, respectively. In addition, a
sample set of classes (called the Test classes because they are
used by the DAP tests) is included with the DAP distribution. You can
read the source code for those classes to find out how they were
created.
Each of the sub-classed types must supply:
ptr_duplicate.
read function, to read data from a disk and load it
into the type class object.
The ptr_duplicate member function returns a pointer to a new
instance of the type of object from which it was invoked. This member
function exists so that objects that are referenced through pointers
to BaseType can correctly copy themselves. (If you were to use
the operator new to copy an object referenced through
BaseType, you would get a BaseType, not a new instance
of the type of the referenced object.) Note that ptr_duplicate
is a virtual function so an object which is a descendent of
BaseType will get the most specific definition of that
function.
The read function is much more complicated to write than
ptr_duplicate, and the difficulty varies depending on the data
type to be read. However, this function is only used on the server
side of the system and not by the client. That is, it can be
implemented with a null function body if all you are building is a
client library. The read function takes two arguments, the
dataset name, and an error flag. It must read from that dataset the
values specified by the current constraint expression. The error flag
is passed by reference so that read can set its value and callers can
test it. The class BaseType contains a number of member
functions to facilitate writing a read function. The return value of
read is TRUE is there is more data to be read (by additional
calls to read) or FALSE otherwise.