Class GenericSimulation<S extends GenericSimulation<S,A,C,D,DM,F,G>,A extends GenericActor<S,A,C,D,DM,F,G>,C extends GenericCondition<S,A,C,D,DM,F,G>,D extends GenericDomain<S,A,C,D,DM,F,G>,DM extends GenericDomainMember<S,A,C,D,DM,F,G>,F extends GenericFactory<S,A,C,D,DM,F,G>,G extends GenericGroup<S,A,C,D,DM,F,G>>

java.lang.Object
org.bzdev.scripting.ScriptingContext
org.bzdev.devqsim.Simulation
org.bzdev.drama.generic.GenericSimulation<S,A,C,D,DM,F,G>
All Implemented Interfaces:
ObjectNamerOps<SimObject>
Direct Known Subclasses:
DramaSimulation

public abstract class GenericSimulation<S extends GenericSimulation<S,A,C,D,DM,F,G>,A extends GenericActor<S,A,C,D,DM,F,G>,C extends GenericCondition<S,A,C,D,DM,F,G>,D extends GenericDomain<S,A,C,D,DM,F,G>,DM extends GenericDomainMember<S,A,C,D,DM,F,G>,F extends GenericFactory<S,A,C,D,DM,F,G>,G extends GenericGroup<S,A,C,D,DM,F,G>> extends Simulation
Base simulation class. All flavors of simulations defined in other packages should be subclasses of this class. The simulation package includes a number of classes that make use of generics. The type parameters should match the specific classes used in each simulation's flavor, where this use of generics will be hidden.

The idea is that each flavor of simulation will want its own top-level classes, and access methods should declare their return values to match those classes, not the ones defined in the current package.

