anthill.nestor
Class LocalGate

java.lang.Object
  |
  +--anthill.nestor.LocalGate
All Implemented Interfaces:
Clearable, Gate

public class LocalGate
extends java.lang.Object
implements Gate

Class LocalGate is the implementation of Gate to be used during off-line simulations. Communication among different LocalGates is based on local method invocations.

Version:
$Revision$
Author:
Alberto Montresor

Constructor Summary
LocalGate()
          Initializes a new LocalGate by creating a new local nest identifier.
 
Method Summary
 void clear()
          Restores the object to its initial state.
 NestId getId()
          Returns the identifier of the Nest to which this gate is associated.
 void send(NestId dest, Ant ant, int ttl)
          Sends an ant to the specified nest.
 void setAntListener(AntListener listener)
          Sets the ant listener, i.e. the object that will accept the ants coming from other nests.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalGate

public LocalGate()
Initializes a new LocalGate by creating a new local nest identifier.
Method Detail

getId

public NestId getId()
Returns the identifier of the Nest to which this gate is associated.
Specified by:
getId in interface Gate

setAntListener

public void setAntListener(AntListener listener)
Sets the ant listener, i.e. the object that will accept the ants coming from other nests.
Specified by:
setAntListener in interface Gate
Parameters:
listener - the listener object that will accepts the ants coming from other nests

send

public void send(NestId dest,
                 Ant ant,
                 int ttl)
          throws java.lang.ClassCastException
Sends an ant to the specified nest. Both the nest identifier and the ant must be serializable or externalizable.
Specified by:
send in interface Gate
Throws:
java.lang.ClassCastException - raised if the nest identifier does not belong to the expected class
IOException - raised if problems have occurred during serialization and sending

clear

public void clear()
Restores the object to its initial state.
Specified by:
clear in interface Clearable