File: DBTools.mesa
Implemented By: DBToolsImpl
Last edited by
Donahue, June 19, 1985 9:46:43 am PDT
This interface manages a database of information about the tools that are generally considered to be part of the Cedar release -- ie., those that are brought over into ///Commands as part of the initialization of a new Cedar machine.
DIRECTORY
IO USING[STREAM, noWhereStream],
Rope USING [ROPE],
ViewerClasses USING[Viewer, ViewerFlavor];
DBTools: CEDAR DEFINITIONS IMPORTS IO = BEGIN
OPEN Rope;
EstablishToolDB: PROC [file: Rope.ROPE];
Close: PROC [];
Close the connection with the database.
ToolDB: READONLY Rope.ROPE;
readOnly: READONLY BOOLEAN;
RegisterTool: PROC [toolName, loadFile: ROPE];
Will change only the non-NIL properties of the tool named. The LoadFile must be a short name. (It will be prefixed with ///Commands when loaded.) The name of the tool is the registered command that is used to access it.
GetLoadFile: PROC[toolName: ROPE] RETURNS[loadFile: ROPE];
Return the load file for the named tool
SetToolDocumentation: PROC[toolName: ROPE, docFile, briefDoc: ROPENIL];
Set the documentation properties for the tool -- both the brief documentation and the name of the file containing the complete truth
GetToolDocumentation: PROC[toolName: ROPE] RETURNS[docFile, briefDoc: ROPE];
Return the current documentation properties of a tool
SetToolDescriptors: PROC[toolName: ROPE, descriptors: LIST OF ROPENIL];
Set the list of brief descriptors for the tool
GetToolDescriptors: PROC[toolName: ROPE] RETURNS[descriptors: LIST OF ROPE];
Return the descriptors for the named tool
FindMatchingTools: PROC [descriptors: LIST OF ROPE] RETURNS [tools: LIST OF ROPE];
Return the list of toolnames for which the descriptors match -- each descriptor in the list supplied appears in the list for the tool
LoadTool: PROC [toolName: ROPE, errorStream: IO.STREAMIO.noWhereStream];
Execute the contents of the load file for the given tool. This may cause commands to become registered. (No attempt is made to ensure that the load file actually exists.) A record is made that the tool is loaded.
ApplyTool: PROC [toolName, arguments: ROPE, errorStream: IO.STREAMIO.noWhereStream];
A tool corresponds to a registered command; apply the command associated with the tool to the argument list provided. The errorStream is used by the Commander to print any error messages that may arise.
RegisterViewerFlavor: PROC[tool: ROPE, flavor: ViewerClasses.ViewerFlavor];
Register a viewer flavor for a tool. This registration is used in the mapping of viewers to tools performed by ViewerToTool -- if the flavor of the viewer is of one of the registered flavors, then the toolname produced is the one associated with the registration
RegisterNamePattern: PROC[toolName, pattern: ROPE];
For tools that simply uses containers, a name pattern is another way to allow mapping of viewers to tools. If tool is associated with the viewer flavor of the tool, then the name patterns currently registered in the database are used to attempt to match the name of the viewer supplied to ViewerToTool -- if one of the patterns completely matches the name of the viewer, then the tool associated with that pattern is used.
RegisterArgumentPattern: PROC[toolName, pattern: ROPE];
Argument patterns are used to attempt to construct the argument used to create a viewer from the name of the viewer (eg., a TSetter viewer named "Clover" can be created by executing the command "TSetter Clover" -- in this case the pattern is something that matches the entire name). When executing a ViewerToTool, the pattern associated with the tool is used to attempt to extract the argument needed to create the viewer. (This information is used by Whiteboards, for instance, when it stores a tool viewer in a database.)
GetViewerInfo: PROC[tool: ROPE] RETURNS[flavor: ViewerClasses.ViewerFlavor, namePattern, argumentPattern: ROPE];
ViewerToTool: PROC[v: ViewerClasses.Viewer] RETURNS[toolName: ROPE, arguments: ROPE];
As described above, use the registered flavor information, the registered name patterns and the registered argument patterns to attempt to determine the toolname and the necessary arguments for the specified viewer.
WriteCatalogue: PROC[ file: Rope.ROPE ];
Write a text file of all of the information in the DBTools database. The format of an entry for a tool is:
ToolName {Property RopeLiteral}7 ( RopeLiteral* )
where Property is one of "DFFile", "LoadFile", "DocFile", "BriefDoc", "ViewerFlavor", "NamePattern", "ArgumentPattern" and a RopeLiteral is a RopeLiteral (produced by Convert.RopeFromRope). The RopeLiterals enclosed in parentheses are the Descriptors for the tool.
ReadCatalogue: PROC[ file: Rope.ROPE, eraseFirst: BOOLFALSE];
Read a previously written catalogue into the database. If eraseFirst, then the database is erased before loading
END.