1 package cz.cuni.amis.pogamut.sposh.executor; 2 3 import cz.cuni.amis.pogamut.sposh.context.Context; 4 5 /** 6 * Basic state action primitive. It contains context and name. Wizzard for new 7 * state actions generates class that is extension of this class. 8 * @author Honza 9 * @param <CONTEXT> Context of this action, used to manipulate the environment. 10 */ 11 public abstract class StateAction<CONTEXT extends Context> implements IAction { 12 /** Name of the action */ 13 private String name; 14 /** Context for the action */ 15 protected final CONTEXT ctx; 16 17 /** 18 * Create new state action. 19 * @param name name of the action 20 * @param ctx action context, used as shared memory or environment interactor. 21 */ 22 protected StateAction(String name, CONTEXT ctx) { 23 this.name = name; 24 this.ctx = ctx; 25 } 26 27 /** 28 * Create new state action. Name of the action will be name of the class. 29 * @param ctx action context, used as shared memory or environment interactor. 30 */ 31 protected StateAction(CONTEXT ctx) { 32 this.name = this.getClass().getName(); 33 this.ctx = ctx; 34 } 35 36 /** 37 * Get name of the action. 38 * @return the name 39 */ 40 public String getName() { 41 return name; 42 } 43 44 /** 45 * Get shared context of all primitives. 46 * @return the ctx 47 */ 48 public CONTEXT getCtx() { 49 return ctx; 50 } 51 52 }