|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--anthill.nestor.LocalNest
A Nest class collects the components of a Nest site: (i) a AntView object, which is the view of a Nest for an Ant; (ii) a Gate object, which manage the communication between nests; (iii) an Manager, i.e. the object which manage the activities performed by different agents.
Implementation note: this implementation is supposed to be used as
simple implementation of Nest
in the off-line
environment. Here, we assume that the Manager object used is single-threaded;
in this way, we avoid the costs of synchronized methods.
Constructor Summary | |
LocalNest(Factory factory,
int ttl)
Constructs a new nest, by putting together a Storage (a resource database), a Gate (i.e. the basic API for communicating with other nests) and an Manager (i.e., a thread handler managing the agent execution). |
Method Summary | |
void |
addAntNeighbour(NestId aid)
Add the identifier of a new neighbour anthill to the set of neighbours known to this Nest , on behalf of
an ant. |
void |
addClientNeighbour(NestId aid)
Add the identifier of a new neighbour anthill to the set of neighbours known to this Nest , on behalf of
an Nest client. |
void |
clear()
Restores the object to its initial state. |
void |
deliver(AntDescriptor desc)
Receive an agent from outside and deliver it to the to the activity manager. |
NestId |
getId()
Return the identifier of this Nest |
Manager |
getManager()
Return the Manager associated to this Nest |
Neighbour[] |
getNeighbours()
Return the neighbours known to this Nest |
java.lang.Object |
getPheromone(java.lang.Class cl)
Return the pheromone associated to the link to this neighbour. |
void |
insert(Resource resource)
Insert a new resource in this anthill. |
void |
removeNeighbour(NestId aid)
Remove a neighbour identifier from the set of neighbour |
void |
request(java.lang.Object request,
ResponseListener listener)
Accepts a request from the nest user. |
void |
setPheromone(java.lang.Object pheromone,
java.lang.Class cl)
Return the pheromone associated to the link to this neighbour. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public LocalNest(Factory factory, int ttl)
Method Detail |
public void deliver(AntDescriptor desc)
deliver
in interface AntListener
anthill.nest.AntListener
sender
- the identifier of the nest from which this ant
has been receiveddesc
- the ant descriptor of the received antjava.rmi.RemoteException
- added to the throw clause to respect
the conventions for remote interfaces.public NestId getId()
getId
in interface Nest
public Manager getManager()
getManager
in interface Nest
public void request(java.lang.Object request, ResponseListener listener)
Implementation note: If the resource can be found locally,
the listener is immediately contacted. Otherwise, a new
Ant
is generated and is delivered to the ant
manager.
request
in interface Nest
request
- the request to be performedlistener
- The listener object which will be notified
when the request is completed.public void insert(Resource resource)
insert
in interface Nest
resource
- the resource to be inserted.public void addClientNeighbour(NestId aid)
Nest
, on behalf of
an Nest client.addClientNeighbour
in interface Nest
aid
- neighbour identifierpublic void addAntNeighbour(NestId aid)
Nest
, on behalf of
an ant.addAntNeighbour
in interface Nest
aid
- neighbour identifierpublic void removeNeighbour(NestId aid)
removeNeighbour
in interface Nest
aid
- neighbour identifierpublic Neighbour[] getNeighbours()
getNeighbours
in interface Nest
public java.lang.Object getPheromone(java.lang.Class cl)
public void setPheromone(java.lang.Object pheromone, java.lang.Class cl)
public void clear()
clear
in interface Clearable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |