|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--anthill.nestor.LocalAntView
Class LocalAntView is a simple implementation of interface
AntView
, which implements methods included in
it by invoking the opportune methods on the local nest.
Method Summary | |
void |
addAnt(Ant ant)
FIXME: Implement. |
void |
addNeighbour(NestId id)
Add the new neighbor information to the Gate object contained
in the current nest. |
void |
addResource(Resource resource)
Add a resource to the nest. |
AntId |
createAntId()
Creates a new ant identifier. |
Ant |
getAnt()
Returns the ant which is associated to this AntView . |
NestId |
getLastVisited()
Returns the identifier of the last nest visisted by this ant. |
Neighbour[] |
getNeighbours()
Ants invoke this method to obtain the list of nest neighbors known to the current nest. |
NestId |
getNestId()
Returns the identifier of the nest hosting the ant using this AntView . |
java.lang.Object |
getPheromone()
Get the pheromone information object related to the species of the ant associated to this AntView object. |
Resource |
getResource(java.lang.Object key)
Performs the specified request on the local resource storage and returns the resources satisfying the request. |
Resource[] |
getResources(java.lang.Object request)
Performs the specified request on the local resource storage and returns the resources satisfying the request. |
NestId |
getReturnNest(AntId aid,
boolean remove)
Lookup trail information on the Trail object stored
in the nest and move to the obtained nest. |
Storage |
getStorage(java.lang.String name)
Return a storage object identified by the given name. |
int |
getTTL()
|
int |
intValue(java.lang.String name)
Read from statistics |
void |
move(NestId id)
Moves an ant to the specified nest. |
void |
removeNeighbour(NestId id)
FIXME: Implement. |
boolean |
returnResources(RequestId rid,
Resource[] resources)
This method is invoked by ants to notify the nest that the ant associated to this AntView, created to satisfy a request, is returning the specified set of resources. |
void |
setPheromone(java.lang.Object pheromone)
Set the pheromone information object related to the species of the ant associated to this AntView object. |
boolean |
storeReturnNest(AntId aid,
NestId nid)
Leave trail information on the Trail object stored
in the nest. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public NestId getNestId()
AntView
AntView
.getNestId
in interface AntView
public NestId getLastVisited()
AntView
getLastVisited
in interface AntView
public int getTTL()
getTTL
in interface AntView
public Ant getAnt()
AntView
AntView
. Normally not
used by ants, as they may access the same information using
this
.getAnt
in interface AntView
public AntId createAntId()
createAntId
in interface AntView
public void addAnt(Ant ant)
The exact behavior of this method depends on the class implementing
the Manager
interface currently used in the current nest.
Please refer to the implementation documentation for more details.
Please see the corresponding method comment in interface
AntView
for additional information.
addAnt
in interface AntView
anthill.AntView
ant
- the ant to be added to the current nestpublic void move(NestId id) throws java.io.IOException
The exact behavior of this method depends on the class implementing
the Gate
interface currently used in the current nest.
Please refer to the implementation documentation for more details.
Please see the corresponding method comment in interface
AntView
for additional information.
move
in interface AntView
id
- the id of the destination nestjava.io.IOException
- if the ant cannot move to the
destination nest for communication problems.public boolean storeReturnNest(AntId aid, NestId nid)
Trail
object stored
in the nest. If absent, the trail is created. Return true if the
the information is left
The exact behavior of this method depends on the class implementing
the Trail
interface currently used in the current nest.
Please refer to the implementation documentation for more details.
Please see the corresponding method comment in interface
AntView
for additional information.
storeReturnNest
in interface AntView
anthill.AntView
true
if this is the first visit of this ant
to this nest (and thus, the information about the previous nest
has been stored successfully), or false
if this
ant has already visited the nest (and thus, the inforamtion about
the previous nest could not be stored).public NestId getReturnNest(AntId aid, boolean remove)
Trail
object stored
in the nest and move to the obtained nest. If the trail is absent,
IllegalStateException
is raised.
The exact behavior of this method depends on the class implementing
the Trail
interface currently used in the current nest.
Please refer to the implementation documentation for more details.
Please see the corresponding method comment in interface
AntView
for additional information.
getReturnNest
in interface AntView
remove
- true if the association (ant id, nest id)
should be removed after retrievalpublic void addNeighbour(NestId id) throws java.io.IOException
Gate
object contained
in the current nest. FIXME: correct implementation by removing addAntNeighbour
and adding the method to Gate.
The exact behavior of this method depends on the class implementing
the Gate
interface currently used in the current nest.
Please refer to the implementation documentation for more details.
Please see the corresponding method comment in interface
AntView
for additional information.
addNeighbour
in interface AntView
anthill.AntView
java.io.IOException
- if a connection with the nest cannot be established.public void removeNeighbour(NestId id)
The exact behavior of this method depends on the class implementing
the Gate
interface currently used in the current nest.
Please refer to the class documentation for more details.
Please see the corresponding method comment in interface
AntView
for additional information.
removeNeighbour
in interface AntView
public Neighbour[] getNeighbours()
The exact behavior of this method depends on the class implementing
the Gate
interface currently used in the current nest.
Please refer to the implementation documentation for more details.
Please see the corresponding method comment in interface
AntView
for additional information.
getNeighbours
in interface AntView
public Storage getStorage(java.lang.String name) throws StorageNotFoundException
getStorage
in interface AntView
public Resource[] getResources(java.lang.Object request) throws StorageNotFoundException
The exact behavior of this method depends on the implementation of the current nest hosting the ant. Please refer to the documentation of the nest implementation for more details.
getResources
in interface AntView
request
- The request to be performedpublic Resource getResource(java.lang.Object key) throws StorageNotFoundException
The exact behavior of this method depends on the implementation of the current nest hosting the ant. Please refer to the documentation of the nest implementation for more details.
getResource
in interface AntView
request
- The request to be performedpublic void addResource(Resource resource) throws CapacityException, StorageNotFoundException
Depending on the implementation of Resource
and Nest
, adding a resource to a nest through
an AntView may result to actual copy the content of the
resource, or to simply insert a reference to the actual
position of the resource itself.
This method may be invoked more than once from an ant, in
order to insert more resources. Nevertheless, the actual
insertion of a resource in a nest depends on the policies
of the particular Nest
implementation. For
example, a nest may limit the number of resources originated
by another nest, in order to avoid "spamming".
The exact behavior of this method depends on the implementation of the current nest hosting the ant. Please refer to the documentation of the nest implementation for more details.
addResource
in interface AntView
resource
- resource to be addedpublic java.lang.Object getPheromone()
AntView
object. Different
ant species are associated to different pheromone objects.
Please see the corresponding method comment in interface
AntView
for additional information.
getPheromone
in interface AntView
public void setPheromone(java.lang.Object pheromone)
AntView
object. Different
ant species are associated to different pheromone objects.setPheromone
in interface AntView
pheromone
- the pheromone object to be set.
Please see the corresponding method comment in interface
AntView
for additional information.
public boolean returnResources(RequestId rid, Resource[] resources)
returnResources
in interface AntView
request
- the request to be performedresources
- the resources satisfying the querypublic int intValue(java.lang.String name)
intValue
in interface AntView
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |