anthill.nest
Interface Gate

All Superinterfaces:
Clearable
All Known Implementing Classes:
GateService, 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: 1.7 $
Author:
Alberto Montresor

Field Summary
static String NAME
          Identifier used in the configuration files
 
Method Summary
 NestId getNestId()
          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
 

Field Detail

NAME

public static final String NAME
Identifier used in the configuration files

See Also:
Constant Field Values
Method Detail

getNestId

public NestId getNestId()
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 IOException,
                 ClassCastException
Sends an ant to the specified nest. Both the nest identifier and the ant must be serializable or externalizable.

Throws:
ClassCastException - raised if the nest identifier does not belong to the expected class
IOException - raised if problems have occurred during serialization and sending