ProtocolsImpl.Mesa
Copyright Ó 1992 by Xerox Corporation. All rights reserved.
Last tweaked by Mike Spreitzer on April 4, 1990 12:23:28 pm PDT
DIRECTORY Atom, List, Protocols, Rope;
ProtocolsImpl: CEDAR PROGRAM
IMPORTS Atom, List, Rope
EXPORTS Protocols
= {OPEN Protocols;
protocols: List.AList ¬ NIL;
GetProtocol: PUBLIC PROC [name: ROPE] RETURNS [p: Protocol] = {
a: ATOM ¬ Atom.MakeAtom[name];
p ¬ NARROW[List.Assoc[key: a, aList: protocols]];
IF p#NIL AND NOT name.Equal[p.name] THEN ERROR;
};
RegProtocol: PUBLIC PROC [p: Protocol] = {
a: ATOM ¬ Atom.MakeAtom[p.name];
protocols ¬ List.PutAssoc[key: a, val: p, aList: protocols];
};
EnumerateProtocols: PUBLIC PROC [Consume: PROC [Protocol]] ~ {
FOR pl: List.AList ¬ protocols, pl.rest WHILE pl#NIL DO
p: Protocol ~ NARROW[pl.first.val];
Consume[p];
ENDLOOP;
RETURN};
}.