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

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
All Implemented Interfaces:
IComponent, ILocalWorldView, ITimedWorldChangeEventInput
Direct Known Subclasses:
VisionLocalWorldView

public abstract class EventDrivenLocalWorldView
extends AbstractLocalWorldView


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.Queue<IWorldChangeEvent> notifyEventsList
          List of events we have to process.
protected  boolean receiveEventProcessing
          Flag that is telling us whether there is an event being processed or not.
static java.lang.String 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
EventDrivenLocalWorldView(ComponentDependencies dependencies, ILifecycleBus bus, IAgentLogger logger, ISharedWorldView sharedWV, ITeamedAgentId agentId)
           
 
Method Summary
protected  void innerNotify(IWorldChangeEvent event)
          Used to process IWorldChangeEvent - it has to be either IWorldChangeEvent or IWorldObjectUpdateEvent.
 void notify(IWorldChangeEvent event)
           
protected  void objectCreated(ILocalWorldObject obj)
          Must be called whenever an object was created, raises correct events.
protected  void objectDestroyed(ILocalWorldObject obj)
          Must be called whenever an object was destroyed - raises correct events.
protected  void objectUpdated(ILocalWorldObject obj)
          Must be called whenever an object was updated - raises correct event.
protected  void objectUpdatedEvent(ILocalWorldObjectUpdatedEvent updateEvent)
          Called from EventDrivenWorldView.innerNotify(IWorldChangeEvent) if the event is IWorldObjectUpdatedEvent to process it.
protected  void raiseEvent(IWorldEvent event)
          Catches exceptions.
 
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
 

Field Detail

WORLDVIEW_DEPENDENCY

public static final java.lang.String WORLDVIEW_DEPENDENCY
See Also:
Constant Field Values

receiveEventProcessing

protected boolean receiveEventProcessing
Flag that is telling us whether there is an event being processed or not.

It is managed only by notify() method - DO NOT MODIFY OUTSIDE IT!


notifyEventsList

protected java.util.Queue<IWorldChangeEvent> notifyEventsList
List of events we have to process.

It is managed only by notify() method - DO NOT MODIFY OUTSIDE IT!

Constructor Detail

EventDrivenLocalWorldView

public EventDrivenLocalWorldView(ComponentDependencies dependencies,
                                 ILifecycleBus bus,
                                 IAgentLogger logger,
                                 ISharedWorldView sharedWV,
                                 ITeamedAgentId agentId)
Method Detail

notify

public void notify(IWorldChangeEvent event)
            throws ComponentNotRunningException,
                   ComponentPausedException
Throws:
ComponentNotRunningException
ComponentPausedException

raiseEvent

protected void raiseEvent(IWorldEvent event)
Catches exceptions. If exception is caught, it calls ComponentController.fatalError() and this.kill().

Overrides:
raiseEvent in class AbstractLocalWorldView

innerNotify

protected void innerNotify(IWorldChangeEvent event)
Used to process IWorldChangeEvent - it has to be either IWorldChangeEvent or IWorldObjectUpdateEvent. Forbids recursion.

DO NOT CALL SEPARATELY - should be called only from notifyEvent().

You may override it to provide event-specific processing behavior.

Parameters:
event -

objectUpdatedEvent

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

Parameters:
updateEvent -

objectCreated

protected void objectCreated(ILocalWorldObject obj)
Must be called whenever an object was created, raises correct events.

Might be overridden to provide different behavior.

Parameters:
obj -

objectUpdated

protected void objectUpdated(ILocalWorldObject obj)
Must be called whenever an object was updated - raises correct event.

Might be overridden to provide a mechanism that will forbid update of certain objects (like items that can't move).

Parameters:
obj -

objectDestroyed

protected void objectDestroyed(ILocalWorldObject obj)
Must be called whenever an object was destroyed - raises correct events.

Might be overriden to provide different behavior.

Parameters:
obj -