CDDesignCache.mesa (part of ChipNDale)
Copyright © 1987 by Xerox Corporation. All rights reserved.
Created by Christian Jacobi, April 9, 1987 12:03:09 pm PDT
Last edited by: Christian Jacobi, April 9, 1987 4:13:05 pm PDT
DIRECTORY
BasicTime,
CD,
Rope;
CDDesignCache: CEDAR DEFINITIONS =
BEGIN
This module implements caching of readonly designs.
Readonly: clients must/can not know whether cached designs are shared.
--Basic functions
IsCached: PROC [for: CD.Design, remoteName: Rope.ROPE] RETURNS [BOOL];
-- Returns whether a design "remoteName" is cached for "for"
Fetch: PROC [for: CD.Design, remoteName: Rope.ROPE] RETURNS [remote: CD.Design];
-- Returns cached design if there is one; NIL otherwise.
-- "remote" will be readonly and therefore must [and will] never be changed
-- (but a different design with the same name might be cached later...)
Set: PROC [for: CD.Design, remote: CD.Design];
-- Remembers [caches] the design "remote".
-- Forgets previous cache contents.
-- "remote" must be readonly
Forget: PROC [for: CD.Design, remoteName: Rope.ROPE];
-- Forgets cache of remote design "remoteName"
--Higher level functions
CheckProc: TYPE = PROC [design: CD.Design, data: REF] RETURNS [ok: BOOLTRUE];
Search: PROC [remoteName: Rope.ROPE, fileName: Rope.ROPENIL, createdTime: BasicTime.GMT ← BasicTime.nullGMT, check: CheckProc←NIL, data: REFNIL] RETURNS [found: CD.Design];
-- Tries hard to find a cached design and returns it, or NIL if not found.
-- The returned design is readonly.
-- "fileName" [if ~NIL]: checks that cached design comes from this file.
-- "createdTime" [if ~nullGMT]: checks that cached design's file has this create time.
-- "check" [if ~NIL]: returns cached design only in case check returns TRUE.
-- "data": given to check, if called.
MakeUpFile: PROC [for: CD.Design, remoteName: Rope.ROPE] RETURNS [fileName: Rope.ROPE];
-- Checks whether for wants a special file name to be used for caching design "remoteName".
-- Returns "remoteName" if no file name could be made up.
-- Might use properties, user profile, or magic to find a name.
GetOrRead: PROC [for: CD.Design, remoteName: Rope.ROPE, remoteFile: Rope.ROPENIL, reload: BOOLFALSE, checkFile: BOOLTRUE, check: CheckProc←NIL, data: REFNIL] RETURNS [remote: CD.Design, different: BOOL];
-- Conveniance; Tries hard to make and return a cached design,
-- using Fetch, Search or Read to get it, and, sets the cache.
-- "remoteFile" file name; make up name if NIL.
-- "reload"
-- if true: discards previous cache contents if loading suceeds.
-- if false: skips loading if design "remoteName" is already cached.
-- "checkFile": if a cached design is searched a check is made whether it comes
-- from the right file.
-- "check": used for Search.
-- "data": given to check, if called.
-- "remote": the cached design, independent whether loaded before or now.
-- "different": the cache contents is changed.
END.