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, visibleMap
notifyEventsList, receiveEventProcessing, WORLDVIEW_DEPENDENCY
actLocalWorldObjects, 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, removeVisible
innerNotify, notifyAfterPropagation, notifyImmediately, raiseEvent
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, lockTime, pause, prePause, preStop, removeEventListener, removeListener, removeLocalWorldObject, removeObjectListener, removeObjectListener, removeObjectListener, removeObjectListener, reset, resume, setCurrentTime, setInitialTime, start, unlockTime
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addEventListener, 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, unlockTime
notifyAfterPropagation
getComponentId
protected 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)
EventDrivenLocalWorldView
Might be overridden to provide different behavior.
objectCreated
in class VisionLocalWorldView
protected void objectUpdated(ILocalWorldObject obj, long time)
EventDrivenLocalWorldView
Might be overridden to provide a mechanism that will forbid update of certain objects (like items that can't move).
objectUpdated
in class EventDrivenLocalWorldView
protected void objectDestroyed(ILocalWorldObject obj, long time)
EventDrivenLocalWorldView
Might be overriden to provide different behavior.
objectDestroyed
in class VisionLocalWorldView
protected void objectAppeared(ILocalViewable obj, long time)
VisionLocalWorldView
objectAppeared
in class VisionLocalWorldView
protected void objectDisappeared(ILocalViewable obj, long time)
VisionLocalWorldView
objectDisappeared
in class VisionLocalWorldView
protected 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)
IWorldChangeEventInput
notify
in interface IWorldChangeEventInput
notify
in class VisionLocalWorldView
protected void stop()
AbstractLocalWorldView
If you override this method, do not forget to call super.stop().
stop
in class AbstractLocalWorldView
protected void kill()
AbstractLocalWorldView
If you override this method, do not forget to call super.stop().
kill
in class AbstractLocalWorldView
Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.