etomica.action.activity
Class ActivityGroupSeries

java.lang.Object
  extended by etomica.action.Activity
      extended by etomica.action.activity.ActivityGroupSeries
All Implemented Interfaces:
ActionGroup, ActivityGroup, IAction, Serializable
Direct Known Subclasses:
Controller

public class ActivityGroupSeries
extends Activity
implements ActivityGroup

Organizer of simulation actions to be executed in series.

See Also:
Serialized Form

Field Summary
protected  IAction[] completedActions
           
protected  IAction currentAction
           
protected  int numActions
           
protected  boolean pauseAfterEachAction
           
protected  IAction[] pendingActions
           
 
Fields inherited from class etomica.action.Activity
haltRequested, isActive, pauseRequested
 
Constructor Summary
ActivityGroupSeries()
           
 
Method Summary
 void addAction(IAction newAction)
          Adds the given action to the list of actions.
 IAction[] getAllActions()
          Returns all actions from this group.
 IAction[] getCompletedActions()
          Returns all actions from this group that have been completed.
 IAction[] getCurrentActions()
          Returns all actions from this group that are currently being performed.
 IAction[] getPendingActions()
          Returns all actions from this group that have not yet started.
 void halt()
          Request that the activity group terminate its thread as soon as possible.
 boolean isPauseAfterEachAction()
           
 boolean isPaused()
          Queries whether the integrator is in a state of being paused.
 void pause()
          Requests a pause in the performance of the actions.
 boolean removeAction(IAction action)
          Removes the given action from the list of actions performed by this controller.
 void reset()
          Marks all actions as pending.
protected  void run()
          Causes uncompleted actions added to this group to be run in sequence.
 void setPauseAfterEachAction(boolean pauseAfterEachAction)
           
 void unPause()
          Removes activity group from the paused state, resuming execution where it left off.
 
Methods inherited from class etomica.action.Activity
actionPerformed, doContinue, doWait, isActive
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface etomica.action.IAction
actionPerformed
 

Field Detail

currentAction

protected IAction currentAction

pauseAfterEachAction

protected boolean pauseAfterEachAction

numActions

protected int numActions

pendingActions

protected IAction[] pendingActions

completedActions

protected IAction[] completedActions
Constructor Detail

ActivityGroupSeries

public ActivityGroupSeries()
Method Detail

addAction

public void addAction(IAction newAction)
Adds the given action to the list of actions. If action is already in list of actions to be performed, method returns without doing anything.

Specified by:
addAction in interface ActionGroup

removeAction

public boolean removeAction(IAction action)
Removes the given action from the list of actions performed by this controller. If action is currently running, or is not in list of actions, method returns without doing anything.

Specified by:
removeAction in interface ActionGroup
Returns:
true if the action was removed

reset

public void reset()
Marks all actions as pending. Previously completed actions are put first in the new list of pending actions. The Controller must be inactive or halted before calling this method.


getPendingActions

public IAction[] getPendingActions()
Description copied from interface: ActivityGroup
Returns all actions from this group that have not yet started.

Specified by:
getPendingActions in interface ActivityGroup
Returns:
a list of the actions yet to be performed by this controller.

getCurrentActions

public IAction[] getCurrentActions()
Description copied from interface: ActivityGroup
Returns all actions from this group that are currently being performed.

Specified by:
getCurrentActions in interface ActivityGroup
Returns:
an array containing the action currently being performed, or a zero-length array if the current action is null.

getCompletedActions

public IAction[] getCompletedActions()
Description copied from interface: ActivityGroup
Returns all actions from this group that have been completed.

Specified by:
getCompletedActions in interface ActivityGroup
Returns:
a list of the actions completed by this activity group.

getAllActions

public IAction[] getAllActions()
Description copied from interface: ActionGroup
Returns all actions from this group.

Specified by:
getAllActions in interface ActionGroup

run

protected void run()
Causes uncompleted actions added to this group to be run in sequence. Should not be executed directly, but instead as part of the Runnable interface it is executed by a thread made upon invoking the start method.

Specified by:
run in class Activity

pause

public void pause()
Requests a pause in the performance of the actions. If the current action is an Activity, it is paused; if a simple Action, pause takes effect once it has completed. In either case, calling thread is put in a wait state until the pause takes effect.

Overrides:
pause in class Activity

unPause

public void unPause()
Removes activity group from the paused state, resuming execution where it left off.

Overrides:
unPause in class Activity

halt

public void halt()
Request that the activity group terminate its thread as soon as possible. Calling thread is caused to wait until halt is completed.

Overrides:
halt in class Activity

isPaused

public boolean isPaused()
Description copied from class: Activity
Queries whether the integrator is in a state of being paused. This may occur independent of whether the integrator is isActive or not. If paused but not isActive, then pause will take effect upon start.

Overrides:
isPaused in class Activity

isPauseAfterEachAction

public boolean isPauseAfterEachAction()
Returns:
flag specifying whether activity should pause upon completing each action.

setPauseAfterEachAction

public void setPauseAfterEachAction(boolean pauseAfterEachAction)
Parameters:
pauseAfterEachAction - specifies whether activity should pause upon completing each action (true), or if next action should begin immediately upon completion of current action.