cz.cuni.amis.pogamut.sposh.executor
Class ParamsAction<CONTEXT extends Context>

Package class diagram package ParamsAction
java.lang.Object
  extended by cz.cuni.amis.pogamut.sposh.executor.StateAction<CONTEXT>
      extended by cz.cuni.amis.pogamut.sposh.executor.ParamsAction<CONTEXT>
All Implemented Interfaces:
IAction

public abstract class ParamsAction<CONTEXT extends Context>
extends StateAction<CONTEXT>

Base class for actions that have parameters passed to them using the reflection API. The actions derived directly from StateAction must check that passed VariableContext contains expected parameters. To correctly implement action that can utilize the reflection for parameters, you must derive from this class and implement three methods: public void init, public ActionResult run and public void done. All parameters of these methods must be annotated by the Param with specified name of the variable contained in the VariableContext. Note that each action can have different parameters, as long as all parameters have annotations with Param and are all in the context. Only allowed parameters are of type String, Integer and Double. Example:

 class StayAction extends ParamsAction<PreyContext> {
   public StayAction(Context ctx) {
     super(ctx);
   }

   public void init(&064;Param("$enemy") String enemy, &064;Param("$distance") Double distance) {
     ...
   }

   public ActionResult run(&064;Param("$teamname") String teamName) {
     ...
   }

   public void done() {
     ...
   }
 }

 

Author:
Honza Havlicek
See Also:
ParamsSense, Annotation for parameters of the methods.

Field Summary
 
Fields inherited from class cz.cuni.amis.pogamut.sposh.executor.StateAction
ctx
 
Constructor Summary
ParamsAction(CONTEXT ctx)
           
 
Method Summary
 void done(VariableContext params)
          This action is done, according to posh plan, some other IAction is supposed to execute, therefore use this to clean up the mess.
 void init(VariableContext params)
          Initialize action.
 ActionResult run(VariableContext params)
          Run is called every time evaluation of posh plan determines that this and no other action is the one that is supposed to execute.
 
Methods inherited from class cz.cuni.amis.pogamut.sposh.executor.StateAction
getCtx, getName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParamsAction

public ParamsAction(CONTEXT ctx)
Method Detail

init

public final void init(VariableContext params)
Description copied from interface: IAction
Initialize action. Called ever time action is supposed to execute.

After init, run is immediately called, so first run call has same state of world as init did.

Parameters:
params - Variable context that is passed from posh plan to the primitive

run

public final ActionResult run(VariableContext params)
Description copied from interface: IAction
Run is called every time evaluation of posh plan determines that this and no other action is the one that is supposed to execute.

Parameters:
params - Variable context passed from posh plan to the primtive
Returns:
result of action in this iteration.

done

public final void done(VariableContext params)
Description copied from interface: IAction
This action is done, according to posh plan, some other IAction is supposed to execute, therefore use this to clean up the mess.



Copyright © 2013 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.