io.sarl.api.core
Capacity Behaviors
All Superinterfaces:
Capacity
All Known Implementing Classes:
BehaviorsSkill
capacity Behaviors
implements Capacity
Agent behaviors management.
Property Summary
Modifier and type Property and description
ConcurrentCollection<T> registeredBehaviors
Replies the registered behaviors.
Action Summary
Modifier and type Action and description
abstract EventListener asEventListener
Replies the interface to dispatch an event to agent's Behaviors.
abstract ConcurrentCollection<T> getRegisteredBehaviors
Replies the registered behaviors.
abstract boolean hasRegisteredBehavior
Replies true if at least a behavior is registered.
abstract Behavior registerBehavior(Behavior,[Function1<Param,Result>],Object*)
Register a Behavior for the owner agent.
abstract Behavior unregisterBehavior(Behavior)
Unregisters a behavior for the owner agent.
abstract void wake(Behavior,Event)
Wake a specific agent's behavior reacting to the Event evt.
abstract void wake(Event,[Scope<T>])
Wake the agent's behaviors reacting to the Event evt.
abstract void wake(Iterable<T>,Event)
Wake a set of specific agent's behaviors reacting to the Event evt.
Property Details
registeredBehaviors
val registeredBehaviors : ConcurrentCollection<T>
Replies the registered behaviors.

A registered behavior is not necessary running. It may wait for events.

This property is an alias for the action: getRegisteredBehaviors

Returns:
the unmodifiable collection of the registered behavior.
Since:
0.5
Action Details
asEventListener
def asEventListener : EventListener
Replies the interface to dispatch an event to agent's Behaviors.
Returns:
the event listener.
getRegisteredBehaviors
def getRegisteredBehaviors : ConcurrentCollection<T>
Replies the registered behaviors.

A registered behavior is not necessary running. It may wait for events.
Returns:
the unmodifiable collection of the registered behavior.
Since:
0.5
hasRegisteredBehavior
def hasRegisteredBehavior : boolean
Replies true if at least a behavior is registered.

A registered behavior is not necessary running. It may wait for events.
Returns:
true if a behavior is registered; otherwise false .
Since:
0.5
registerBehavior(Behavior,[Function1<Param,Result>],Object*)
def registerBehavior(Behavior,[Function1<Param,Result>],Object*) : Behavior
Register a Behavior for the owner agent. The new Behavior will react to all declared events received by the agent.

If the filter is provided, it will be used for determining if the given behavior accepts a specific event. If the filter function replies true for a specific event as argument, the event is fired in the behavior context. If the filter function replies false, the event is not fired in the behavior context.

This function does nothing if one of the following conditions evaluates to true:
  • the agent is not alive.
Parameters:
attitude - the behavior to add to the agent.
filter - the filter that enables to indicates if an event is accepted by a behavior.
initializationParameters - the set of parameters to pass to the behavior within the Initialize event.
Returns:
the given behavior.
Since:
0.5 for the filter parameter.
unregisterBehavior(Behavior)
def unregisterBehavior(Behavior) : Behavior
Unregisters a behavior for the owner agent.
Parameters:
attitude - the behavior to remove to the agent.
Returns:
the given behavior.
wake(Behavior,Event)
def wake(Behavior,Event)
Wake a specific agent's behavior reacting to the Event evt.

This function does nothing if one of the following conditions evaluates to true:
  • the agent is not alive.
Parameters:
behavior - the agent's behavior to wake up.
event - the event to emit to the agent's behaviors and in the internal context.
Since:
0.12
wake(Event,[Scope<T>])
def wake(Event,[Scope<T>])
Wake the agent's behaviors reacting to the Event evt.

Note that the scope parameter could be used only for filtering the agents (the current receiving agent) in order to determine the ones that will receive the event. The behaviors of the current agent (registered with registerBehavior(Behavior, Function1, Object[]) will always receive the event if the current agent is not discarded. Because the behaviors have no associated address, they cannot be filtered individually.

This function does nothing if one of the following conditions evaluates to true:
  • the agent is not alive.
Parameters:
event - the event to emit to the agent's behaviors and in the internal context.
scope - the definition of the scope that will be used for selected the receivers of the events.
wake(Iterable<T>,Event)
def wake(Iterable<T>,Event)
Wake a set of specific agent's behaviors reacting to the Event evt.

This function does nothing if one of the following conditions evaluates to true:
  • the agent is not alive.
Parameters:
behaviors - the agent's behaviors to wake up.
event - the event to emit to the agent's behaviors and in the internal context.
Since:
0.12