anthill.nest
Interface Gate

All Superinterfaces:
Clearable
All Known Implementing Classes:
UdpGate, LocalGate

public interface Gate
extends Clearable

The Gate interface contains the set of methods used by a nest to communicate with other nests.

Gate is one of the components of a nest; the other are Manager), RequestSet, Storage and Trail.

Gate methods are invoked by AntView objects to implement methods move(), addNeighbour, getNeighbours and removeNeighbour(). The exact behavior of these methods depends on the implementation of Gate.

Version:
$Revision$
Author:
Alberto Montresor

Method Summary
 NestId getId()
          Returns the identifier of the nest containing this gate.
 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 interface anthill.util.Clearable
clear
 

Method Detail

getId

public NestId getId()
Returns the identifier of the nest containing this gate.

setAntListener

public void setAntListener(AntListener listener)
Sets the ant listener, i.e. the object that will accept the ants coming from other nests.
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.io.IOException,
                 java.lang.ClassCastException
Sends an ant to the specified nest. Both the nest identifier and the ant must be serializable or externalizable.
Throws:
java.lang.ClassCastException - raised if the nest identifier does not belong to the expected class
java.io.IOException - raised if problems have occurred during serialization and sending