cz.cuni.amis.pogamut.base3d.worldview
Class Vision

java.lang.Object
  extended by cz.cuni.amis.pogamut.base3d.worldview.Vision
All Implemented Interfaces:
IWorldEventListener<IWorldObjectEvent<IViewable>>, IWorldObjectEventListener<IViewable,IWorldObjectEvent<IViewable>>, IWorldObjectListener<IViewable>, IListener<IWorldObjectEvent<IViewable>>, java.util.EventListener

public class Vision
extends java.lang.Object
implements IWorldObjectListener<IViewable>

Vision is taking care about the objects the bot might see (of all implementing IViewable interface).


Nested Class Summary
 
Nested classes/interfaces inherited from interface cz.cuni.amis.utils.listener.IListener
IListener.Notifier<LISTENER extends IListener>
 
Constructor Summary
Vision(IWorldView worldView, IAgentLogger logger)
           
 
Method Summary
protected
<T> java.util.Map<WorldObjectId,T>
addNewObjectCategory(java.lang.Class<T> cls)
          Used to introduce new object category into worldObjects and immutableWorldObjects.
protected  void addSeeObject(IWorldObject seeObject)
          Method that adds a new world object to the object maps.
 java.util.Map<java.lang.Class,java.util.Map<WorldObjectId,IWorldObject>> getSee()
          Returns map of all objects the agent can currently see.
<T> java.util.Map<WorldObjectId,T>
getSee(java.lang.Class<T> type)
          Returns map map of all objects of a certain type the agent can currently see.
 IWorldObject getSee(WorldObjectId id)
          If agents sees item of 'id' it returns it instances, otherwise it returns null.
protected  IWorldObject getSeeObject(WorldObjectId objectId)
          Returns world object of the given id or null if the object is not yet in the world view.
 void notify(IWorldObjectEvent<IViewable> event)
           
protected  void removeSeeObject(IWorldObject worldObject)
          Removes world object from the world view - this will be called from the descendants of the AbstractWorldView whenever world object should disappear from the world view.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Vision

@Inject
public Vision(IWorldView worldView,
                     IAgentLogger logger)
Method Detail

notify

public void notify(IWorldObjectEvent<IViewable> event)
Specified by:
notify in interface IListener<IWorldObjectEvent<IViewable>>

addNewObjectCategory

protected <T> java.util.Map<WorldObjectId,T> addNewObjectCategory(java.lang.Class<T> cls)
Used to introduce new object category into worldObjects and immutableWorldObjects.

It will create new synchronized Map<IWorldViewObjectId, T> in the worldObjects and it's immutable counterpart in immutableWorldObjects under key of 'cls'.

Returns modifiable version of created map.

Type Parameters:
T -
Parameters:
cls -
Returns:

addSeeObject

protected void addSeeObject(IWorldObject seeObject)
Method that adds a new world object to the object maps. It will be called from the descendant whenever new object appears in the world view.

Parameters:
worldObject -

getSeeObject

protected IWorldObject getSeeObject(WorldObjectId objectId)
Returns world object of the given id or null if the object is not yet in the world view.

Parameters:
objectId -
Returns:

removeSeeObject

protected void removeSeeObject(IWorldObject worldObject)
Removes world object from the world view - this will be called from the descendants of the AbstractWorldView whenever world object should disappear from the world view.

Parameters:
worldObject -

getSee

public java.util.Map<java.lang.Class,java.util.Map<WorldObjectId,IWorldObject>> getSee()
Returns map of all objects the agent can currently see.

WARNING: returns immutable map!

Returns:

getSee

public <T> java.util.Map<WorldObjectId,T> getSee(java.lang.Class<T> type)
Returns map map of all objects of a certain type the agent can currently see.

WARNING: returns immutable map!

Parameters:
type -
Returns:

getSee

public IWorldObject getSee(WorldObjectId id)
If agents sees item of 'id' it returns it instances, otherwise it returns null.

Parameters:
id -
Returns: