A device-independent Application Programming Interface (API) does not guarantee that all programs run identically on all supported devices. A device-independent API provides the tools that allow properly written application programs to run identically on all supported devices.
In order for your applications to run on other workstations in the future, your application should adapt to a workstation's capabilities. That is why the key to creating device-independent programs involves the proper use of inquiries to determine the specific capabilities of a system and its workstations.
Device-independent applications need not perform any differently than device-specific applications. You must initially invest more effort in program development. The payback is the reduction of effort in migrating the application to other supported graphics devices. If programmed properly, your application can run unmodified on other than the original target workstation.
Inquiries enable your application to determine:
This chapter discusses categories of inquiries. It does not cover every inquiry subroutine call. It presents some important, commonly used inquiries. Refer to The graPHIGS Programming Interface: Subroutine Reference for more information about each inquiry subroutine. Refer to The graPHIGS Programming Interface: Technical Reference for the content of state lists and description tables.
System related inquiries let your application inquire into the system's operating states, state lists, and description table. System related inquiries can be used to inquire information such as:
The purpose of workstation inquiries is to enable your application to inquire the state of a workstation, and adapt to its capabilities, such as differing screen sizes, number of supported colors, and supported input devices.
In order to determine such workstation-dependent capabilities, your application queries a workstation's description table (WDT) and a workstation's state list (WSL).
All inquiries whose first parameter is a workstation type inquire information from the WDT corresponding to that workstation type. The values in the WDT are provided by and initialized by the system. It contains all of the workstation's defaults. It also contains all of the general characteristics of that workstation's type.
Certain values in the WDT are configuration variable. These values depend on the type and configuration of each workstation. When the graPHIGS API opens a particular workstation, it obtains the necessary device-specific information, then inserts that information and creates an actual WDT for that workstation.
Each actual WDT is identified by a unique system generated workstation type which can be inquired using the Inquire Realized Connection and Type (GPQRCT) subroutine. GPQRCT takes a workstation identifier as its' first parameter and returns both the actual connection identifier and workstation type for the workstation. The actual workstation type can then be used in any WDT inquiry to determine the actual capabilities of the workstation.
WDT inquiries can be used to inquire information such as:
In the sample program, the statements:
CALL GPQRCT (WSID, ILEN, ERRIND, OLEN, ACONID, AWSTYP) CALL GPQDS (AWSTYP, ERRIND, UNITS, CSIZE, ASIZE)inquire the actual maximum display surface size of the workstation whose identifier is WSID These inquiries allow the sample program to run on all supported workstations.
All inquiries whose first parameter is a workstation identifier, inquire information from the WSL corresponding to that open workstation. The values in the WSL reflect the current state of the workstation when the workstation is open.
For example, the Inquire Highlighting Filter (GPQHLF) subroutine will return the current highlighting filter lists for a specified workstation identifier.
Structure related inquiries let your application inquire the existence and content of structures.
To inquire the contents of an element within a structure, the structure must be open. Your application must first set the current element pointer at the target element, then issue the appropriate inquiry.
The graPHIGS API provides a rich variety of inquire element subroutine calls. For example, to inquire the length (in bytes) and element code for a set of structure elements, use the Inquire List of Element Headers (GPQEHD) subroutine.
Next, to obtain the contents of a set of structure elements, use the Inquire List of Element Data (GPQED) subroutine. Both GPQEHD and GPQED return structure element information starting at the structure element pointed to by the current element pointer. The format of a structure element is described in The graPHIGS Programming Interface: Technical Reference