While GenericSimulation merely provides access methods to look up flavor-specific instances of GenericActor, GenericCondition, etc., its superclass Simulation provides the mechanisms necessary managing the event queue and mapping names to objects.

  • Constructor Details

    • GenericSimulation

      protected GenericSimulation(F factory)
      Constructor. A simulation's factory provides methods that construct objects with the subtype of the object determined at run time. It is needed in part because type parameters cannot be used as the names of constructors. Subclasses will provide the appropriate factory as a default, but may allow that choice to be overridden.
      Parameters:
      factory - the simulation factory
    • GenericSimulation

      protected GenericSimulation(ScriptingContext parent, F factory)
      Constructor with a parent. When a simulation has a parent, the simulation's scripting context is that of its parent unless specific methods are overridden. When a simulation has a parent that is also a Simulation, the parent's event queue is used instead of the simulation's event queue and time structures. This allows multiple simulations, perhaps with different flavors, to be combined into a single simulation. While the event queue and simulation time are shared, tables of simulation objects are not. Running any of the simulations sharing a parent will run all of them.

      A simulation's factory provides methods that construct objects with the subtype of the object determined at run time. It is needed in part because type parameters cannot be used as the names of constructors. Subclasses will provide the appropriate factory as a default, but may allow that choice to be overridden.

      Parameters:
      parent - the parent simulation.
      factory - the simulation factory
    • GenericSimulation

      protected GenericSimulation(ScriptingContext parent, F factory, double ticksPerUnitTime)
      Constructor with parent simulation and time unit specification. When a simulation has a parent, the simulation's scripting context is that of its parent unless specific methods are overridden. When a simulation has a parent that is also a Simulation, the parent's event queue is used instead of the simulation's event queue and time structures. This allows multiple simulations, perhaps with different flavors, to be combined into a single simulation. While the event queue and simulation time are shared, tables of simulation objects are not. Running any of the simulations sharing a parent will run all of them. In addition, the parent simulation will be added an an alternative object namer, so that the set/add methods of factory classes can find objects are defined by a parent simulation.

      A simulation's factory provides methods that construct objects with the subtype of the object determined at run time. It is needed in part because type parameters cannot be used as the names of constructors. Subclasses will provide the appropriate factory as a default, but may allow that choice to be overridden.

      Parameters:
      parent - the simulation's parent; null if there is none
      factory - the simulation factory
      ticksPerUnitTime - the number of ticks per unit time
    • GenericSimulation

      protected GenericSimulation(F factory, double ticksPerUnitTime)
      Constructor give a time-unit specification. A simulation's factory provides methods that construct objects with the subtype of the object determined at run time. It is needed in part because type parameters cannot be used as the names of constructors. Subclasses will provide the appropriate factory as a default, but may allow that choice to be overridden.
      Parameters:
      factory - the simulation factory
      ticksPerUnitTime - the number of ticks per unit time when time is provided as a double-precision number
  • Method Details

    • getFactory

      public F getFactory()
      Get the simulation's factory. A simulation's factory provides methods that construct objects with the subtype of the object determined at run time. It is needed in part because type parameters cannot be used as the names of constructors.
      Returns:
      the simulation's factory
    • getActor

      public abstract A getActor(String name)
      Get an actor.
      Parameters:
      name - the actor's name
      Returns:
      the actor; null if none with that name
    • getActorNames

      public Set<String> getActorNames()
      Get actor names.
      Returns:
      a set of the names of all actors interned in the simulation's name table
    • getConditionNames

      public Set<String> getConditionNames()
      Get condition names.
      Returns:
      a set of the names of all conditions interned in the simulation's name table
    • getDomain

      public abstract D getDomain(String name)
      Get a domain.
      Parameters:
      name - the domain's name
      Returns:
      the domain; null if none with that name
    • getDomainNames

      public Set<String> getDomainNames()
      Get domain names.
      Returns:
      a set of the names of all domains interned in the simulation's name table
    • getDomainMember

      public abstract DM getDomainMember(String name)
      Get a domain member.
      Parameters:
      name - the domain member's name
      Returns:
      the domain member; null if none with that name
    • getDomainMemberNames

      public Set<String> getDomainMemberNames()
      Get domain-member names.
      Returns:
      a set of the names of all domain members interned in the simulation's name table
    • getGroup

      public abstract G getGroup(String name)
      Get a group.
      Parameters:
      name - the group's name
      Returns:
      the group; null if none with that name
    • getGroupNames

      public Set<String> getGroupNames()
      Get group names.
      Returns:
      a set of the names of all groups interned in the simulation's name table
    • findMsgFrwdngInfo

      public String[] findMsgFrwdngInfo(A src, Set<CommDomainType> commDomainTypes, A dest)
      Find the names of the forwarding tables (GenericMsgFrwdngInfo) used by a call to findCommDomain(GenericActor,Set,GenericActor). This method is intended primarily as a debugging aid. It can be used to determine which subclasses of GenericMsgFrwdngInfo to instrument.
      Parameters:
      src - the actor that will send a message
      commDomainTypes - the types of domains to allow; null if any domain is acceptable
      dest - the actor that will receive a message
      Returns:
      the names of the MsgFrwdngInfo objects that would be used; null if a route is not possible
    • findCommDomain

      public CommDomainInfo<D> findCommDomain(A src, Set<CommDomainType> commDomainTypes, A dest) throws IllegalArgumentException
      Determine if an actor can communicate with another actor. The test is unidirectional. An argument provides the allowable communication-domain types and a search of the src actor's domains is used to find a suitable domain. If a communication-domain-type set is provided (i.e., it is not null) and a domain's communication-domain type is not a member of this set, that domain is skipped. If all domains are skipped, null is returned. Otherwise GenericDomain.communicationMatch(GenericActor,GenericActor) determines if communication is possible.
      Parameters:
      src - the actor that will send a message
      dest - the actor that will receive a message
      commDomainTypes - the types of domains to allow; null if any domain is acceptable
      Returns:
      an object specifying the domains needed to look up delays and message filters; null if there are none
      Throws:
      IllegalArgumentException - src's domain set contains domains at a given priority level that have incompatible modes.
    • findMsgFrwdngInfo

      public String[] findMsgFrwdngInfo(A src, Set<CommDomainType> commDomainTypes, A dest, D domain)
      Find the names of the forwarding tables (GenericMsgFrwdngInfo) used by a call to findCommDomain(GenericActor,Set,GenericActor,GenericDomain). This method is intended primarily as a debugging aid. It can be used to determine which subclasses of GenericMsgFrwdngInfo to instrument.
      Parameters:
      src - the actor that will send a message
      dest - the actor that will receive a message
      commDomainTypes - the types of domains to allow; null if any domain is acceptable
      domain - the domain that must allow communication
      Returns:
      the names of the GenericMsgFrwdngInfo objects that would be used; null if a route is not possible
    • findCommDomain

      public CommDomainInfo<D> findCommDomain(A src, Set<CommDomainType> commDomainTypes, A dest, D domain) throws IllegalArgumentException
      Determine if an actor can communicate with another actor using a specific domain for communication. The test is unidirectional. An argument provides the allowable communication-domain types and either the source actor or the destination actor must be a member of the specified domain. If a communication-domain-type set is provided (i.e., it is not null) and the specified domain's communication-domain type is not a member of this set, this method returns null. Otherwise GenericDomain.communicationMatch(GenericActor,GenericActor) determines if communication is possible.
      Parameters:
      src - the actor that will send a message
      dest - the actor that will receive a message
      commDomainTypes - the types of domains to allow; null if any domain is acceptable
      domain - the domain that must allow communication
      Returns:
      an object specifying the domains needed to look up delays and message filters; null if there are none
      Throws:
      IllegalArgumentException - src's domain set contains domains at a given priority level that have incompatible modes.
    • findMsgFrwdngInfo

      public String[] findMsgFrwdngInfo(A src, Set<CommDomainType> commDomainTypes, G dest)
      Find the names of the forwarding tables (GenericMsgFrwdngInfo) used by a call to findCommDomain(GenericActor,Set,GenericGroup). This method is intended primarily as a debugging aid. It can be used to determine which subclasses of GenericMsgFrwdngInfo to instrument.
      Parameters:
      src - the actor that will send a message
      dest - the group that will receive a message
      commDomainTypes - the types of domains to allow; null if any domain is acceptable
      Returns:
      the names of the GenericMsgFrwdngInfo objects that would be used; null if a route is not possible
    • findCommDomain

      public CommDomainInfo<D> findCommDomain(A src, Set<CommDomainType> commDomainTypes, G dest) throws IllegalArgumentException
      Determine if an actor can communicate with a group. The test is unidirectional. An argument provides the allowable communication-domain types and a search of the src actor's domains is used to find a suitable domain. If a communication-domain-type set is provided (i.e., it is not null) and a domain's communication-domain type is not a member The domain's method, that domain is skipped. If all domains are skipped, null is returned. Otherwise GenericDomain.communicationMatch(GenericActor,GenericGroup) determines if communication is possible.
      Parameters:
      src - the actor that will send a message
      commDomainTypes - the types of domains to allow; null if any domain is acceptable
      dest - the group that will receive a message
      Returns:
      an object specifying the domains needed to look up delays and message filters; null if there are none
      Throws:
      IllegalArgumentException - src's domain set contains domains at a given priority level that have incompatible modes.
    • findMsgFrwdngInfo

      public String[] findMsgFrwdngInfo(A src, Set<CommDomainType> commDomainTypes, G dest, D domain)
      Find the names of the forwarding tables (GenericMsgFrwdngInfo) used by a call to findCommDomain(GenericActor,Set,GenericGroup,GenericDomain). This method is intended primarily as a debugging aid. It can be used to determine which subclasses of GenericMsgFrwdngInfo to instrument.
      Parameters:
      src - the actor that will send a message
      dest - the group that will receive a message
      commDomainTypes - the types of domains to allow; null if any domain is acceptable
      domain - the domain to use for communication
      Returns:
      the names of the GenericMsgFrwdngInfo objects that would be used; null if a route is not possible
    • findCommDomain

      public CommDomainInfo<D> findCommDomain(A src, Set<CommDomainType> commDomainTypes, G dest, D domain) throws IllegalArgumentException
      Determine if an actor can communicate with a group using a specific domain. The test is unidirectional. An argument provides the allowable communication-domain types and either the source actor or the destination group must be a member of the specified domain. If a communication-domain-type set is provided (i.e., it is not null) and the specified domain's communication-domain type is not a member of this set, this method returns null. Otherwise GenericDomain.communicationMatch(GenericActor,GenericGroup) determines if communication is possible.
      Parameters:
      src - the actor that will send a message
      commDomainTypes - the types of domains to allow; null if any domain is acceptable
      dest - the group that will receive a message
      domain - the domain to use for communication
      Returns:
      an object specifying the domains needed to look up delays and message filters; null if there are none
      Throws:
      IllegalArgumentException - src's domain set contains domains at a given priority level that have incompatible modes.
    • findMsgFrwdngInfo

      public String[] findMsgFrwdngInfo(G src, Set<CommDomainType> commDomainTypes, G dest)
      Find the names of the forwarding tables (GenericMsgFrwdngInfo) used by a call to findCommDomain(GenericGroup,Set,GenericGroup). This method is intended primarily as a debugging aid. It can be used to determine which subclasses of GenericMsgFrwdngInfo to instrument.
      Parameters:
      src - the group that will send a message
      commDomainTypes - the types of domains to allow; null if any domain is acceptable
      dest - the group that will receive a message
      Returns:
      the names of the GenericMsgFrwdngInfo objects that would be used; null if a route is not possible
    • findCommDomain

      public CommDomainInfo<D> findCommDomain(G src, Set<CommDomainType> commDomainTypes, G dest) throws IllegalArgumentException
      Determine if a group can communicate with a group. The test is unidirectional. An argument provides the allowable communication-domain types and a search of the src group's domains is used to find a suitable domain. If a communication-domain-type set is provided (i.e., it is not null) and a domain's communication-domain type is not a member of this set, that domain is skipped. If all domains are skipped, null is returned. Otherwise GenericDomain.communicationMatch(GenericGroup,GenericGroup) determines if communication is possible.
      Parameters:
      src - the group that will send a message
      commDomainTypes - the types of domains to allow; null if any domain is acceptable
      dest - the group that will receive a message
      Returns:
      an object specifying the domains needed to look up delays and message filters; null if there are none
      Throws:
      IllegalArgumentException - src's domain set contains domains at a given priority level that have incompatible modes.
    • findMsgFrwdngInfo

      public String[] findMsgFrwdngInfo(G src, Set<CommDomainType> commDomainTypes, G dest, D domain)
      Find the names of the forwarding tables (GenericMsgFrwdngInfo) used by a call to findCommDomain(GenericGroup,Set,GenericGroup,GenericDomain). This method is intended primarily as a debugging aid. It can be used to determine which subclasses of GenericMsgFrwdngInfo to instrument.
      Parameters:
      src - the group that will send a message
      dest - the group that will receive a message
      commDomainTypes - the types of domains to allow; null if any domain is acceptable
      domain - the domain to use for communication
      Returns:
      the names of the GenericMsgFrwdngInfo objects that would be used; null if a route is not possible
    • findCommDomain

      public CommDomainInfo<D> findCommDomain(G src, Set<CommDomainType> commDomainTypes, G dest, D domain) throws IllegalArgumentException
      Determine if a group can communicate with a group using a specific domain. The test is unidirectional. An argument provides the allowable communication-domain types and either the source group or the destination group must be a member of the specified domain. If a communication-domain-type set is provided (i.e., it is not null) and the specified domain's communication-domain type is not a member of this set, this method returns null. Otherwise GenericDomain.communicationMatch(GenericGroup,GenericGroup) determines if communication is possible.
      Parameters:
      src - the group that will send a message
      commDomainTypes - the types of domains to allow; null if any domain is acceptable
      dest - the group that will receive a message
      domain - the domain to use for communication
      Returns:
      an object specifying the domains needed to look up delays and message filters; null if there are none
      Throws:
      IllegalArgumentException - src's domain set contains domains at a given priority level that have incompatible modes.
    • findMsgFrwdngInfo

      public String[] findMsgFrwdngInfo(G src, Set<CommDomainType> commDomainTypes, A dest)
      Find the names of the forwarding tables GenericMsgFrwdngInfo) used by a call to findCommDomain(GenericGroup,Set,GenericActor). This method is intended primarily as a debugging aid. It can be used to determine which subclasses of GenericMsgFrwdngInfo to instrument.
      Parameters:
      src - the group that will send a message
      commDomainTypes - the types of domains to allow; null if any domain is acceptable
      dest - the actor that will receive a message
      Returns:
      the names of the GenericMsgFrwdngInfo objects that would be used; null if a route is not possible
    • findCommDomain

      public CommDomainInfo<D> findCommDomain(G src, Set<CommDomainType> commDomainTypes, A dest) throws IllegalArgumentException
      Determine if a group can communicate with an actor using a specific domain. The test is unidirectional. An argument provides the allowable communication-domain types and a search of the src group's domains is used to find a suitable domain. If a communication-domain-type set is provided (i.e., it is not null) and a domain's communication-domain type is not a member of this set, that domain is skipped. If all domains are skipped, null is returned. Otherwise GenericDomain.communicationMatch(GenericGroup,GenericActor) determines if communication is possible.
      Parameters:
      src - the group that will send a message
      commDomainTypes - the types of domains to allow; null if any domain is acceptable
      dest - the group that will receive a message
      Returns:
      an object specifying the domains needed to look up delays and message filters; null if there are none
      Throws:
      IllegalArgumentException - src's domain set contains domains at a given priority level that have incompatible modes.
    • findMsgFrwdngInfo

      public String[] findMsgFrwdngInfo(G src, Set<CommDomainType> commDomainTypes, A dest, D domain)
      Find the names of the forwarding tables (GenericMsgFrwdngInfo) used by a call to findCommDomain(GenericGroup,Set,GenericActor,GenericDomain). This method is intended primarily as a debugging aid. It can be used to determine which subclasses of GenericMsgFrwdngInfo to instrument.
      Parameters:
      src - the group that will send a message
      commDomainTypes - the types of domains to allow; null if any domain is acceptable
      dest - the actor that will receive a message
      domain - the domain to use for communication
      Returns:
      the names of the GenericMsgFrwdngInfo objects that would be used; null if a route is not possible
    • findCommDomain

      public CommDomainInfo<D> findCommDomain(G src, Set<CommDomainType> commDomainTypes, A dest, D domain) throws IllegalArgumentException
      Determine if a group can communicate with an actor using a specific domain. The test is unidirectional. An argument provides the allowable communication-domain types and either the source group or the destination actor must be a member of the specified domain. If a communication-domain-type set is provided (i.e., it is not null) and the specified domain's communication-domain type is not a member of this set, this method returns null. Otherwise GenericDomain.communicationMatch(GenericGroup,GenericActor) determines if communication is possible.
      Parameters:
      src - the group that will send a message
      commDomainTypes - the types of domains to allow; null if any domain is acceptable
      dest - the actor that will receive a message
      domain - the domain to use for communication
      Returns:
      an object specifying the domains needed to look up delays and message filters; null if there are none
      Throws:
      IllegalArgumentException - src's domain set contains domains at a given priority level that have incompatible modes.
    • createAdapter

      public SimulationListener createAdapter(Object object) throws IllegalArgumentException
      Create a simulation listener based on a script object that implements an adapter. To respond to particular events, the script object must implement one or more methods. The arguments to these methods are:
      • sim. The simulation that scheduled the event
      • q. A task queue or server queue associated with the event.
      • server. A queue server associated with the event.
      • from. The message recipient that sent a message.
      • to. The message recipient that received a message.
      • msg An arbitrary object representing a message.
      • obj. A simulation object associated with the event by being responsible for generating it. Methods with this argument are the result of events generated by calling certain methods of the class SimObject or its subclasses.
      • tag. A tag labeling the event (for debugging/tracing purposes). The tag can be any object, but is typically a string or stack trace.
      Some methods use a subset of these arguments.

      The adapters GenericSimulation recognizes two methods defined for a script object in addition to those defined by DefaultSimAdapter. These methods are:

      • messageReceiveStart(sim,from,to.msg). A message is about to be received.
      • messageReceiveEnd(sim,from,to.msg). A message has just been received and handled.

      The methods that DefaultSimAdapter provides are:

      • simulationStart(sim). A simulation has started.
      • simulationStop(sim). A simulation has stopped (ended or paused).
      • callStart(sim,tag). A call scheduled by a simulation has started. The call was scheduled using a simulation's method scheduleCall, scheduleScript, or scheduleCallObject, and is not attributed to any particular simulation object. The argument representing the call must be either a Callable, a string providing a script to execute, or an object in a scripting language with a "call" method that has no arguments.
      • callEnd(sim, tag). A call scheduled by a simulation has ended. The call was scheduled using a simulation's method scheduleCall, scheduleScript, or scheduleCallObject, and is not attributed to any particular simulation object. The argument representing the call must be either a Callable, a string providing a script to execute, or an object in a scripting language with a "call" method that has no arguments.
      • callStartSimObject(sim,obj,tag). A call that a simulation object scheduled has started. The call was created using a simulation object's protected method named callableScript, scheduleScript, scheduleCall, scheduleCallObject, or bindCallable and is attributed to that simulation object.
      • callEndSimObject(sim,obj,tag). A call that an simulation object scheduled has ended. The call was created using a simulation object's protected method named callableScript, scheduleScript, scheduleCall, scheduleCallObject, or bindCallable and is attributed to that simulation object.
      • taskStart(sim,tag). A task scheduled by a simulation has started. The task was created by a simulation's public method scheduleTask, scheduleTaskScript, scheduleTaskObject, scheduleTaskWP, startImmediateTask, or unscheduledTaskThread and is not attributed to any particular simulation object. The argument representing a task must be either a Runnable, a string providing a script to execute, or an object in a scripting language with a "run" method that has no arguments.
      • taskPause(sim,tag). A task scheduled by a simulation has paused. The task was created by a simulation's public method scheduleTask, scheduleTaskScript, scheduleTaskObject, scheduleTaskWP, startImmediateTask, or unscheduledTaskThread and is not attributed to any particular simulation object. The argument representing a task must be either a Runnable, a string providing a script to execute, or an object in a scripting language with a "run" method that has no arguments.
      • taskResume(sim,tag). A task scheduled by a simulation has resumed. The task was created by a simulation's public method scheduleTask, scheduleTaskScript, scheduleTaskObject, scheduleTaskWP, startImmediateTask, or unscheduledTaskThread and is not attributed to any particular simulation object. The argument representing a task must be either a Runnable, a string providing a script to execute, or an object in a scripting language with a "run" method that has no arguments.
      • taskEnd(sim,tag). A task scheduled by a simulation has ended. The task was created by a simulation's public method scheduleTask, scheduleTaskScript, scheduleTaskObject, scheduleTaskWP, startImmediateTask, or unscheduledTaskThread and is not attributed to any particular simulation object. The argument representing a task must be either a Runnable, a string providing a script to execute, or an object in a scripting language with a "run" method that has no arguments.
      • taskStartSimObject(sim,obj,tag). A task that a simulation object scheduled has started. The task was created using a simulation object's protected method unscheduledTaskThread, scheduleTask, scheduleTaskScript, scheduleTaskObject startImmediateTask, runnableScript, runnableObject, or bindRunnable and is attributed to the simulation object.
      • taskPauseSimObject(sim,obj,tag). A task that a simulation object scheduled has paused. The task was created using a simulation object's protected method unscheduledTaskThread, scheduleTask, scheduleTaskScript, scheduleTaskObject startImmediateTask, runnableScript, runnableObject, or bindRunnable and is attributed to the simulation object.
      • taskResumeSimObject(sim,obj,tag). A task that a simulation object scheduled has resumed. The task was created using a simulation object's protected method unscheduledTaskThread, scheduleTask, scheduleTaskScript, scheduleTaskObject startImmediateTask, runnableScript, runnableObject, or bindRunnable and is attributed to the simulation object.
      • taskEndSimObject(sim,obj,tag). A task that a simulation object scheduled has ended. The task was created using a simulation object's protected method unscheduledTaskThread, scheduleTask, scheduleTaskScript, scheduleTaskObject startImmediateTask, runnableScript, runnableObject, or bindRunnable and is attributed to the simulation object.
      • taskQueueStart(sim,q). Processing of an element on a task queue of a simulation has started. Subsequent calls to other adapter methods may indicate details of that processing.
      • taskQueuePause(sim,q). Processing of an element on a task queue of a simulation has paused. Subsequent calls to other adapter methods may indicate details of that processing.
      • taskQueueResume(sim,q). Processing of an element on a task queue of a simulation has resumed. Subsequent calls to other adapter methods may indicate details of that processing.
      • taskQueueEnd(sim,q). Processing of an element on a task queue of a simulation has ended.
      • serverSelected(sim,q). A server was selected by a server queue in a simulation.
      • serverInteraction(sim,q,server,tag). A server associated with a server queue in a simulation begins interacting with the callable, runnable, or task it is serving. For this method, the task or callable is not associated with a simulation object.
      • serverCallable(sim,q,server,tag). A server associated with a server queue in a simulation finishes its interaction and a callable is run to continue the simulation. For this method, the task or callable is not associated with a simulation object.
      • serverRunnable(sim,q,server,tag). A server associated with a server queue in a simulation finishes its interaction and a Runnable starts execution to continue the simulation. For this method, the task or callable is not associated with a simulation object.
      • serverTask(sim,q,server,tag). A server associated with a server queue in a simulation finishes its interaction and the task that was queued resumes execution. For this method, the task or callable is not associated with a simulation object.
      • serverInteractionSimObject(sim,q,server,obj,tag). A server associated with a server queue in a simulation begins interacting with the object it is serving. The simulation object's protected method bindCallable or bindRunnable was used to create the Callable or Runnable and associate it with the simulation object, or a thread was created using the simulation object's unscheduledTaskThread or scheduleTask methods.
      • serverCallableSimObject(sim,q,server,obj,tag). A server associated with a server queue in a simulation finishes its interaction and a callable associated with a simulation object is run to continue the simulation. The simulation object's protected method bindCallable was used to create the Callable and associate it with the simulation object.
      • serverRunnableSimObject(sim,q,server,obj,tag). A server associated with a server queue in a simulation finishes its interaction and a Runnable associated with a simulation object starts execution to continue the simulation. The simulation object's protected method bindRunnable was used to create the Runnable and associate it with the simulation object.
      • serverTaskSimObject(sim,q,server,obj,tag). A server associated with a server queue in a simulation finishes its interaction and a Task associated with a simulation object resumes execution to continue the simulation. The task was associated with a simulation object when the task was created by creating the task by using one of the simulation object's unscheduledTaskThread or scheduleTask methods.
      Overrides:
      createAdapter in class Simulation
      Parameters:
      object - the script object implementing the adapter
      Returns:
      the adapter
      Throws:
      IllegalArgumentException
    • getNamedObjectClass

      public Class<SimObject> getNamedObjectClass()
      Get the class common to all named objects.
      Specified by:
      getNamedObjectClass in interface ObjectNamerOps<SimObject>
      Returns:
      the class
    • addObjectNamer

      public final void addObjectNamer(ObjectNamerOps<SimObject> altNamer)
      Add an alternative object namer for use by getObject methods.
      Specified by:
      addObjectNamer in interface ObjectNamerOps<SimObject>
      Parameters:
      altNamer - the alternative object namer
    • checkAltList

      public boolean checkAltList(ObjectNamerOps<SimObject> altNamer)
      Determine if the argument is equal to this object namer or a member of this object namer's object-namer list. This test is recursive. It is specified in this interface for technical reasons, and is not intended to be called otherwise. It is called by addObjectNamer to ensure that a depth-first search will terminate.
      Specified by:
      checkAltList in interface ObjectNamerOps<SimObject>
      Parameters:
      altNamer - the object namer to test
      Returns:
      true if he argument is equal to this object namer or a member of this object namer's object-namer list, tested recursively; false otherwise
    • getObject

      public SimObject getObject(String name)
      Get an object from the object namer's tables.
      Specified by:
      getObject in interface ObjectNamerOps<SimObject>
      Parameters:
      name - the name of the object
      Returns:
      the object corresponding to the name provided
    • getObjectNames

      public Set<String> getObjectNames()
      Get all the object names from a object namer's tables.
      Specified by:
      getObjectNames in interface ObjectNamerOps<SimObject>
      Returns:
      a set containing the names of all objects interned in the object namer's tables
    • getObjectNames

      public Set<String> getObjectNames(Class<?> clazz)
      Get some the object names from a object namer's tables. The object names are those of objects for which either their classes or one of their superclasses match the class passed as an argument.
      Specified by:
      getObjectNames in interface ObjectNamerOps<SimObject>
      Parameters:
      clazz - the class of the objects whose names are to appear in the set returned
      Returns:
      a set containing the names of all objects interned in the object namer's tables such that the class of that object or the class of a subclass of that object matches the clazz argument
    • getObject

      public <T> T getObject(String name, Class<T> clazz)
      Get a named object with a particular name, provided that the object is a subclass of a specific class.
      Specified by:
      getObject in interface ObjectNamerOps<SimObject>
      Type Parameters:
      T - the type specified by the argument clazz
      Parameters:
      name - the name of the object
      clazz - the class of the object
      Returns:
      the object or null if the object cannot be found
    • getObjects

      public Collection<SimObject> getObjects()
      Get a collection of all the interned named objects assocated with an object namer.
      Specified by:
      getObjects in interface ObjectNamerOps<SimObject>
      Returns:
      an unmodifiable collection of the objects interned in the object namer's tables.
    • getObjects

      public <T> Collection<T> getObjects(Class<T> clazz)
      Get a set of objects from a object namer's tables. The objects are those for which either their classes or one of their superclasses match the class passed as an argument.
      Specified by:
      getObjects in interface ObjectNamerOps<SimObject>
      Type Parameters:
      T - the type specified by the argument clazz
      Parameters:
      clazz - the class of the objects to get.
      Returns:
      a collection containing all interned objects whose class or one of its superclasses matches the class clazz passed as the method's argument
    • getObjects

      public Collection<SimObject> getObjects(String className)
      Get a collection of objects with a class constraint, expressed as a class name, from a object namer's tables. The objects are those for which either their classes or one of their superclasses match the class passed as an argument.

      Note: this method is provided because script engines do not provide a standard way of denoting a Java class (the class not an instance of it). The collection it returns is a collection of the common named object type. Except for scripting languages that do not provide compile-time type checking, one should nearly always use ObjectNamerOps.getObjects(Class).

      Parameters:
      className - the fully qualified class name of the objects to get.
      Returns:
      an unmodifiable collection containing all interned objects whose class or one of its superclasses matches the class clazz passed as the method's argument; an empty (and unmodifiable) collection if no objects can be found
    • configureFactorySupported

      public boolean configureFactorySupported()
      Determine if the configureFactory method is supported.
      Specified by:
      configureFactorySupported in interface ObjectNamerOps<SimObject>
      Returns:
      true if configure() is supported; false otherwise
    • configureFactory

      public void configureFactory(NamedObjectFactory factory, Object scriptObject) throws UnsupportedOperationException, IllegalArgumentException
      Configure a factory. This is an optional operation.
      Specified by:
      configureFactory in interface ObjectNamerOps<SimObject>
      Parameters:
      factory - the factory to be configured
      scriptObject - an object in a scripting language representing a specification for how this factory should be configured
      Throws:
      UnsupportedOperationException - the factory cannot be configured using a script object
      IllegalArgumentException - the scriptObject is ill formed
    • createFactories

      public void createFactories(String pkg, Object scriptObject) throws UnsupportedOperationException, IllegalArgumentException
      Description copied from interface: ObjectNamerOps
      Create multiple factories from a package in a single statement. The first argument is the fully qualified name of a package. The second is a scripting-language object specifying the individual factories and how they should be named. For the object-namer subclass Simulation and its subclasses (DramaSimulation and Animation2D are defined in this class library), the specification for ECMAScript is an ECMAScript objects whose property names are used as the name of a scripting language variable and whose value is a string containing the name of the factory class (excluding its package name, which is provided by the first argument). For example, with ECMAScript for one of these subclasses,
      
          a2d = new Animation2D(scripting, ...);
          a2d.createFactories("org.bzdev.anim2d", {
             alf: "AnimationLayer2DFactory",
             gvf: "GraphViewFactory"
          });
       
      will create two ECMAScript variables whose names are alf and gvf.

      Unless explicitly implemented, this method will throw an UnsupportedOperationException.

      Specified by:
      createFactories in interface ObjectNamerOps<SimObject>
      Parameters:
      pkg - the fully-qualified package name
      scriptObject - a scripting-language object specifying factories that should be created
      Throws:
      UnsupportedOperationException - this object namer does not support scripting or creating multiple factories specified by a scripting object
      IllegalArgumentException - an argument was not suitable for creating a factory.
    • createFactory

      public NamedObjectFactory createFactory(String varName, String packageName, String className) throws UnsupportedOperationException, IllegalArgumentException
      Create a factory and store it in a scripting-language variable. The factory must have a single-argument constructor that takes its object namer as its argument.

      This method is provided for convenience - to reduce the amount of typing when adding factories to a script. It returns the factory that was created in addition to storing it in a variable in case a user of this method tries to assign the value it returns.

      Specified by:
      createFactory in interface ObjectNamerOps<SimObject>
      Parameters:
      varName - the name of a scripting-language variable
      packageName - the name of the package (null or an empty string for the unnamed package)
      className - the class name of a factory, excluding the package name
      Returns:
      the factory that was created
      Throws:
      IllegalArgumentException - the factory is not listed in a META-INF/services/org.bzdev.NamedObjectFactory resource or the class name does not refer to subclass of NamedObjectFactory
      UnsupportedOperationException - this object namer does not support scripting;
    • createFactory

      public NamedObjectFactory createFactory(String className) throws IllegalArgumentException
      Create a factory. The factory must have a single-argument constructor that takes its object namer as its argument.
      Specified by:
      createFactory in interface ObjectNamerOps<SimObject>
      Parameters:
      className - the fully-qualified class name of a factory.
      Returns:
      a new factory
      Throws:
      IllegalArgumentException - the factory is not listed in a META-INF/services/org.bzdev.NamedObjectFactory resource or the class name does not refer to subclass of NamedObjectFactory
    • createFactory

      public NamedObjectFactory createFactory(Class clazz) throws IllegalArgumentException
      Create a factory given a class. The factory must have a single-argument constructor that takes its object namer as its argument.
      Specified by:
      createFactory in interface ObjectNamerOps<SimObject>
      Parameters:
      clazz - the factory's class
      Returns:
      a new factory
      Throws:
      IllegalArgumentException - the factory is not listed in a META-INF/services/org.bzdev.NamedObjectFactory resource or the class name does not refer to subclass of NamedObjectFactory