CDMarks.mesa (part of Chipndale)
Copyright © 1983, 1984 by Xerox Corporation. All rights reserved.
by Christian Jacobi July 12, 1983 2:11 pm
last edited by Christian Jacobi October 19, 1984 4:49:45 pm PDT
DIRECTORY
CD USING [ObPtr, Design, markNum];
CDMarks: CEDAR DEFINITIONS =
BEGIN
MarkRange: TYPE = [0..CD.markNum);
GetNewMark: PROC [design: CD.Design] RETURNS [MarkRange];
--Gets a new value to be used as a mark.
--If all values are already used, it clears all accessible marks and is therefore quite slow.
--Never returns 0.
ClearAllAccessibleMarks: PROC [design: CD.Design];
--Clears all the marks of the design
MarkUnMarkedInclusiveChildren: PROC [design: CD.Design, ob: CD.ObPtr, value: MarkRange];
--For all objects do: if their markvalue is different, then set it to value, and do this
--also recursively for all the children of the object.
--value must be the current mark value.
Every object* has a mark, which can temporarily used to mark objects. To avoid to reinitialize all the marks before each usage of marks, a markvalue goes cyclic through the small subrange MarkRange. For every application of marks, the client gets a new value with GetNewMark. This value is different from every previous value of marks remaining in the data structures. Whenever a new value for marks is requested, all the old values now just mean un-marked, nevertheless, they remain hanging around. However, when there are no more unused values for marks, all the marks must be reset; there must stay no mark with a value which could be reused for marking in the next cycle through MarkRange. This is done by calling ClearAllAccessibleMarks (called internally by GetNewmark).
Use the marks only for objects with children.
To avoid conflicts, only one client at a time is allowed to use the mark features. The rule which client is allowed to use the mark features is a convention: the client who owns the lock of the command execution queue of the design gets the exclusive right to use the marks, while he owns the lock.
The value 0 is reserved for clear marks, it can be safely assigned to marks independent of which value is the current mark value. However, if you have to do this, chances are big that your algorithm may be wrong.
Only objects which are actually part of the design may be used. This is necessary to guaranty that the marks are properly cleared on the next cycle through MarkRange.
END.