Jump Over Left Menu
Chapter 14: Archives
The PHIGS central structure store provides storage for graphical information whilst PHIGS is open. When PHIGS is closed, the Central Structure Store (CSS) disappears and the information contained in it is lost.
Many applications have a requirement to preserve graphical information between invocations of the application program, and the requirement to exchange graphical information between different applications. An application to design work environments, for example, would wish to allow the designer to save the current state of a design and return to it at a later stage. For some applications, it would make most sense to save just the application data structures, but in other cases, where the manipulations performed by the operator have most effect on the CSS, or where generation of the CSS from the application data structures is expensive in compute time, it makes sense for the application to save the CSS contents. It is also useful to build up a library of templates of useful sequences of structure elements that can be edited to perform specific tasks and added to structures using COPY ALL ELEMENTS FROM STRUCTURE (see Section 5.7.4).
PHIGS provides a mechanism for storing structures, called archive files. Functions are provided to archive structures from the CSS to archive files and to retrieve structures from archive files into the CSS.
Part 2 of the ISO/IEC PHIGS standard defines the functionality of PHIGS archive files. Essentially the archive file is defined as a sequence of elements of different types, representing the contents of structure elements and control information.
Part 3 of the PHIGS standard defines a representation (or concrete syntax) of the archive file. This follows the same principles as the Clear Text Encoding of the ISO/IEC CGM (Metafile for the storage and transfer of picture description information) standard. Discussion of the functionality and representation of archive files per se is beyond the scope of this book. This chapter concentrates on the functions provided by PHIGS for archiving and retrieving structures from archive files.
14.2 ARCHIVAL AND RETRIEVAL FUNCTIONS
Before anything can be written to an archive file, it must be opened. This is done by calling the function:
OPEN ARCHIVE FILE(AFID, ARCFIL)
The first parameter is the archive file identifier, an identifier which is used by subsequent functions to refer to that file. The second parameter is the name of the archive file. Archive identifiers play a similar role to workstation identifiers. PHIGS allows several archive files to be open simultaneously, and again as in the case of workstations, there is an inquiry function which will return the maximum number of archive files which may be open simultaneously.
CLOSE ARCHIVE FILE(AFID)
closes the specified archive file.
Three functions are provided to archive structures to an archive file:
ARCHIVE STRUCTURES(AFID, N, LSTRID) ARCHIVE STRUCTURE NETWORKS(AFID, N, LSTRID) ARCHIVE ALL STRUCTURES(AFID)
The first of these three functions archives each of the structures specified in the list of structure identifiers (N is the number of structures to be archived and the array LSTRID contains the structure identifiers) to the archive file with identifier AFID.
The second archives the structure networks whose roots are specified by the parameters N and LSTRID. As for the previous function, N is the number of structure networks to archive, and the array LSTRID contains the structure identifiers of the roots of each. Using the structure network in Figure 5.7, as an example archiving the two structure networks with root structures CN and LG respectively would archive the structures CN and PHON for the first and LG, BLOT, CALC, LMP, LMPB, ARM and LITE for the second.
The third function archives all the structures in the CSS to t he specified archive file. Three analogous functions are provided to retrieve structures from an archive file:
RETRIEVE STRUCTURES(AFID, N, LSTRID) RETRIEVE STRUCTURE NETWORKS(AFID, N, LSTRID) RETRIEVE ALL STRUCTURES(AFID)
The first retrieves the specified structures from the specified archive file, the second retrieves the structure networks whose roots are the specified structures and the third retrieves all the structures in the archive file. The effect in each case is to add the structures retrieved to the CSS.
Conflicts may arise, both in archiving structures (the archive file already contains structures with the same names as some of those to be archived), and in retrieving structures (the CSS already contains structures with the same names as some of those to be retrieved). The control provided by PHIGS in such situations is described in the next section.
14.3 CONFLICT RESOLUTION
SET CONFLICT RESOLUTION(ARCCR, RETCR)
provides the application program with a mechanism for controlling the action to be taken if conflicts arise in archiving or retrieving structures.
The parameter ARCCR controls the action on structure archival and RETCR the action on structure retrieval.
The possible values of each flag are MAINTAIN, ABANDON and UPDATE. The value MAINTAIN has the effect that the archival or retrieval operation will only write a structure into the archive or CSS if a structure with the same name does not already exist in the archive file or CSS. A value of ABANDON causes the archival or retrieval operation to be abandoned if a conflict arises, leaves the archive file or CSS in its original state and generates an error. The value UPDATE allows structures in the archive or CSS to be overwritten.
PHIGS does provide inquiry functions which will indicate if a particular operation will generate conflicts. These are described in the next section.
14.4 INQUIRY FUNCTIONS FOR ARCHIVES
PHIGS provides a number of functions which enable the application program to inquire various characteristics of a PHIGS archive file. The function:
RETRIEVE STRUCTURE IDENTIFIERS(AFID, ILS, N, LSTRID)
returns a list of the structure identifiers in the archive file with archive identifier AFID.
The function RETRIEVE PATHS TO ANCESTORS returns the paths in an archive file which reference a specified structure. The function RETRIEVE PATHS TO DESCENDANTS returns the paths in an archive file which are referenced by the specified archived structure. The functions return information as the functions INQUIRE PATHS TO DESCENDANTS and INQUIRE PATHS TO ANCESTORS described in section Section 12.5. The latter pair of functions provide similar information for structures in the CSS.
14.5 DELETION FUNCTIONS
Three functions are provided to delete structures from an archive file:
DELETE STRUCTURES FROM ARCHIVE(AFID, N, LSTRID) DELETE STRUCTURE NETWORKS FROM ARCHIVE (AFID, N, LSTRID) DELETE ALL STRUCTURES FROM ARCHIVE(AFID)
The functions delete specified structures, all the structures referenced by specified structure networks, and all the structures in an archive respectively.
The first and second of these functions do not check if the structures to be deleted are referenced from any of the other structures in the archive file, thus some care needs to be exercised in their usage to avoid introducing inconsistencies into the archive file.