cz.cuni.amis.pogamut.multi.communication.worldview.impl
Class VisionLocalWorldView

java.lang.Object
  extended by cz.cuni.amis.pogamut.multi.communication.worldview.impl.AbstractLocalWorldView
      extended by cz.cuni.amis.pogamut.multi.communication.worldview.impl.EventDrivenLocalWorldView
          extended by cz.cuni.amis.pogamut.multi.communication.worldview.impl.VisionLocalWorldView
All Implemented Interfaces:
IComponent, ILocalWorldView, ITimedWorldChangeEventInput, IVisionLocalWorldView
Direct Known Subclasses:
BatchAwareLocalWorldView

public abstract class VisionLocalWorldView
extends EventDrivenLocalWorldView
implements IVisionLocalWorldView

VisionLocalWorldView manages information about all objects currently in the bot's FOV (field-of-view) by implementing methods from IVisionLocalWorldView interface.


Nested Class Summary
 
Nested classes/interfaces inherited from class cz.cuni.amis.pogamut.multi.communication.worldview.impl.AbstractLocalWorldView
AbstractLocalWorldView.LazyCompositeObjectMap<T extends ICompositeWorldObject>
 
Field Summary
protected  java.util.Map<java.lang.Class,java.util.Map<WorldObjectId,IViewable>> syncVisibleClassMap
          Synchronized version of visible objects sorted according to class.
protected  java.util.Map<WorldObjectId,IViewable> syncVisibleMap
          Synchronized version of visible objects.
protected  java.util.Map<java.lang.Class,java.util.Map<WorldObjectId,IViewable>> visibleClassMap
          Map of all currently visible objects, sorted according to their classes.
protected  AbstractLocalWorldView.LazyCompositeObjectMap<IViewable> visibleMap
          Map of all currently visible objects.
 
Fields inherited from class cz.cuni.amis.pogamut.multi.communication.worldview.impl.EventDrivenLocalWorldView
notifyEventsList, receiveEventProcessing, WORLDVIEW_DEPENDENCY
 
Fields inherited from class cz.cuni.amis.pogamut.multi.communication.worldview.impl.AbstractLocalWorldView
actLocalWorldObjects, agentId, classMap, COMPONENT_ID, control, controller, eventBus, log, sharedWorldView, syncClassMap
 
Constructor Summary
VisionLocalWorldView(ComponentDependencies dependencies, ILifecycleBus bus, IAgentLogger logger, ISharedWorldView parentWorldView, ITeamedAgentId agentId)
           
 
Method Summary
protected  void addVisible(ILocalViewable obj)
          Adds the provided object as visible into all visibleMaps int the worldView.
 java.util.Map<java.lang.Class,java.util.Map<WorldObjectId,IViewable>> getAllVisible()
          Returns map of all visible objects (IViewable instances} - those that the agent can currently see.
<T extends IViewable>
java.util.Map<WorldObjectId,T>
getAllVisible(java.lang.Class<T> type)
          Returns map of all visible objects (IViewable instances} - those that the agent can currently see.
 java.util.Map<WorldObjectId,IViewable> getVisible()
          Returns map of all visible objects (IViewable instances} organized according to their WorldObjectId - those that the agent can currently see.
 IViewable getVisible(WorldObjectId id)
          Returns a visible world object of the specific id (if exists inside the world view and is visible).
 void notify(IWorldChangeEvent event)
           
protected  void objectAppeared(ILocalViewable obj)
          Handles events for making the object visible.
 void objectCreated(ILocalWorldObject obj)
          Must be called whenever an object was created, raises correct events.
 void objectDestroyed(ILocalWorldObject obj)
          Must be called whenever an object was destroyed - raises correct events.
protected  void objectDisappeared(ILocalViewable obj)
          Handles events for making the object not visible.
protected  void objectUpdatedEvent(ILocalWorldObjectUpdatedEvent updateEvent)
          Called from EventDrivenWorldView.innerNotify(IWorldChangeEvent) if the event is IWorldObjectUpdatedEvent to process it.
protected  void removeVisible(ILocalViewable obj)
          Removes object of the same objectId as the provided localObject from visible maps.
 
Methods inherited from class cz.cuni.amis.pogamut.multi.communication.worldview.impl.EventDrivenLocalWorldView
innerNotify, objectUpdated, raiseEvent
 
Methods inherited from class cz.cuni.amis.pogamut.multi.communication.worldview.impl.AbstractLocalWorldView
addEventListener, addLocalWorldObject, addObjectListener, addObjectListener, addObjectListener, addObjectListener, addOldLocalWorldObject, cleanUp, createCompositeObject, get, get, get, get, getAgentId, getAll, getAll, getAll, getAll, getComponentId, getCurrentTimeKey, getEventBus, getLocal, getLocal, getMostRecentLocalWorldObject, getSingle, getSingle, isListening, isListening, isListening, isListening, isListening, isListening, isPaused, isRunning, kill, lockTime, pause, prePause, preStop, removeEventListener, removeListener, removeLocalWorldObject, removeObjectListener, removeObjectListener, removeObjectListener, removeObjectListener, reset, resume, setCurrentTime, setInitialTime, start, stop, unlockTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface cz.cuni.amis.pogamut.multi.communication.worldview.ILocalWorldView
addEventListener, addObjectListener, addObjectListener, addObjectListener, addObjectListener, get, get, getAgentId, getAll, getAll, getCurrentTimeKey, getEventBus, getLocal, getSingle, isListening, isListening, isListening, isListening, isListening, isListening, lockTime, removeEventListener, removeListener, removeObjectListener, removeObjectListener, removeObjectListener, removeObjectListener, setCurrentTime, setInitialTime, unlockTime
 
