Class BasicModelEntity
- All Implemented Interfaces:
ModelEntity
- Direct Known Subclasses:
BasicAgent
,BasicDomain
In more detail, that is:
- unit identification (by name or address)
- managing in- and outports
- utility methods (model level, naming,
toString
,equals
) - providing relevant exceptions
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.simplesim.model.ModelEntity
ModelEntity.PortConnectionException, ModelEntity.PortOperationException, ModelEntity.UniqueConstraintViolationException
-
Field Summary
Fields inherited from interface org.simplesim.model.ModelEntity
ROOT_LEVEL
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addToDomain
(BasicDomain domain) Adds this entity to a domain.boolean
Tests if two model entities are equal (equality by identity)int[]
Gets the entity address.Returns the full name of a model, concatenating the names of the parent entities.int
getLevel()
Returns the level of the entity within the model hierarchygetName()
Returns the name of this model entityReturns the parent domain of this model entity.void
Removes this entity form its parent domain.toString()
-
Constructor Details
-
BasicModelEntity
public BasicModelEntity()
-
-
Method Details
-
addToDomain
Description copied from interface:ModelEntity
Adds this entity to a domain.The domain becomes the parent of this entity.
Note: Connection management has to be done externally by the caller!
- Specified by:
addToDomain
in interfaceModelEntity
-
removeFromDomain
public void removeFromDomain()Description copied from interface:ModelEntity
Removes this entity form its parent domain.This method should never be called during a simulation cycle. If the entity could be removed from the domain, the entity's parent is set to null.
Note: Connection management has to be done externally by the caller.
- Specified by:
removeFromDomain
in interfaceModelEntity
-
getName
Description copied from interface:ModelEntity
Returns the name of this model entityReturns an empty string as default, may be overridden in derived classes.
- Specified by:
getName
in interfaceModelEntity
- Returns:
- the name of this model entity, may be an empty string but not null
-
getFullName
Description copied from interface:ModelEntity
Returns the full name of a model, concatenating the names of the parent entities.Example: If A and B are parents of this entity and this entity is named C, then the full name is A.B.C
- Specified by:
getFullName
in interfaceModelEntity
- Returns:
- the full name of this entity
-
getParent
Description copied from interface:ModelEntity
Returns the parent domain of this model entity.- Specified by:
getParent
in interfaceModelEntity
- Returns:
- the parent of this model
-
getAddress
public int[] getAddress()Description copied from interface:ModelEntity
Gets the entity address. Can be null.Note: The address of the root domain is
int[0]
. Another dimension is added per model level. The value of each dimension is the index within the corresponding level.- Specified by:
getAddress
in interfaceModelEntity
- Returns:
- the address
-
getInport
- Specified by:
getInport
in interfaceModelEntity
-
getOutport
- Specified by:
getOutport
in interfaceModelEntity
-
getLevel
public int getLevel()Description copied from interface:ModelEntity
Returns the level of the entity within the model hierarchyModels may be organized in a hierarchy, so that each entity resides in a definite domain level of the model tree. The level information is generated when the getLevel() method is called first. The level of the root node is always 0.
- Specified by:
getLevel
in interfaceModelEntity
- Returns:
- the level of this entity in the model hierarchy
-
equals
Tests if two model entities are equal (equality by identity) -
toString
-