org.kaariboga.agents
Class ReturnAgent

java.lang.Object
  |
  +--org.kaariboga.core.Kaariboga
        |
        +--org.kaariboga.agents.ReturnAgent
All Implemented Interfaces:
KbMessageHandler, java.lang.Runnable, java.io.Serializable

public class ReturnAgent
extends Kaariboga

Example of a simple kaariboga that travels to another base returns and destroys itself.

See Also:
Serialized Form

Inner classes inherited from class org.kaariboga.core.Kaariboga
Kaariboga.FireEventThread, Kaariboga.FireMessageThread
 
Field Summary
(package private)  int trips
          Number of trips.
 
Fields inherited from class org.kaariboga.core.Kaariboga
base, destination, kaaribogaListener, messageListener, name
 
Constructor Summary
ReturnAgent(java.lang.String name)
          Just initialize the super class.
 
Method Summary
 void onArrival()
          This is called before run when the agent arrives from a trip.
 void onCreate()
          This method is called when base has done some initialisation on the agent and before run.
 void onDispatch()
          This method is called before the agent gets dispatched to another base.
 void run()
          Run is called every time an agent get's loaded or arrives on a base.
 
Methods inherited from class org.kaariboga.core.Kaariboga
addKaaribogaListener, addKaaribogaMessageListener, fireDestroyRequest, fireDispatchRequest, fireKaaribogaMessage, fireSleepRequest, getDestination, getName, handleMessage, onAwake, onDestroy, onSleep, setBase, toString
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

trips

int trips
Number of trips.
Constructor Detail

ReturnAgent

public ReturnAgent(java.lang.String name)
Just initialize the super class.
Parameters:
name - The name of the agent. This name has to be unique. Normally the KaaribogaBase class provides some method to generate a unique name.
Method Detail

onCreate

public void onCreate()
This method is called when base has done some initialisation on the agent and before run.
Overrides:
onCreate in class Kaariboga

run

public void run()
Run is called every time an agent get's loaded or arrives on a base.
Overrides:
run in class Kaariboga

onArrival

public void onArrival()
This is called before run when the agent arrives from a trip.
Overrides:
onArrival in class Kaariboga

onDispatch

public void onDispatch()
This method is called before the agent gets dispatched to another base. The method should be used to do clean up when the agent has locked some resources.
Overrides:
onDispatch in class Kaariboga