The Meta-Environment API

toolbus.process
Class ProcessCall

java.lang.Object
  extended by toolbus.process.ProcessExpression
      extended by toolbus.process.ProcessCall
All Implemented Interfaces:
StateElement

public class ProcessCall
extends ProcessExpression
implements StateElement

ProcessCall implements a call to a process P(f1, f2, ...). There are two main cases: (1) A static process call: the current environment does not contain a declaration for a string variable P and the name of the process is P. Its declaration is taken and the call is replaced statically by the corresponding process expression. (2) A dynamic process call: the current environment *does* contain a declaration for a string variable P and the name of the process is the *string value* of that variable. The declaration correspodning to that value is taken and the call is replaced dynamically by the corresponding process expression. In the dynamic case, each the call is encountered during execution it the may thus be expanded into a different process expression. Due to the possibility of dynamic calls, a process call is a StateElement and exists during execution.


Field Summary
private  boolean activated
           
protected  aterm.ATermList actuals
           
private  ProcessDefinition definition
           
private  Environment env
           
private  boolean evalArgs
           
private  boolean executing
           
private  State firstState
           
private  aterm.ATermList formals
           
private  java.lang.String name
           
protected  aterm.ATermList originalActuals
           
protected  ProcessExpression PE
           
protected  ProcessInstance processInstance
           
 
Fields inherited from class toolbus.process.ProcessExpression
posInfo, tbfactory
 
Constructor Summary
ProcessCall(aterm.ATerm call, TBTermFactory tbfactory, PositionInformation posInfo)
           
ProcessCall(java.lang.String name, aterm.ATermList actuals, boolean evalArgs, TBTermFactory tbfactory, PositionInformation posInfo)
           
ProcessCall(java.lang.String name, aterm.ATermList actuals, TBTermFactory tbfactory, PositionInformation posInfo)
           
 
Method Summary
 void activate()
          Activate the StateElement, i.e.
protected  void compile(ProcessInstance P, java.util.Stack<java.lang.String> calls, State follows)
           
protected  void computeFirst()
           
 boolean contains(StateElement a)
          Check whether a StateElement contains another StateElement.
protected  ProcessExpression copy()
           
 ProcessInstance[] debugExecute()
          Executes the state element in debug mode.
 boolean execute()
          Execute this StateElement
 AtomList getAtoms()
           
 StateElement getExecutedStateElement()
          Returns the last, by this process call, executed state element.
 java.lang.String getName()
           
 ProcessInstance getProcess()
           
 java.util.List<aterm.ATerm> getTests()
          Returns a collection containing all tests that are associated with this state element.
 State gotoNextStateAndActivate()
           
 State gotoNextStateAndActivate(StateElement se)
          Get the successor of the StateElement for a given other StateElement elem.
 boolean isEnabled()
          Is this StateElelement enabled for execution, i.e., are its associated tests all true? If enabled, the StateElement is ready for execution.
protected  void replaceFormals(Environment e)
           
 void setEvalArgs(boolean b)
           
 void setTest(aterm.ATerm test, Environment env)
          Add a test to this state element.
 java.lang.String toString()
           
 
Methods inherited from class toolbus.process.ProcessExpression
addToFirst, addToFollow, getFirst, getFollow, getPosInfo, setFirst, setFollow
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface toolbus.StateElement
getFollow, getPosInfo
 

Field Detail

name

private java.lang.String name

originalActuals

protected final aterm.ATermList originalActuals

actuals

protected aterm.ATermList actuals

formals

private aterm.ATermList formals

env

private Environment env

definition

private ProcessDefinition definition

PE

protected ProcessExpression PE

processInstance

protected ProcessInstance processInstance

evalArgs

private boolean evalArgs

firstState

private final State firstState

executing

private boolean executing

activated

private boolean activated
Constructor Detail

ProcessCall

public ProcessCall(java.lang.String name,
                   aterm.ATermList actuals,
                   TBTermFactory tbfactory,
                   PositionInformation posInfo)

ProcessCall

