next up previous contents
Next: Getting Information about Variables Up: Client Library Functions Previous: Client Library Functions   Contents


Rewriting the Open and Close Functions

The functions which perform the open/close operations will require complete re-implementation so that information about the data set can be retrieved from the data server. These re-implemented functions must store the necessary state information so that subsequent accesses for variable information or data reads can be satisfied. This state information will, in almost every case, consist of the data set attribute structure (DAS) and dataset descriptor structure (DDS).

Figures [*] and [*] are structure charts for the DODS client library open and close functions. In order to write the DODS client library version of open for a given API, the function must first determine if the data object (typically a file) is local to the user program making the open call or is a remote data object to be accessed through DODS. It is possible to access DODS objects which are local to a user program, but there is little reason to do so if the data object can be accessed through the API used by the user program. In any case, the distinction of local or remote is made on the basis whether a URL is used to reference the data object. If that is the case, the object is assumed to be remote and is accessed using a DODS data server, otherwise it is assumed to be local and is accessed using the functions of the original API implementation.

If the data object is remote, then the open function must build a structure which can hold the DAS and DDS objects which describe the named data set. Once this object is built, the open function must map this structure to a file identifier or pointer which can be passed back to the user program as the return value of the open function. Subsequent accesses to the data set will include this identifier (or pointer), and each function which is a member of the API can be modified to use it to gain access to the state information stored by the open function.

The close function must use the state information accessible with the file identifier or pointer returned by the open function to determine if the data set is local (and hence manipulated using the original API implementation) or remote. In either case, the appropriate actions necessary to free allocated storage, ..., must be taken. In the case of a local data set, the original implementation's close function must be called. In the case of a remote data set, the locally stored state information must be freed.

The network I/O tool kit which is part of the DODS software distribution contains utility functions and classes which simplify most of these operations.

Figure: Structure Chart for the Open/Connect Functions in a DODS Client Library
\begin{figure}\centerline{\psfig{figure=client-open.ps}}\end{figure}

Figure: Structure Chart for the Close/Disconnect Functions in a DODS Client Library
\begin{figure}\centerline{\psfig{figure=client-close.ps}}\end{figure}


next up previous contents
Next: Getting Information about Variables Up: Client Library Functions Previous: Client Library Functions   Contents
James Gallagher 2004-04-21