public abstract class HandlerSelector extends FSMBehaviour
jade.core.behaviours.Behaviour
)
A number of handlers can be registered with
this HandlerSelector
, each handler bound to a different key.
The abstract method getSelectionKey is then called that
must return the key to select one of the registered handlers.
The selected handler is finally scheduled for execution.
Modifier and Type | Field and Description |
---|---|
static int |
SELECTION_NOK
Value returned by
onEnd method if
no handler was found mapped to the key |
static int |
SELECTION_OK
Value returned by
onEnd method if
an handler was found mapped to the key |
currentName, lastStates
Constructor and Description |
---|
HandlerSelector(Agent a,
DataStore s,
java.lang.Object accessKey)
Constructor for this HandlerSelector.
|
Modifier and Type | Method and Description |
---|---|
protected abstract java.lang.Object |
getSelectionKey(java.lang.Object selectionVar)
Subclasses must provide a concrete implementation for this method.
|
void |
registerHandler(java.lang.Object key,
Behaviour h)
Register the bounding between an handler and a key.
|
checkTermination, deregisterDefaultTransition, deregisterState, deregisterTransition, forceTransitionTo, getChildren, getCurrent, getLastExitValue, getName, getPrevious, getState, handleInconsistentFSM, handleStateEntered, hasDefaultTransition, onEnd, registerDefaultTransition, registerDefaultTransition, registerFirstState, registerLastState, registerState, registerTransition, registerTransition, reset, resetStates, scheduleFirst, scheduleNext, stringifyTransitionTable
action, done, resetChildren, setAgent
block, block, getAgent, getBehaviourName, getDataStore, getParent, isRunnable, onStart, restart, root, setBehaviourName, setDataStore
public static final int SELECTION_OK
onEnd
method if
an handler was found mapped to the keypublic static final int SELECTION_NOK
onEnd
method if
no handler was found mapped to the keypublic HandlerSelector(Agent a, DataStore s, java.lang.Object accessKey)
a
- is a reference to the Agent objects
- is the DataStore where the object can be retrieved fromaccessKey
- is the key to get the proper object from the DataStore,
this is the object that will be later passed as argument to the
method getSelectionKey
getSelectionKey(Object)
protected abstract java.lang.Object getSelectionKey(java.lang.Object selectionVar)
selectionVar
- the object retrieved from the datastore at
the accessKey
passed in the constructorpublic void registerHandler(java.lang.Object key, Behaviour h)
key
- this is the key that must be later returned by
the method getSelectionKey
when the passed
Behaviour must be selectedh
- the handler for this key