<> <> <> <> DIRECTORY BasicTime, CD, Rope; CDDesignCache: CEDAR DEFINITIONS = BEGIN <> <> <<--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: BOOL_TRUE]; Search: PROC [remoteName: Rope.ROPE, fileName: Rope.ROPE_NIL, createdTime: BasicTime.GMT _ BasicTime.nullGMT, check: CheckProc_NIL, data: REF_NIL] 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.ROPE _ NIL, reload: BOOL _ FALSE, checkFile: BOOL _ TRUE, check: CheckProc_NIL, data: REF_NIL] 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.