ix.icore.process
Class PNode

java.lang.Object
  extended by ix.icore.process.TimePoint
      extended by ix.icore.process.PNode
All Implemented Interfaces:
HasStatus
Direct Known Subclasses:
AgendaItem

public abstract class PNode
extends TimePoint
implements HasStatus

A node that represents an action or acticity in a process. This class supports expansion into subactions and the propagation of status changes, thus acting as a simple process model / simulator and expansion planner.


Nested Class Summary
protected  class PNode.MakeVarIfUnbound
           
 
Field Summary
protected  PNodeEnd beginEnd
           
protected  PNodeEnd endEnd
           
protected  int level
           
protected  ProcessModelManager modelManager
           
protected  PNode parent
           
 
Fields inherited from class ix.icore.process.TimePoint
tpn_mark
 
Constructor Summary
PNode(PNode parent)
           
 
Method Summary
 void addChild(PNode child, PNode after)
           
static void allComputeStatus(java.util.List l)
           
static boolean allHaveStatus(java.util.List l, Status status)
           
 void assignStatus(Status status)
          Called when loading a plan to give this PNode the status specified in the plan.
 void computeStatus()
          computeStatus() is used to change the status of related nodes when a node changes its status.
 void ensureChildrenLinkedToParent()
          Ensures that all children of this PNode are linked, directly or indirectly, between its ends.
 void expandOneLevel(Refinement sourceRefinement, MatchEnv env)
          Creates child nodes as specified by a refinement and installs ordering links.
 PNodeEnd getBegin()
           
 java.util.List<PNode> getChildren()
           
 PNodeEnd getEnd()
           
 PNodeEnd getEnd(End whichEnd)
           
 int getLevel()
           
 ProcessModelManager getModelManager()
           
 java.util.Map<Name,PNode> getNameToChildMap()
           
 PNode getParentPNode()
           
abstract  LList getPattern()
           
 Refinement getRefinement()
           
abstract  Status getStatus()
           
 java.util.Map getVarTable()
           
 boolean hasChildren()
           
 boolean isAncestorOf(PNode n)
           
 boolean isDescendentOf(PNode n)
           
 boolean isExpanded()
           
 boolean isParentOf(PNode n)
           
 boolean isSiblingOf(PNode n)
           
protected abstract  PNode makePNode(PNode parent, LList pattern)
          Factory method that constructs a child PNode of the right class.
 void processOrderings(ix.icore.domain.ListOfOrdering orderings)
          Adds the before-after links between node-ends specified by a list of Orderings taken from a Refinement.
 PNodeEnd refToTimePoint(NodeEndRef ref)
          Returns the node-end that corresponds to the node-end-ref.
 void setChildren(java.util.List l)
           
 void setModelManager(ProcessModelManager mm)
           
 void setNameToChildMap(java.util.Map<Name,PNode> map)
           
 void setRefinement(Refinement r)
           
 void setStatus(Status status)
          Changes the node's status and then that of related nodes.
 void setVarTable(java.util.Map vt)
           
 Status statusFromNodeEnds()
          Determines the status this PNode should have, based on the statuses of its node-ends.
 void unlink()
           
 void walk(Proc1<PNode> p)
          Starts a walk at this PNode.
 void walkChildren(Proc1<PNode> p)
          Walk this PNode's children.
 
Methods inherited from class ix.icore.process.TimePoint
addPostConstraint, addPreConstraint, clear, getMaxTime, getMinTime, getPostConstraints, getPreConstraints, hasUnboundedMax, removePostConstraint, removePreConstraint, setMaxTime, setMinTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

modelManager

protected ProcessModelManager modelManager

level

protected int level

parent

protected PNode parent

beginEnd

protected PNodeEnd beginEnd

endEnd

protected PNodeEnd endEnd
Constructor Detail

PNode

public PNode(PNode parent)
Method Detail

getPattern

public abstract LList getPattern()

getLevel

public int getLevel()

getBegin

public PNodeEnd getBegin()

