Class BasicModelEntity

java.lang.Object
org.simplesim.model.BasicModelEntity
All Implemented Interfaces:
ModelEntity
Direct Known Subclasses:
BasicAgent, BasicDomain

public abstract class BasicModelEntity extends Object implements ModelEntity
Provides basic functionality needed by all entities within the simulation model.

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
  • Constructor Details

    • BasicModelEntity

      public BasicModelEntity()
  • Method Details

    • addToDomain

      public void addToDomain(BasicDomain domain)
      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 interface ModelEntity
    • 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 interface ModelEntity
    • getName

      public String getName()
      Description copied from interface: ModelEntity
      Returns the name of this model entity

      Returns an empty string as default, may be overridden in derived classes.

      Specified by:
      getName in interface ModelEntity
      Returns:
      the name of this model entity, may be an empty string but not null
    • getFullName

      public String 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 interface ModelEntity
      Returns:
      the full name of this entity
    • getParent

      public Domain getParent()
      Description copied from interface: ModelEntity
      Returns the parent domain of this model entity.
      Specified by:
      getParent in interface ModelEntity
      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 interface ModelEntity
      Returns:
      the address
    • getInport

      public Port getInport()
      Specified by:
      getInport in interface ModelEntity
    • getOutport

      public Port getOutport()
      Specified by:
      getOutport in interface ModelEntity
    • getLevel

      public int getLevel()
      Description copied from interface: ModelEntity
      Returns the level of the entity within the model hierarchy

      Models 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 interface ModelEntity
      Returns:
      the level of this entity in the model hierarchy
    • equals

      public boolean equals(Object other)
      Tests if two model entities are equal (equality by identity)
      Overrides:
      equals in class Object
      Parameters:
      other - entity to be compared with this one
      Returns:
      true if both entities are identical
    • toString

      public String toString()
      Overrides:
      toString in class Object