RETURN - Return type of query.public abstract class ParamsSense<CONTEXT extends Context,RETURN> extends StateSense<CONTEXT,RETURN>
sense using reflection. The senses
created by subclassing this class will have access to the desired parameters
directly from method parameters.
In order to create new parametrized sense, subclass this class and create
method public RETURN query. RETURN is same type as passed to the
generics. All parameters of the query method must be annotated by
the Param and must be one types supported by POSH (currently String, Double, Boolean
and Integer).
If you so desire, no parameters are necessary, thus to create parameterless
sense simply use public RETURN query() {...} method, but it is not
very useful, it is better to directly subclass StateSense that forces
you to implement ISense.query(cz.cuni.amis.pogamut.sposh.engine.VariableContext) method.
NOTE: interfaces and other mechanisms of Java are not capable to
ensure the presence of parametrized query method at compile time.
The presence of method will be checked at the moment of instantiation.
Example:
public class FlagIsOnGround extends FlagSense<AttackbotContext, Boolean> {
public FlagIsOnGround(AttackbotContext ctx) {
super(ctx, Boolean.class);
}
public Boolean query(&064;Param("$teamname") String teamName) {
ParamsActionctx| Modifier | Constructor and Description |
|---|---|
protected |
ParamsSense(CONTEXT ctx,
Class<RETURN> returnCls)
Create new parametrized sense.
|
| Modifier and Type | Method and Description |
|---|---|
RETURN |
query(VariableContext params)
Query current value of sense.
|
getCtx, getNameprotected ParamsSense(CONTEXT ctx, Class<RETURN> returnCls)
ctx - Shared info of bot + tools for manipulating the world.returnCls - Class of RETURN type. Required by reflection for finding
the correct query method (generic types are erased during compile time).
Currently only String.class, Double.TYPE and
Integer.TYPE return values are supported.public final RETURN query(VariableContext params)
ISenseparams - Variable context passed from posh plan to sense. Could be used for things like threshold and so on.Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.