Class EventSimEntity
- java.lang.Object
-
- de.uka.ipd.sdq.simulation.abstractsimengine.SimulationElement
-
- de.uka.ipd.sdq.simulation.abstractsimengine.AbstractSimEntityDelegator
-
- edu.kit.ipd.sdq.eventsim.entities.EventSimEntity
-
- All Implemented Interfaces:
de.uka.ipd.sdq.simulation.abstractsimengine.IEntity
- Direct Known Subclasses:
AbstractActiveResource
,Request
,SimPassiveResource
,SimulatedProcess
,User
public abstract class EventSimEntity extends de.uka.ipd.sdq.simulation.abstractsimengine.AbstractSimEntityDelegator
This is the abstract base class for all simulated entities. Entities have an ID and they notify registeredIEntityListener
s if requested. Both, the generation of IDs and the handling of listeners is provided by this class.IDs are unique with regard to the class of an entity. Thus, an entity that is an instance of
ClassA
can have a certain ID while at the same time an entity ofClassB
can have the same ID. IDs are generated as follows: 0, 1, ..., n.Listeners can register themselves by using the
addEntityListener()
method. The listeners can be notified by callingnotifyEnteredSystem()
ornotifyLeftSystem()
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
EventSimEntity.EntityLifecyclePhase
The lifecycle phase of an entity.
-
Constructor Summary
Constructors Constructor Description EventSimEntity(de.uka.ipd.sdq.simulation.abstractsimengine.ISimulationModel simulationModel, String namePrefix)
Constructs an entity with the specifiednamePrefix
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEntityListener(IEntityListener listener)
Adds a listener, which is to be informed whenever an entity is about to enter or has left the system.boolean
equals(Object obj)
long
getEntityId()
EventSimEntity.EntityLifecyclePhase
getLifecyclePhase()
Returns the current lifecycle phase of this entity.String
getName()
Returns the name of this entity.int
hashCode()
void
notifyEnteredSystem()
Notifies all registered listeners as well as theEventSimModel
that the entity is about to enter the system.void
notifyLeftSystem()
Notifies all registered listeners as well as theEventSimModel
that the entity has left the system.void
removeEntityListener(IEntityListener listener)
Removes a listener that has been registered before.static void
resetIdGenerator()
Resets the ID generators, so that the ID generated next is 0 for all entity classes.String
toString()
-
-
-
Constructor Detail
-
EventSimEntity
public EventSimEntity(de.uka.ipd.sdq.simulation.abstractsimengine.ISimulationModel simulationModel, String namePrefix)
Constructs an entity with the specifiednamePrefix
. The entity is created with an ID that is unique with regard to the entity's class.- Parameters:
model
- the modelnamePrefix
- the prefix of the entitie's name
-
-
Method Detail
-
notifyEnteredSystem
public void notifyEnteredSystem()
Notifies all registered listeners as well as theEventSimModel
that the entity is about to enter the system.
-
notifyLeftSystem
public void notifyLeftSystem()
Notifies all registered listeners as well as theEventSimModel
that the entity has left the system.
-
addEntityListener
public void addEntityListener(IEntityListener listener)
Adds a listener, which is to be informed whenever an entity is about to enter or has left the system.- Parameters:
listener
- the listener that is to be added
-
removeEntityListener
public void removeEntityListener(IEntityListener listener)
Removes a listener that has been registered before.- Parameters:
listener
- the listener that is to be removed
-
getEntityId
public long getEntityId()
-
getName
public String getName()
Returns the name of this entity. The name is thenamePrefix
passed to the constructor concatenated with the entity's ID.- Overrides:
getName
in classde.uka.ipd.sdq.simulation.abstractsimengine.SimulationElement
- Returns:
- a string representation of this entity
-
resetIdGenerator
public static void resetIdGenerator()
Resets the ID generators, so that the ID generated next is 0 for all entity classes.
-
getLifecyclePhase
public EventSimEntity.EntityLifecyclePhase getLifecyclePhase()
Returns the current lifecycle phase of this entity.- See Also:
EventSimEntity.EntityLifecyclePhase
-
-