|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--antsim.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.
Field Summary | |
static String |
PAR_TTL
String name of the parameter used to determine the ttl used by these nests. |
Fields inherited from interface anthill.nest.Nest |
NAME |
Constructor Summary | |
LocalNest(Factory factory,
String name)
Constructs a new nest. |
Method Summary | |
void |
addAntNeighbour(NestId aid)
Add the identifier of a new neighbour nest 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 nest to the set of neighbours known to this Nest , on behalf of
an Nest client. |
void |
clear()
Restores the object to its initial state. |
ResourceManager |
createResourceManager(String name,
String species)
Returns a reference to the resource manager identified by the given name. |
void |
deliver(AntDescriptor desc)
Receive an agent from outside and deliver it to the to the activity manager. |
Manager |
getManager()
Return the Manager associated to this Nest |
Neighbour[] |
getNeighbours()
Return the neighbours known to this Nest |
NestId |
getNestId()
Return the identifier of this Nest |
ResourceManager |
getResourceManager(String name,
String species)
Returns a reference to the resource manager identified by the given name. |
void |
leave()
Forces the nest to exit. |
void |
removeNeighbour(NestId aid)
Remove a neighbour identifier from the set of neighbour |
void |
request(RequestId rid,
Object request,
ResponseListener listener)
Accepts a request from the nest user. |
String |
toString()
FIXME .... |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final String PAR_TTL
Constructor Detail |
public LocalNest(Factory factory, String name)
factory
- the factory to be used to read configuration arguments
and to create other configurable objectsname
- the name that is associated to this instance in the
configuration fileMethod Detail |
public void clear()
clear
in interface Clearable
public void deliver(AntDescriptor desc)
deliver
in interface AntListener
desc
- the ant descriptor of the received antpublic void leave()
leave
in interface SimulatedNest
public NestId getNestId()
getNestId
in interface Nest
public Manager getManager()
getManager
in interface SimulatedNest
public void request(RequestId rid, 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.rid
- the request identifier, created and managed by the
invoker of this method.public ResourceManager getResourceManager(String name, String species)
getResourceManager
in interface Nest
name
- the name of the manager to obtain a reference tospecies
- the name of the ant species to which the manager is
associated
null
if no such resource manager is found.public ResourceManager createResourceManager(String name, String species) throws ResourceManagerException
createResourceManager
in interface Nest
name
- the name of the manager to obtain a reference tospecies
- the name of the ant species to which the manager is
associated
null
if no such resource manager is found.
ResourceManagerException
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 String toString()
toString
in class Object
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |