com.sun.electric.tool.ncc.strategy
Class Strategy

java.lang.Object
  extended by com.sun.electric.tool.ncc.strategy.Strategy
Direct Known Subclasses:
StratCheck, StratCheckSizes, StratCount, StratDebug, StratDebug2, StratHashParts, StratHashWires, StratPartPopularity, StratPartType, StratPortName, StratPrint, StratRandomMatch, StratSizes

public abstract class Strategy
extends java.lang.Object

Strategy is the superclass for all strategies. The Strategy classes implement a doFor method for each level of the EquivRecord tree: Integer doFor(NetObject) Each of these does a call-back to the apply(Strategy) method of its class which actually computes the appropriate answer, perhaps by doFor calls, for each of its children, accumulating the answers. Strategy keeps track of the depth in the tree, giving reports when depth == 0. Because of that, calls to Strategy.doFor(Record) produce a single combined report, but calls to Record.apply(Strategy) produce multiple reports.


Field Summary
static java.lang.Integer CODE_ERROR
           
static java.lang.Integer CODE_NO_CHANGE
           
protected  int depth
           
 NccGlobals globals
           
 
Constructor Summary
protected Strategy(NccGlobals globals)
          Simple stratgies may pass in null for globals.
 
Method Summary
 java.util.HashMap<java.lang.Integer,java.util.List<NetObject>> doFor(Circuit c)
          Method doFor(Circuit) process a single Circuit, dividing the circuit according to this strategy, and placing the NetObjects of the Circuit into new Circuits mapped in the return according to the separation Integer.
 LeafList doFor(EquivRecord rr)
          Method doFor(EquivRecord) processes a single EquivRecord.
 LeafList doFor(java.util.Iterator<EquivRecord> it)
           
 java.lang.Integer doFor(NetObject n)
          doFor(NetObject) tests the NetObject to decide its catagory.
 LeafList doFor(RecordList r)
          Apply this Strategy to a list of leaf and internal records.
protected  long elapsedTime()
           
 void error(boolean pred, java.lang.String msg)
          Die if error occurs
protected  int getDepth()
           
protected  java.lang.String offspringStats(LeafList el)
           
protected  void startTime(java.lang.String strat, java.lang.String target)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CODE_ERROR

public static final java.lang.Integer CODE_ERROR

CODE_NO_CHANGE

public static final java.lang.Integer CODE_NO_CHANGE

depth

protected int depth

globals

public NccGlobals globals
Constructor Detail

Strategy

protected Strategy(NccGlobals globals)
Simple stratgies may pass in null for globals. But they can't call startTime, elapsedTime, or pickAnOffspring

Method Detail

getDepth

protected int getDepth()

error

public void error(boolean pred,
                  java.lang.String msg)
Die if error occurs

Parameters:
pred - true if error occurs
msg - message to print if error occurs

doFor

public LeafList doFor(RecordList r)
Apply this Strategy to a list of leaf and internal records.

Parameters:
r - a RecordList of EquivRecords to process
Returns:
a LeafList of the new leaf EquivRecords

doFor

public LeafList doFor(java.util.Iterator<EquivRecord> it)

doFor

public LeafList doFor(EquivRecord rr)
Method doFor(EquivRecord) processes a single EquivRecord.

Parameters:
rr - the EquivRecord to process
Returns:
a LeafList of the new leaf EquivRecords

doFor

public java.util.HashMap<java.lang.Integer,java.util.List<NetObject>> doFor(Circuit c)
Method doFor(Circuit) process a single Circuit, dividing the circuit according to this strategy, and placing the NetObjects of the Circuit into new Circuits mapped in the return according to the separation Integer.

Parameters:
c - the Circuit to process.
Returns:
a CircuitMap of offspring Circuits. Returns an empty map if no offspring intended, and returns the input input Circuit if method fails to split.

doFor

public java.lang.Integer doFor(NetObject n)
doFor(NetObject) tests the NetObject to decide its catagory. The default method generates no offspring.

Parameters:
n - the NetObject to catagorize
Returns:
an Integer for the choice.

offspringStats

protected java.lang.String offspringStats(LeafList el)

startTime

protected void startTime(java.lang.String strat,
                         java.lang.String target)

elapsedTime

protected long elapsedTime()