cz.cuni.amis.pogamut.sposh.executor
Class ParamsSense<CONTEXT extends Context,RETURN>
java.lang.Object
cz.cuni.amis.pogamut.sposh.executor.StateSense<CONTEXT,RETURN>
cz.cuni.amis.pogamut.sposh.executor.ParamsSense<CONTEXT,RETURN>
- Type Parameters:
RETURN
- Return type of query.
- All Implemented Interfaces:
- ISense<RETURN>
public abstract class ParamsSense<CONTEXT extends Context,RETURN>
- extends StateSense<CONTEXT,RETURN>
Create new parametrized 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) {
- Author:
- Honza Havlicek
- See Also:
ParamsAction
Fields inherited from class cz.cuni.amis.pogamut.sposh.executor.StateSense |
ctx |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ParamsSense
protected ParamsSense(CONTEXT ctx,
Class<RETURN> returnCls)
- Create new parametrized sense.
- Parameters:
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.
ParamsSense
protected ParamsSense(CONTEXT ctx)
query
public final RETURN query(VariableContext params)
- Description copied from interface:
ISense
- Query current value of sense.
- Parameters:
params
- Variable context passed from posh plan to sense. Could be used for things like threshold and so on.
- Returns:
- what is sense currently sensing, e.g. number of friends in FOV
Copyright © 2014 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.