public interface SimEntityListener
SimEntitys.Copyright (C) 2005-2017 Jan de Jongh, TNO
This file is covered by the LICENSE file in the root of this project.
| Modifier and Type | Method and Description |
|---|---|
void |
notifyResetEntity(SimEntity entity)
Notification of a reset at a
SimEntity. |
void |
notifyStateChanged(double time,
SimEntity entity,
List<Map<SimEntitySimpleEventType.Member,SimEntityEvent>> notifications)
Notification of a (any) state change of a
SimEntity. |
void |
notifyUpdate(double time,
SimEntity entity)
Notification of an immediate upcoming update at an entity.
|
void notifyResetEntity(SimEntity entity)
SimEntity.
Convenience method as resets are also notified through notifyStateChanged(double, org.javades.jqueues.r5.entity.SimEntity, java.util.List<java.util.Map<org.javades.jqueues.r5.entity.SimEntitySimpleEventType.Member, org.javades.jqueues.r5.entity.SimEntityEvent>>).
entity - The entity that has been reset.void notifyUpdate(double time,
SimEntity entity)
An update at an entity is defined as a moment in time at which the entity is about to change its state. The main advantage of an update notification is that you can inspect the entity right before it is about to change. This leads the way to (efficiently) maintaining time-based statistics on the entity.
The general contract is that in between entity notifications, the entity does not change its state. However, what exactly comprises the state of the entity has to be documented by concrete implementations.
Update notifications through notifyUpdate(double, org.javades.jqueues.r5.entity.SimEntity)
and state-change notifications through notifyStateChanged(double, org.javades.jqueues.r5.entity.SimEntity, java.util.List<java.util.Map<org.javades.jqueues.r5.entity.SimEntitySimpleEventType.Member, org.javades.jqueues.r5.entity.SimEntityEvent>>) are dual in the sense that
the former are issued before and the latter after
a state change.
Preferably, update and state-change notifications for a single entity must always alternate. However, the only requirement in that sense is that a state-change notification must be immediately preceded with an update notification with equal time. It is therefore allowed to issue multiple update-notifications in between two consecutive state-change notifications, as long as the last update notification has the same time-stamp as the the second state-change notification.
Both types of notifications should not be sent upon construction of the entity;
there are no SimEntityListeners at this stage anyway.
However, upon an explicit reset of a SimEntity,
it is recommended to issue a notifyUpdate(double, org.javades.jqueues.r5.entity.SimEntity) before applying the reset.
Listeners must never directly or indirectly cause state changes on the reporting entity.
See SimEntity.doAfterNotifications(org.javades.jqueues.r5.entity.SimEntity.Action) for a workaround.
Beware that updates are never reported as state-change event.
time - The time of the update.entity - The entity that is about to be updated.notifyStateChanged(double, org.javades.jqueues.r5.entity.SimEntity, java.util.List<java.util.Map<org.javades.jqueues.r5.entity.SimEntitySimpleEventType.Member, org.javades.jqueues.r5.entity.SimEntityEvent>>),
AbstractSimQueueStatvoid notifyStateChanged(double time,
SimEntity entity,
List<Map<SimEntitySimpleEventType.Member,SimEntityEvent>> notifications)
SimEntity.
All state changes of a SimEntity must be reported through this method.
The notification is passed as a list of (SimEntitySimpleEventType.Member, SimEntityEvent) tuples,
the sub-notifications.
Note that the maps must have exactly one non-null key with non-null value.
All sub-notifications must have time set identical to the time passed as argument.
These sub-notifications form the sequence of (sub-)events describing the atomic state-change as a whole.
Beware that updates are never reported as state-change event.
time - The current time (the time of the state change).entity - The entity at which the state changed.notifications - The sequence of notifications of state-changes the combination of which led to the new state.notifyUpdate(double, org.javades.jqueues.r5.entity.SimEntity)Copyright © 2018. All rights reserved.