ASDBManagerImpl.mesa
Arnon, November 19, 1987 4:18:58 pm PST
DIRECTORY
Basics,
Rope,
Convert,
List USING [AList, Assoc, PutAssoc]
ASDBManager;
ASDBManagerImpl: CEDAR PROGRAM
IMPORTS List, Convert
EXPORTS ASDBManager ~
BEGIN OPEN ASDBManager;
Abbreviations from Imported Interfaces
ROPE: TYPE ~ Rope.ROPE;
AList: TYPE ~ List.AList;
Simulated LoganBerry DB
LoganBerryLog: LBLog; -- a global simulated LoganBerry Log
Global registry of AS objects loaded into memory
OnlineASObjects: List.AList ← NIL;
Given a request or a need to retrieve an OfflineObject, the DataManager checks this first to see if already online.
Operations on Public Lists of Expression Class Names, by Expr Type
ResetWorld: PUBLIC PROC[] ~ {
LoganBerryLog ← NIL;
OnlineASObjects ← NIL;
};
OnlineASObject: PROC [in: AlgebraClasses.Object, tryToLink: BOOLFALSE] RETURNS [out: AlgebraClasses.Object];
Checks OnlineASObjects to see if already online, if not, loads it and enters it into OnlineASObjects. If tryToLink = TRUE, then for each field which contains one or more AS objects, looks for those objects in OnlineASObjects, and if found, puts pointers to the online versions in the output object. If tryToLink = FALSE, then all such fields are left containing offline objects.
InstallAtomClass: PUBLIC PROC[class: AtomClass] ~ {
effects: Installs class in global AtomClass DataBase
add atom class to database - not very efficient, but does the job
GlobalAtomClasses ← List.PutAssoc[key: class.name, val: class, aList: GlobalAtomClasses];
add atom class name to index
AtomClassNames ← CONS[class.name, AtomClassNames];
};
LookupAtomClass: PUBLIC PROC[name: ATOM] RETURNS[AtomClass] ~ {
effects: Returns the AtomClass object associated with name.
SIGNALS notFound if no association exists
atomClass: AtomClass ← NARROW[List.Assoc[key: name, aList: GlobalAtomClasses]];
IF atomClass = NIL THEN ERROR notFound;
RETURN[atomClass];
};
KillAtomClass: PUBLIC PROC[name: ATOM] ~{
GlobalAtomClasses ← KillAssoc[name, GlobalAtomClasses]
};
Public Lists of Operator Names (Operators assumed to be CompoundExprs)
GlobalOperatorTable: List.AList ← NIL;
Signals & Errors
notFound: PUBLIC ERROR = CODE;
Start Code (Reset Database)
ResetWorld[];
END.