io.sarl.api.core
Capacity Lifecycle
All Superinterfaces:
Capacity
All Known Implementing Classes:
LifecycleSkill
capacity Lifecycle
implements Capacity
Lifecycle related actions.
Action Summary
Modifier and type Action and description
abstract void killMe([Object])
Kills this agent.
abstract void spawn(Class<T>,Object*)
Spawns a new Agent inside the default context of this agent.
abstract void spawn(int,Class<T>,Object*)
Spawns a group of agents inside the default context of this agent.
abstract void spawnInContext(Class<T>,AgentContext,Object*)
Spawns a new member agent in the parent's context (parentID).
abstract void spawnInContext(int,Class<T>,AgentContext,Object*)
Spawns a group of agents in the parent's context (parentID).
abstract void spawnInContextWithID(Class<T>,UUID,AgentContext,Object*)
Spawns a new member agent in the given context.
abstract void spawnWithID(Class<T>,UUID,Object*)
Spawns a new member agent in the parent's context (parentID).
Action Details
killMe([Object])
def killMe([Object])

fires AgentKilled, Destroy, AgentKillFailure

Kills this agent.

This action must automatically unregister this agent from the default context and therefore all its spaces including the DefaultSpace. If this is a composable agent, it must not have any members before calling this action. Otherwise a RuntimeException will be thrown.

This function does nothing if one of the following conditions evaluates to true:
  • the agent is not alive.
Parameters:
terminationCause - indicates the cause of the termination of the agent. If this argument is null, the agent terminates without specific cause.
Fires SARL events:
AgentKilled in DefaultSpace of all Contexts to which this agent belongs, Destroy inside the agent, AgentKillFailure inside the agent
Since:
0.12
spawn(Class<T>,Object*)
def spawn(Class<T>,Object*)

fires AgentSpawned, AgentSpawnFailure

Spawns a new Agent inside the default context of this agent. This action must automatically register the newly created agent within the default space of the context.

Caution: when this function returns, there is no warranty that the spawned agent is initialized at the time of the return. Indeed, agent spawning is done in parallel to the calling thread. This parallel task for spawning is not considered as an agent task, i.e. it cannot be stopped or cancelled by the spawning agent, or if this agent is killed.

This function does nothing if one of the following conditions evaluates to true:
  • the agent is not alive.
Parameters:
agentType - the type of the agent to spawn.
params - the arguments to pass in the initialization event to the spawned agent.
Fires SARL events:
AgentSpawned in DefaultSpace, AgentSpawnFailure if the agent cannot be spawned.
Since:
0.5
spawn(int,Class<T>,Object*)
def spawn(int,Class<T>,Object*)

fires AgentSpawned, AgentSpawnFailure

Spawns a group of agents inside the default context of this agent. This action must automatically register the newly created agents within the default space of the context.

Caution: when this function returns, there is no warranty that the spawned agents are initialized at the time of the return. Indeed, agent spawning is done in parallel to the calling thread. This parallel task for spawning is not considered as an agent task, i.e. it cannot be stopped or cancelled by the spawning agent, or if this agent is killed.

This function does nothing if one of the following conditions evaluates to true:
  • the agent is not alive.
Parameters:
nbAgents - the number of agents to spawn.
agentType - the type of the agents to spawn.
params - the arguments to pass in the initialization event to the spawned agents. All the agents will receive the same initialization parameters.
Fires SARL events:
AgentSpawned in DefaultSpace, AgentSpawnFailure if the agent cannot be spawned.
Since:
0.5
spawnInContext(Class<T>,AgentContext,Object*)
def spawnInContext(Class<T>,AgentContext,Object*)

fires AgentSpawned, AgentSpawnFailure

Spawns a new member agent in the parent's context (parentID).

Caution: when this function returns, there is no warranty that the spawned agent is initialized at the time of the return. Indeed, agent spawning is done in parallel to the calling thread. This parallel task for spawning is not considered as an agent task, i.e. it cannot be stopped or cancelled by the spawning agent, or if this agent is killed.

This function does nothing if one of the following conditions evaluates to true:
  • the agent is not alive.
Parameters:
agentClass - the type of the agent to spawn.
context - the context in which the agent must be spawned.
params - the arguments to pass to the initialization event that will be sent to the spawned agent.
Fires SARL events:
AgentSpawned inside the default context of the parent. The source of the event is this agent., AgentSpawnFailure if the agent cannot be spawned.
spawnInContext(int,Class<T>,AgentContext,Object*)
def spawnInContext(int,Class<T>,AgentContext,Object*)

fires AgentSpawned, AgentSpawnFailure

Spawns a group of agents in the parent's context (parentID).

Caution: when this function returns, there is no warranty that the spawned agents are initialized at the time of the return. Indeed, agent spawning is done in parallel to the calling thread. This parallel task for spawning is not considered as an agent task, i.e. it cannot be stopped or cancelled by the spawning agent, or if this agent is killed.

This function does nothing if one of the following conditions evaluates to true:
  • the agent is not alive.
Parameters:
nbAgents - the number of agents to spawn.
agentClass - the type of the agents to spawn.
context - the context in which the agents must be spawned.
params - the arguments to pass to the initialization event that will be sent to the spawned agents. All the agents will receive the same initialization parameters.
Fires SARL events:
AgentSpawned inside the default context of the parent. The source of the event is this agent., AgentSpawnFailure if the agent cannot be spawned.
Since:
0.5
spawnInContextWithID(Class<T>,UUID,AgentContext,Object*)
def spawnInContextWithID(Class<T>,UUID,AgentContext,Object*)

fires AgentSpawned, AgentSpawnFailure

Spawns a new member agent in the given context.

Caution: when this function returns, there is no warranty that the spawned agent is initialized at the time of the return. Indeed, agent spawning is done in parallel to the calling thread. This parallel task for spawning is not considered as an agent task, i.e. it cannot be stopped or cancelled by the spawning agent, or if this agent is killed.

This function does nothing if one of the following conditions evaluates to true:
  • the agent is not alive.
Parameters:
agentClass - the type of the agent to spawn.
agentID - the identifier of the spawned agent.
context - the context in which the agent must be spawned.
params - the arguments to pass to the initialization event that will be sent to the spawned agent.
Fires SARL events:
AgentSpawned inside the default context of the parent. The source of the event is this agent., AgentSpawnFailure if the agent cannot be spawned.
spawnWithID(Class<T>,UUID,Object*)
def spawnWithID(Class<T>,UUID,Object*)

fires AgentSpawned, AgentSpawnFailure

Spawns a new member agent in the parent's context (parentID).

Caution: when this function returns, there is no warranty that the spawned agent is initialized at the time of the return. Indeed, agent spawning is done in parallel to the calling thread. This parallel task for spawning is not considered as an agent task, i.e. it cannot be stopped or cancelled by the spawning agent, or if this agent is killed.

This function does nothing if one of the following conditions evaluates to true:
  • the agent is not alive.
Parameters:
agentClass - the type of the agent to spawn.
agentID - the identifier of the spawned agent.
params - the arguments to pass to the initialization event that will be sent to the spawned agent.
Fires SARL events:
AgentSpawned inside the default context of the parent. The source of the event is this agent., AgentSpawnFailure if the agent cannot be spawned.
Since:
0.12