Methods inherited from interface cz.cuni.amis.pogamut.base.component.IComponent
getComponentId
 

Field Detail

visibleMap

protected AbstractLocalWorldView.LazyCompositeObjectMap<IViewable> visibleMap
Map of all currently visible objects.


syncVisibleMap

protected java.util.Map<WorldObjectId,IViewable> syncVisibleMap
Synchronized version of visible objects.


visibleClassMap

protected java.util.Map<java.lang.Class,java.util.Map<WorldObjectId,IViewable>> visibleClassMap
Map of all currently visible objects, sorted according to their classes.


syncVisibleClassMap

protected java.util.Map<java.lang.Class,java.util.Map<WorldObjectId,IViewable>> syncVisibleClassMap
Synchronized version of visible objects sorted according to class.

Constructor Detail

VisionLocalWorldView

public VisionLocalWorldView(ComponentDependencies dependencies,
                            ILifecycleBus bus,
                            IAgentLogger logger,
                            ISharedWorldView parentWorldView,
                            ITeamedAgentId agentId)
Method Detail

notify

public void notify(IWorldChangeEvent event)
Specified by:
notify in interface ITimedWorldChangeEventInput
Overrides:
notify in class EventDrivenLocalWorldView

objectUpdatedEvent

protected void objectUpdatedEvent(ILocalWorldObjectUpdatedEvent updateEvent)
Description copied from class: EventDrivenLocalWorldView
Called from EventDrivenWorldView.innerNotify(IWorldChangeEvent) if the event is IWorldObjectUpdatedEvent to process it.

Overrides:
objectUpdatedEvent in class EventDrivenLocalWorldView

objectCreated

public void objectCreated(ILocalWorldObject obj)
Description copied from class: EventDrivenLocalWorldView
Must be called whenever an object was created, raises correct events.

Might be overridden to provide different behavior.

Overrides:
objectCreated in class EventDrivenLocalWorldView

objectDestroyed

public void objectDestroyed(ILocalWorldObject obj)
Description copied from class: EventDrivenLocalWorldView
Must be called whenever an object was destroyed - raises correct events.

Might be overriden to provide different behavior.

Overrides:
objectDestroyed in class EventDrivenLocalWorldView

objectAppeared

protected void objectAppeared(ILocalViewable obj)
Handles events for making the object visible.

Parameters:
obj -

objectDisappeared

protected void objectDisappeared(ILocalViewable obj)
Handles events for making the object not visible.

Parameters:
obj -

addVisible

protected void addVisible(ILocalViewable obj)
Adds the provided object as visible into all visibleMaps int the worldView. Note that since the cached visible objects are composite and the parameter for this method is a local object, only the id and the getCompositeClass of the object are actually used.

Parameters:
obj -

removeVisible

protected void removeVisible(ILocalViewable obj)
Removes object of the same objectId as the provided localObject from visible maps. Note that the provided ILocalViewable object has to implement the getCompositeClass() method to return the correct composite object class.

Parameters:
obj -

getAllVisible

public java.util.Map<java.lang.Class,java.util.Map<WorldObjectId,IViewable>> getAllVisible()
Description copied from interface: IVisionLocalWorldView
Returns map of all visible objects (IViewable instances} - those that the agent can currently see.

WARNING: If you will do iteration over the map, you must synchronize on it.

Specified by:
getAllVisible in interface IVisionLocalWorldView

getAllVisible

public <T extends IViewable> java.util.Map<WorldObjectId,T> getAllVisible(java.lang.Class<T> type)
Description copied from interface: IVisionLocalWorldView
Returns map of all visible objects (IViewable instances} - those that the agent can currently see.

WARNING: If you will do iteration over the map, you must synchronize on it.

Specified by:
getAllVisible in interface IVisionLocalWorldView
Returns:

getVisible

public java.util.Map<WorldObjectId,IViewable> getVisible()
Description copied from interface: IVisionLocalWorldView
Returns map of all visible objects (IViewable instances} organized according to their WorldObjectId - those that the agent can currently see.

WARNING: If you will do iteration over the map, you must synchronize on it.

Specified by:
getVisible in interface IVisionLocalWorldView
Returns:

getVisible

public IViewable getVisible(WorldObjectId id)
Description copied from interface: IVisionLocalWorldView
Returns a visible world object of the specific id (if exists inside the world view and is visible).

Otherwise, null is returned.

Specified by:
getVisible in interface IVisionLocalWorldView
Parameters:
id - objects's id
Returns: