LoganBerryBrowser.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Doug Terry, November 23, 1986 8:37:16 pm PST
Operations used by the LoganBerry Browser that may be of use to others. Includes facilities for performing multi-attribute filtered queries and for creating customized browsers.
DIRECTORY
IO USING [STREAM],
LoganBerryStub USING [Attribute, Entry, EntryProc, OpenDB],
Rope USING [ROPE],
ViewerClasses USING [Viewer];
LoganBerryBrowser: CEDAR DEFINITIONS
~ BEGIN
Attribute patterns are lists of LoganBerry attributes that may optionally contain a pattern type. The currently supported types of patterns include "exact", "prefix", "wildcard", "reg. exp.", and "soundex" (see LoganQuery.mesa). The following data structure is the internal representation of an attribute pattern list. In addition, attribute patterns have an external (character string) representation that can be printed or typed in. A basic LoganBerry attribute is represented in the form:
 <attribute type>: <attribute value>
In this case, since a pattern is not explicitly specified, the value is taken to be the exact value of the attribute. That is, a missing pattern defaults to "exact". The attribute value may be either a token or a rope literal.

An explicit pattern type may be given in parenthesis immediately following the attribute type. Thus, an attribute pattern is given in the form
 <attribute type>(<pattern>): <attribute value>
Several of these may be concatenated together to get a list of attribute patterns. For example,
 Name: "Douglas B. Terry" Phone(prefix): 494-44 Office(wildcard): 35-2*
AttributePattern: TYPE = REF AttributePatternRec;
AttributePatternRec: TYPE = RECORD [
attr: LoganBerryStub.Attribute,
ptype: Rope.ROPENIL
];
AttributePatterns: TYPE = LIST OF AttributePattern;
SyntaxError: ERROR [explanation: Rope.ROPENIL];
Following are some operations for dealing with attribute patterns and using them to query a LoganBerry database.
ReadAttributePatterns: PROC [s: IO.STREAM] RETURNS [ap: AttributePatterns];
Reads an externalized list of attribute patterns from the given stream and builds the appropriate data structure. Raises ! SyntaxError if the stream does not contain a validly formed list of attributes.
WriteAttributePatterns: PROC [s: IO.STREAM, ap: AttributePatterns] RETURNS [];
Writes a list of attribute patterns to the given stream.
PatternsToEntry: PROC [ap: AttributePatterns] RETURNS [entry: LoganBerryStub.Entry];
Converts a list of attribute patterns to a LoganBerry entry by ignoring the pattern type.
EntryToPatterns: PROC [entry: LoganBerryStub.Entry] RETURNS [ap: AttributePatterns];
Converts a LoganBerry entry to a list of attribute patterns with ptype=NIL.
FilteredQuery: PROC [db: LoganBerryStub.OpenDB, patterns: AttributePatterns, proc: LoganBerryStub.EntryProc] RETURNS [];
Retrieves entries in the LoganBerry database that match the attribute patterns and calls the given procedure for each one.
The following operations allow one to create a LoganBerry browser with customized behavior.
DisplayProc: TYPE = PROC [entry: LoganBerryStub.Entry, output: ViewerClasses.Viewer, clientData: REFNIL] RETURNS [continue: BOOL ← TRUE];
If a DisplayProc is supplied to CreateTool (below) then that procedure is called for every LoganBerry entry retrieved by the browser. A supplied DisplayProc has access to the browser's typescript viewer and is also passed any clientData that was registered when the browser was created. If the procedure returns continue=FALSE then the query is aborted.
PrintEntry: DisplayProc;
This default DisplayProc simply prints a LoganBerry entry in the browser's output viewer.
OpProc: TYPE = PROC [op: ATOM, complete: BOOLEAN, output: ViewerClasses.Viewer, clientData: REFNIL] RETURNS [continue: BOOL ← TRUE];
If an OpProc is supplied to CreateTool (below) then that procedure is called twice for every major operation invoked via the browser—once before the operation (complete=FALSE) and once upon completion (complete=TRUE). If complete=FALSE and the procedure returns continue=FALSE then the operation is aborted and the database remains unchanged.
Current operations include: $LBQuery, $LBWrite, $LBDelete.
CreateTool: PROC [db: LoganBerryStub.OpenDB, proc: DisplayProc ← PrintEntry, oproc: OpProc ← NIL, clientData: REFNIL] RETURNS [];
Builds a tool for browsing the given LoganBerry database.
END.
Doug Terry, October 20, 1986 4:24:29 pm PDT
changes to: DIRECTORY, LoganBerryCommands, ~
Doug Terry, October 31, 1986 3:34:34 pm PST
Added CreateTool operation.
changes to: DIRECTORY, LoganBerryBrowser, ~
Doug Terry, November 23, 1986 8:12:21 pm PST
Exported the default DisplayProc; added OpProc registration to the browser.
changes to: ~