<> <> <> <> DIRECTORY CD, Rope, SymTab; CDGenerate: CEDAR DEFINITIONS = BEGIN <> <> <> <<>> <> <> <> Context: TYPE = REF --READONLY-- ContextRep; ContextRep: TYPE = RECORD [rep: PRIVATE REF, case: BOOL, cache: BOOL]; GeneratorProc: TYPE = PROC [design: CD.Design, key: Rope.ROPE, context: Context, data: REF] RETURNS [ob: CD.Object_NIL]; Create: PROC [case: BOOL _ TRUE, cache: BOOL _ TRUE] RETURNS [Context]; <<--creates a new, empty context>> <<--cache: whether this context tries to cache generated objects>> Clear: PROC [context: Context]; <<--undo all registrations in this context>> Register: PROC[context: Context, key: Rope.ROPE, generator: GeneratorProc, cache: BOOL_TRUE, data: REF_NIL] RETURNS [first: BOOL]; <<--first: TRUE if key did not already exist>> <<--cache: tries to cache the result; works only if context itself is willing to cache>> <<--data: passed through to FetchNCall calling generator>> <<>> <<>> FetchRegistration: PROC[context: Context, key: Rope.ROPE] RETURNS [generator: GeneratorProc, cache: BOOL, data: REF]; <<--fetch the registration of a generator key>> <<--generator NIL if not found>> FetchCached: PROC[context: Context, design: CD.Design, key: Rope.ROPE] RETURNS [CD.Object]; <<--fetch a generated object if it is cached.>> <<--returns NIL if not found, not cached or looks different>> FetchNCall: PROC[context: Context, design: CD.Design, key: Rope.ROPE, cache: BOOL_TRUE] RETURNS [CD.Object]; <<--fetch a generator and invoke it>> <<--returns NIL if not found or generated>> <<--caching only if generator and this call want caching>> Flush: PROC [context: Context, design: CD.Design, key: Rope.ROPE]; <<--Removes this entry from the cache>> FlushAll: PROC [context: Context, design: CD.Design]; <<--Removes all entries from the cache>> <<>> <<--convenient procedures>> SelectOneOf: PROC [context: Context, label: Rope.ROPE] RETURNS [key: Rope.ROPE]; <<--Interactive selection of a generator from a context>> <<--NIL if discarded>> AssertContext: PROC [project: Rope.ROPE] RETURNS [Context]; <<--Fetches a context; if not done then create one and store it for next call of AssertTable.>> <<--This context can be imported by lots of unknown applications...>> END.