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

Package class diagram package 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:
IWorldChangeEventInput, IComponent, ILocalWorldView
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  LinkedList<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 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)
          New event was generated from the world.
 void notifyAfterPropagation(IWorldChangeEvent event)
          Raise another event after current one finishes its propagation.
 void notifyImmediately(IWorldChangeEvent event)
          Calls notify without waiting for batches, locks or anything else.
protected  void objectCreated(ILocalWorldObject obj, long time)
          Must be called whenever an object was created, raises correct events.
protected  void objectDestroyed(ILocalWorldObject obj, long time)
          Must be called whenever an object was destroyed - raises correct events.
protected  void objectUpdated(ILocalWorldObject obj, long time)
          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, 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 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 LinkedList<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
Description copied from interface: IWorldChangeEventInput
New event was generated from the world.

Throws:
ComponentNotRunningException
ComponentPausedException

notifyAfterPropagation

public void notifyAfterPropagation(IWorldChangeEvent event)
                            throws ComponentNotRunningException,
                                   ComponentPausedException
Description copied from interface: IWorldChangeEventInput
Raise another event after current one finishes its propagation.

Won't propagate the event if the world view is locked!.

Throws:
ComponentNotRunningException
ComponentPausedException

notifyImmediately

public void notifyImmediately(IWorldChangeEvent event)
                       throws ComponentNotRunningException,
                              ComponentPausedException
Description copied from interface: ILocalWorldView
Calls notify without waiting for batches, locks or anything else.

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,
                             long time)
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,
                             long time)
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,
                               long time)
Must be called whenever an object was destroyed - raises correct events.

Might be overriden to provide different behavior.

Parameters:
obj -


Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.