cz.cuni.amis.pogamut.base.communication.worldview.impl
Class LockableWorldView

java.lang.Object
  extended by cz.cuni.amis.pogamut.base.communication.worldview.impl.AbstractWorldView
      extended by cz.cuni.amis.pogamut.base.communication.worldview.impl.EventDrivenWorldView
          extended by cz.cuni.amis.pogamut.base.communication.worldview.impl.LockableWorldView
All Implemented Interfaces:
ILockableWorldView, IWorldChangeEventInput, IWorldView, IComponent

public class LockableWorldView
extends EventDrivenWorldView
implements ILockableWorldView

WorldView that can be locked. If the world is locked all chages on objects are postponed and issued when the world is unlocked. The events aren't locked by default, but there is a switch that enables locking of events.


Field Summary
protected  java.util.List<IWorldChangeEvent> eventsToProcess
          List of events received when the worldview was locked.
protected  boolean lockEvents
          Lock non object update events?
static java.lang.String WORLDVIEW_DEPENDENCY
           
 
Fields inherited from class cz.cuni.amis.pogamut.base.communication.worldview.impl.EventDrivenWorldView
notifyEventsList, receiveEventProcessing
 
Fields inherited from class cz.cuni.amis.pogamut.base.communication.worldview.impl.AbstractWorldView
COMPONENT_ID, control, controller, eventBus, log
 
Constructor Summary
LockableWorldView(ComponentDependencies dependencies, IComponentBus bus, IAgentLogger log)
           
 
Method Summary
 boolean isLocked()
          Whether the worldview is locked.
 boolean isLockEvents()
           
 void lock()
          Prevent the WorldView from being changed.
 void notifyEvent(IWorldChangeEvent event)
          Store all changes for later processing when the event is received in the while the world is locked.
 void setLockEvents(boolean lockEvents)
          Should the event processing also be locked? The object updating isn't affected by this switch.
 void unlock()
          Unlock the WorldView and process all changes that happened when the world was locked.
 
Methods inherited from class cz.cuni.amis.pogamut.base.communication.worldview.impl.EventDrivenWorldView
innerNotify, notify, notifyImmediately, objectCreated, objectDestroyed, objectUpdated, objectUpdatedEvent, raiseEvent
 
Methods inherited from class cz.cuni.amis.pogamut.base.communication.worldview.impl.AbstractWorldView
addEventListener, addObjectListener, addObjectListener, addObjectListener, addObjectListener, addWorldObject, cleanUp, get, get, getAll, getAll, getComponentId, getEventBus, getLog, getSingle, isListening, isListening, isListening, isListening, isListening, isListening, isPaused, isRunning, kill, pause, prePause, preStop, removeEventListener, removeListener, removeObjectListener, removeObjectListener, removeObjectListener, removeObjectListener, removeWorldObject, reset, resume, start, stop, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface cz.cuni.amis.pogamut.base.communication.worldview.IWorldView
addEventListener, addObjectListener, addObjectListener, addObjectListener, addObjectListener, get, get, getAll, getAll, getEventBus, getSingle, isListening, isListening, isListening, isListening, isListening, isListening, removeEventListener, removeListener, removeObjectListener, removeObjectListener, removeObjectListener, removeObjectListener
 
Methods inherited from interface cz.cuni.amis.pogamut.base.communication.worldview.IWorldChangeEventInput
notify, notifyImmediately
 
Methods inherited from interface cz.cuni.amis.pogamut.base.component.IComponent
getComponentId
 

Field Detail

WORLDVIEW_DEPENDENCY

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

eventsToProcess

protected java.util.List<IWorldChangeEvent> eventsToProcess
List of events received when the worldview was locked.


lockEvents

protected boolean lockEvents
Lock non object update events?

Constructor Detail

LockableWorldView

@Inject
public LockableWorldView(ComponentDependencies dependencies,
                                IComponentBus bus,
                                IAgentLogger log)
Method Detail

lock

public void lock()
          throws ComponentNotRunningException
Prevent the WorldView from being changed.

Specified by:
lock in interface ILockableWorldView
Throws:
ComponentNotRunningException

unlock

public void unlock()
Unlock the WorldView and process all changes that happened when the world was locked.

Specified by:
unlock in interface ILockableWorldView

isLocked

public boolean isLocked()
Description copied from interface: ILockableWorldView
Whether the worldview is locked.

Specified by:
isLocked in interface ILockableWorldView
Returns:

setLockEvents

public void setLockEvents(boolean lockEvents)
Should the event processing also be locked? The object updating isn't affected by this switch.

Parameters:
lockEvents -

isLockEvents

public boolean isLockEvents()

notifyEvent

public void notifyEvent(IWorldChangeEvent event)
Store all changes for later processing when the event is received in the while the world is locked. Otherwise immedeately process the change.

Parameters:
event -