public abstract class BatchAwareLocalWorldView extends VisionLocalWorldView
AbstractLocalWorldView.LazyCompositeObjectMap<T extends ICompositeWorldObject>| Modifier and Type | Field and Description |
|---|---|
protected Map<WorldObjectId,Set<DummyObjectEvent.EventType>> |
bufferedEvents |
protected List<DummyObjectEvent> |
eventBuffer |
syncVisibleClassMap, syncVisibleMap, visibleClassMap, visibleMapnotifyEventsList, receiveEventProcessing, WORLDVIEW_DEPENDENCYactLocalWorldObjects, agentId, classMap, COMPONENT_ID, control, controller, eventBus, log, sharedWorldView, syncClassMap| Constructor and Description |
|---|
BatchAwareLocalWorldView(ComponentDependencies dependencies,
ILifecycleBus bus,
IAgentLogger logger,
ISharedWorldView parentWorldView,
ITeamedAgentId agentId) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
bufferObjectEvent(WorldObjectId id,
DummyObjectEvent.EventType eventType,
long time)
This is used for raising object events safely
by buffering the object events, we make sure that when the events are raised and listeners notified,
the update event has been fully processed and the object contains correct and consistent data.
|
protected abstract void |
disappearObject(WorldObjectId id,
long time)
Sets the visible property on the object to false by creating a disappeared event
also raises correct events
|
protected void |
flushEvents()
Raises all events from this batch
|
protected abstract boolean |
isBatchBeginEvent(IWorldChangeEvent event)
Used to identify events marking beginning of batches.
|
protected abstract boolean |
isBatchEndEvent(IWorldChangeEvent event)
Used to detect batch end events, needs to be overriden to detect the events properly.
|
boolean |
isLocked() |
protected void |
kill()
Kills the world view.
|
void |
lock()
Must be called before starting logic.
|
void |
notify(IWorldChangeEvent event)
New event was generated from the world.
|
protected void |
notifySharedBegin(long time)
Notifies sharedWorldView that a beginEvent has been recieved with with the specified time and the sharedWorldView should notify
this worldView back, when all events for the time have been processed.
|
protected void |
objectAppeared(ILocalViewable obj,
long time)
Handles events for making the object visible.
|
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 |
objectDisappeared(ILocalViewable obj,
long time)
Handles events for making the object not visible.
|
protected void |
objectUpdated(ILocalWorldObject obj,
long time)
Must be called whenever an object was updated - raises correct event.
|
protected void |
sharedBatchFinished(long time)
This method is called when the SharedBatchFinishedEvent is recieved from the sharedWorldView, notifying us that
all sharedEvents for the specified time have been processed and it is safe to run logic on the time.
|
protected void |
stop()
Stops the world view.
|
void |
unlock()
Called after the logic has finished.
|
addVisible, getAllVisible, getAllVisible, getVisible, getVisible, objectUpdatedEvent, removeVisibleinnerNotify, notifyAfterPropagation, notifyImmediately, raiseEventaddEventListener, 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, lockTime, pause, prePause, preStop, removeEventListener, removeListener, removeLocalWorldObject, removeObjectListener, removeObjectListener, removeObjectListener, removeObjectListener, reset, resume, setCurrentTime, setInitialTime, start, unlockTimeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddEventListener, addObjectListener, addObjectListener, addObjectListener, addObjectListener, get, get, get, getAgentId, getAll, getAll, getCurrentTimeKey, getEventBus, getLocal, getSingle, isListening, isListening, isListening, isListening, isListening, isListening, lockTime, notifyImmediately, removeEventListener, removeListener, removeObjectListener, removeObjectListener, removeObjectListener, removeObjectListener, setCurrentTime, setInitialTime, unlockTimenotifyAfterPropagationgetComponentIdprotected Map<WorldObjectId,Set<DummyObjectEvent.EventType>> bufferedEvents
protected List<DummyObjectEvent> eventBuffer
public BatchAwareLocalWorldView(ComponentDependencies dependencies, ILifecycleBus bus, IAgentLogger logger, ISharedWorldView parentWorldView, ITeamedAgentId agentId)
protected abstract boolean isBatchBeginEvent(IWorldChangeEvent event)
event - protected abstract boolean isBatchEndEvent(IWorldChangeEvent event)
event - protected void notifySharedBegin(long time)
time - protected void objectCreated(ILocalWorldObject obj, long time)
EventDrivenLocalWorldViewMight be overridden to provide different behavior.
objectCreated in class VisionLocalWorldViewprotected void objectUpdated(ILocalWorldObject obj, long time)
EventDrivenLocalWorldViewMight be overridden to provide a mechanism that will forbid update of certain objects (like items that can't move).
objectUpdated in class EventDrivenLocalWorldViewprotected void objectDestroyed(ILocalWorldObject obj, long time)
EventDrivenLocalWorldViewMight be overriden to provide different behavior.
objectDestroyed in class VisionLocalWorldViewprotected void objectAppeared(ILocalViewable obj, long time)
VisionLocalWorldViewobjectAppeared in class VisionLocalWorldViewprotected void objectDisappeared(ILocalViewable obj, long time)
VisionLocalWorldViewobjectDisappeared in class VisionLocalWorldViewprotected abstract void disappearObject(WorldObjectId id, long time)
id - time - protected void bufferObjectEvent(WorldObjectId id, DummyObjectEvent.EventType eventType, long time)
id - eventType - time - protected void flushEvents()
protected void sharedBatchFinished(long time)
time - public boolean isLocked()
public void lock()
public void unlock()
public void notify(IWorldChangeEvent event)
IWorldChangeEventInputnotify in interface IWorldChangeEventInputnotify in class VisionLocalWorldViewprotected void stop()
AbstractLocalWorldViewIf you override this method, do not forget to call super.stop().
stop in class AbstractLocalWorldViewprotected void kill()
AbstractLocalWorldViewIf you override this method, do not forget to call super.stop().
kill in class AbstractLocalWorldViewCopyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.