getEnd

public PNodeEnd getEnd()

getEnd

public PNodeEnd getEnd(End whichEnd)

getParentPNode

public PNode getParentPNode()

getChildren

public java.util.List<PNode> getChildren()

hasChildren

public boolean hasChildren()

setChildren

public void setChildren(java.util.List l)

getNameToChildMap

public java.util.Map<Name,PNode> getNameToChildMap()

setNameToChildMap

public void setNameToChildMap(java.util.Map<Name,PNode> map)

getModelManager

public ProcessModelManager getModelManager()

setModelManager

public void setModelManager(ProcessModelManager mm)

getVarTable

public java.util.Map getVarTable()

setVarTable

public void setVarTable(java.util.Map vt)

getRefinement

public Refinement getRefinement()

setRefinement

public void setRefinement(Refinement r)

getStatus

public abstract Status getStatus()
Specified by:
getStatus in interface HasStatus

isSiblingOf

public boolean isSiblingOf(PNode n)

isParentOf

public boolean isParentOf(PNode n)

isAncestorOf

public boolean isAncestorOf(PNode n)

isDescendentOf

public boolean isDescendentOf(PNode n)

walk

public void walk(Proc1<PNode> p)
Starts a walk at this PNode.

To walk a node and its descendents:

    node.walk(new Proc1() {
        void call(PNode n) {
            // Process n before its chidren here.
            n.walkChildren(this);
            // Process n after its children here.
        }
    });
 


walkChildren

public void walkChildren(Proc1<PNode> p)
Walk this PNode's children. This method can be used as a recursion utility to go with the walk method.

See Also:
walk(Proc1 p)

isExpanded

public boolean isExpanded()

unlink

public void unlink()

addChild

public void addChild(PNode child,
                     PNode after)

expandOneLevel

public void expandOneLevel(Refinement sourceRefinement,
                           MatchEnv env)
Creates child nodes as specified by a refinement and installs ordering links. The subnodes are constructed by a factory method so that they can be instances of a subclass of Node and to allow other, related objects to be constructed at the same time.

Also instantiates the refinement, replacing with their values any variables that have values in 'env', and creates a map from the ids of child nodes to those children. The ids are taken from the node-specs in the refinement.


makePNode

protected abstract PNode makePNode(PNode parent,
                                   LList pattern)
Factory method that constructs a child PNode of the right class.


refToTimePoint

public PNodeEnd refToTimePoint(NodeEndRef ref)
Returns the node-end that corresponds to the node-end-ref. It will either be an end of this PNode, if the ref is to "self", or else to a child of this PNode, looked up in the id-to-child map created by the expandOneLevel method.


processOrderings

public void processOrderings(ix.icore.domain.ListOfOrdering orderings)
Adds the before-after links between node-ends specified by a list of Orderings taken from a Refinement. Calls refToTimePoint(NodeEndRef) to get each node-end.


ensureChildrenLinkedToParent

public void ensureChildrenLinkedToParent()
Ensures that all children of this PNode are linked, directly or indirectly, between its ends. However, it assumes that the only before-after links that have been added to the children so far came from a refinement. So what it actually does is add begin_of parent --> begin_of child to any child that has nothing linked before it, and end_of child --> end_of parent to any child that has nothing linked after it.


computeStatus

public void computeStatus()
computeStatus() is used to change the status of related nodes when a node changes its status.

Specified by:
computeStatus in interface HasStatus

setStatus

public void setStatus(Status status)
Changes the node's status and then that of related nodes.

Specified by:
setStatus in interface HasStatus

assignStatus

public void assignStatus(Status status)
Called when loading a plan to give this PNode the status specified in the plan. In other cases, setStatus(Status) should be called instead.


statusFromNodeEnds

public Status statusFromNodeEnds()
Determines the status this PNode should have, based on the statuses of its node-ends.


allHaveStatus

public static boolean allHaveStatus(java.util.List l,
                                    Status status)

allComputeStatus

public static void allComputeStatus(java.util.List l)