View Javadoc

1   package cz.cuni.amis.pogamut.sposh.executor;
2   
3   import cz.cuni.amis.pogamut.sposh.engine.VariableContext;
4   
5   /**
6    * Primitive representation used in {@link StateWorkExecutor}. This primitive is
7    * executed in phases: first is called init, then run is called, until
8    * executor decides it is time to switch to another primtive. Before init of
9    * new primtive is called, done of previous primitive is called.
10   * @author Honza
11   * @param <RETURN> Type of object that is returned by this action every time it is evaluated.
12   */
13  public interface IAction {
14  
15      /**
16       * Initialize action. Called ever time action is supposed to execute.
17       * <p/>
18       * After init, run is immediately called, so first run call has same state of world
19       * as init did.
20       * @param params Variable context that is passed from posh plan to the primitive
21       */
22      void init(VariableContext params);
23      
24      /**
25       * Run is called every time evaluation of posh plan determines that this and
26       * no other action is the one that is supposed to execute. 
27       * @param params Variable context passed from posh plan to the primtive
28       * @return result of action in this iteration.
29       */
30      ActionResult run(VariableContext params);
31      
32      /**
33       * This action is done, according to posh plan, some other {@link IAction} is
34       * supposed to execute, therefore use this to clean up the mess.
35       * @param params
36       */
37      void done(VariableContext params);
38      
39  }