View Javadoc

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