public ProcessCall(aterm.ATerm call,
                   TBTermFactory tbfactory,
                   PositionInformation posInfo)

ProcessCall

public ProcessCall(java.lang.String name,
                   aterm.ATermList actuals,
                   boolean evalArgs,
                   TBTermFactory tbfactory,
                   PositionInformation posInfo)
Method Detail

setEvalArgs

public void setEvalArgs(boolean b)

copy

protected ProcessExpression copy()
Specified by:
copy in class ProcessExpression

computeFirst

protected void computeFirst()
Specified by:
computeFirst in class ProcessExpression

replaceFormals

protected void replaceFormals(Environment e)
                       throws ToolBusException
Specified by:
replaceFormals in class ProcessExpression
Throws:
ToolBusException

compile

protected void compile(ProcessInstance P,
                       java.util.Stack<java.lang.String> calls,
                       State follows)
                throws ToolBusException
Specified by:
compile in class ProcessExpression
Throws:
ToolBusException

getAtoms

public AtomList getAtoms()
Specified by:
getAtoms in class ProcessExpression

getName

public java.lang.String getName()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

contains

public boolean contains(StateElement a)
Description copied from interface: StateElement
Check whether a StateElement contains another StateElement. In the simplest case of Atom this is just an identity test. In composite cases (e.g. Merge), it requires a recursive search.

Specified by:
contains in interface StateElement
Parameters:
a - the StateElement
Returns:
true (contained in) or false (not contained in)

getProcess

public ProcessInstance getProcess()
Specified by:
getProcess in interface StateElement
Returns:
the ProcessInstance to which the StateElement belongs

setTest

public void setTest(aterm.ATerm test,
                    Environment env)
             throws ToolBusException
Description copied from interface: StateElement
Add a test to this state element. Tests implement conditionals but not delays / timeouts.

Specified by:
setTest in interface StateElement
env - to be used for executing the test
Throws:
ToolBusException

getTests

public java.util.List<aterm.ATerm> getTests()
Description copied from interface: StateElement
Returns a collection containing all tests that are associated with this state element.

Specified by:
getTests in interface StateElement
Returns:
A collection containing all tests that are associated with this state element.

isEnabled

public boolean isEnabled()
Description copied from interface: StateElement
Is this StateElelement enabled for execution, i.e., are its associated tests all true? If enabled, the StateElement is ready for execution.

Specified by:
isEnabled in interface StateElement
Returns:
true (enabled) or false (not enabled).

gotoNextStateAndActivate

public State gotoNextStateAndActivate()
Specified by:
gotoNextStateAndActivate in interface StateElement
Returns:
the successor State of the StateElement

gotoNextStateAndActivate

public State gotoNextStateAndActivate(StateElement se)
Description copied from interface: StateElement
Get the successor of the StateElement for a given other StateElement elem. This typically used for a composite StateElement to get a specific successor. TODO: Probably this method should be combined with the previous one.

Specified by:
gotoNextStateAndActivate in interface StateElement
Returns:
the successor State of the StateElement

activate

public void activate()
Description copied from interface: StateElement
Activate the StateElement, i.e. make it ready for execution. This may involve initialization and the setting of timers.

Specified by:
activate in interface StateElement

execute

public boolean execute()
                throws ToolBusException
Description copied from interface: StateElement
Execute this StateElement

Specified by:
execute in interface StateElement
Returns:
true if execution was completed.
Throws:
ToolBusException

debugExecute

public ProcessInstance[] debugExecute()
                               throws ToolBusException
Description copied from interface: StateElement
Executes the state element in debug mode.

Specified by:
debugExecute in interface StateElement
Returns:
The collection of partners that cooperated with the execution of the state element. Null if the execution did not complete.
Throws:
ToolBusException

getExecutedStateElement

public StateElement getExecutedStateElement()
Returns the last, by this process call, executed state element. (This method is used for debugging only).

Returns:
The last, by this process call, executed state element; may be null if this process call isn't currently executing.

The Meta-Environment API