CDSatellites.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Written by Pradeep Sindhu December 20, 1985 1:22:54 pm PST
This module is descended from the early implementation of satellites by Monier. It has been
rewritten a number of times since then by Sindhu and Serlet to find an implementation that
works and is comfortable to use both from programs and interactively. This last version is a
complete rewrite, one hopes for the last time!
Pradeep Sindhu December 22, 1985 2:08:56 pm PST
Abstract
A satellite is a text CD.Instance associated with another CD.Instance called the satellite's master. A master along with its satellites forms a satellite group. It is useful to think of satellites simply as visible properties attatched to the master. However, three things distinguish satellites from ordinary properties: 1) satellites are always visible, 2) the user can control their looks and placement to suit his taste, and 3) satellites are untyped—as far as clients are concerned satellites are simply pieces of text.
Clients of this interface should be aware of the set of invariants maintained for satellites, so they may avoid violating these invariants inadvertently. The description below uses the notion of a world, which is a list of CD.Instance belonging to a cell or to the top level of the design:
I1) A master must be a non-text CD.Instance with a non-nil groupIDProp.
I2) A satellite must be a text CD.Instance with a non-nil groupIDProp.
I3) Every satellite in a given world must have a corresponding master. That is, if n is the value of its groupIDProp (its groupID), then there must be a master in world that also has n as its groupID.
I4) A design may have at most one master with a given groupID.
I5) Each master must have a satellitesProp property that points to a list instances that are the master's satellites.
These invariants are enforced by the procedure EnforceInvariants, which should be called whenever one or more of them could have been violated.
DIRECTORY
CD USING [Design, Instance, InstanceList, PropList],
Rope USING [ROPE];
CDSatellites: CEDAR DEFINITIONS = BEGIN
ROPE: TYPE = Rope.ROPE;
InstanceList: TYPE = CD.InstanceList;
satellitesProp: ATOM;
This property hangs on a master. Its value is the list of the master's satellites.
maxGroupIdProp: ATOM;
This property hangs on a design. Its value is the highest numbered satellite group in the design.
groupIdProp: ATOM;
This property hangs on each instance that is in a satellite group. Its value is the group's groupId.
AddSatellite: PROC [design: CD.Design, master: CD.Instance, satellite: CD.Instance];
Adds satellite to master if satellite isn't already present; old satellites are preserved. Caller must guarantee that satellite is in master's world.
RemoveSatellite: PROC [world: InstanceList, satellite: CD.Instance];
Removes satellite from its master.
GetSatellites: PROC [master: CD.Instance] RETURNS [satellites: InstanceList ← NIL];
Returns the satellites for master.
GetSatelliteRopes: PROC [masterProps: CD.PropList] RETURNS [ropes: LIST OF ROPENIL];
Convenience proc that returns the list of satellite ropes for masterProps.
EnforceInvariants: PROC [design: CD.Design, world: InstanceList] RETURNS [ok: BOOLTRUE];
Enforces the satellite invariants listed above. This procedure is fascist!
END.