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>>
- All Implemented Interfaces:
ObjectNamerOps<SimObject>
- Direct Known Subclasses:
DramaSimulation
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bzdev.scripting.ScriptingContext
ScriptingContext.BindingSwapper
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
GenericSimulation
(F factory) Constructor.protected
GenericSimulation
(F factory, double ticksPerUnitTime) Constructor give a time-unit specification.protected
GenericSimulation
(ScriptingContext parent, F factory) Constructor with a parent.protected
GenericSimulation
(ScriptingContext parent, F factory, double ticksPerUnitTime) Constructor with parent simulation and time unit specification. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
addObjectNamer
(ObjectNamerOps<SimObject> altNamer) Add an alternative object namer for use by getObject methods.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.void
configureFactory
(NamedObjectFactory factory, Object scriptObject) Configure a factory.boolean
Determine if the configureFactory method is supported.createAdapter
(Object object) Create a simulation listener based on a script object that implements an adapter.void
createFactories
(String pkg, Object scriptObject) Create multiple factories from a package in a single statement.createFactory
(Class clazz) Create a factory given a class.createFactory
(String className) Create a factory.createFactory
(String varName, String packageName, String className) Create a factory and store it in a scripting-language variable.findCommDomain
(A src, Set<CommDomainType> commDomainTypes, A dest) Determine if an actor can communicate with another actor.findCommDomain
(A src, Set<CommDomainType> commDomainTypes, A dest, D domain) Determine if an actor can communicate with another actor using a specific domain for communication.findCommDomain
(A src, Set<CommDomainType> commDomainTypes, G dest) Determine if an actor can communicate with a group.findCommDomain
(A src, Set<CommDomainType> commDomainTypes, G dest, D domain) Determine if an actor can communicate with a group using a specific domain.findCommDomain
(G src, Set<CommDomainType> commDomainTypes, A dest) Determine if a group can communicate with an actor using a specific domain.findCommDomain
(G src, Set<CommDomainType> commDomainTypes, A dest, D domain) Determine if a group can communicate with an actor using a specific domain.findCommDomain
(G src, Set<CommDomainType> commDomainTypes, G dest) Determine if a group can communicate with a group.findCommDomain
(G src, Set<CommDomainType> commDomainTypes, G dest, D domain) Determine if a group can communicate with a group using a specific domain.String[]
findMsgFrwdngInfo
(A src, Set<CommDomainType> commDomainTypes, A dest) Find the names of the forwarding tables (GenericMsgFrwdngInfo
) used by a call tofindCommDomain(GenericActor,Set,GenericActor)
.String[]
findMsgFrwdngInfo
(A src, Set<CommDomainType> commDomainTypes, A dest, D domain) Find the names of the forwarding tables (GenericMsgFrwdngInfo
) used by a call tofindCommDomain(GenericActor,Set,GenericActor,GenericDomain)
.String[]
findMsgFrwdngInfo
(A src, Set<CommDomainType> commDomainTypes, G dest) Find the names of the forwarding tables (GenericMsgFrwdngInfo
) used by a call tofindCommDomain(GenericActor,Set,GenericGroup)
.String[]
findMsgFrwdngInfo
(A src, Set<CommDomainType> commDomainTypes, G dest, D domain) Find the names of the forwarding tables (GenericMsgFrwdngInfo
) used by a call tofindCommDomain(GenericActor,Set,GenericGroup,GenericDomain)
.String[]
findMsgFrwdngInfo
(G src, Set<CommDomainType> commDomainTypes, A dest) Find the names of the forwarding tablesGenericMsgFrwdngInfo
) used by a call tofindCommDomain(GenericGroup,Set,GenericActor)
.String[]
findMsgFrwdngInfo
(G src, Set<CommDomainType> commDomainTypes, A dest, D domain) Find the names of the forwarding tables (GenericMsgFrwdngInfo
) used by a call tofindCommDomain(GenericGroup,Set,GenericActor,GenericDomain)
.String[]
findMsgFrwdngInfo
(G src, Set<CommDomainType> commDomainTypes, G dest) Find the names of the forwarding tables (GenericMsgFrwdngInfo
) used by a call tofindCommDomain(GenericGroup,Set,GenericGroup)
.String[]
findMsgFrwdngInfo
(G src, Set<CommDomainType> commDomainTypes, G dest, D domain) Find the names of the forwarding tables (GenericMsgFrwdngInfo
) used by a call tofindCommDomain(GenericGroup,Set,GenericGroup,GenericDomain)
.abstract A
Get an actor.Get actor names.Get condition names.abstract D
Get a domain.abstract DM
getDomainMember
(String name) Get a domain member.Get domain-member names.Get domain names.Get the simulation's factory.abstract G
Get a group.Get group names.Get the class common to all named objects.Get an object from the object namer's tables.<T> T
Get a named object with a particular name, provided that the object is a subclass of a specific class.Get all the object names from a object namer's tables.getObjectNames
(Class<?> clazz) Get some the object names from a object namer's tables.Get a collection of all the interned named objects assocated with an object namer.<T> Collection<T>
getObjects
(Class<T> clazz) Get a set of objects from a object namer's tables.getObjects
(String className) Get a collection of objects with a class constraint, expressed as a class name, from a object namer's tables.Methods inherited from class org.bzdev.devqsim.Simulation
addSimulationListener, advance, allowSetStackTraceMode, allowsSetStackTraceMode, allowsSetStackTraceModeTS, createMonitor, currentTicks, currentTime, currentTimeFrom, descheduleEvent, enableTracing, getCurrentTime, getCurrentTimePriority, getEventStackTrace, getNextEventInterval, getParent, getStackTraceMode, getTicks, getTicksCeil, getTicksFloor, getTicksPerUnitTime, getTime, isTracingEnabled, moreEventsScheduled, pauseTask, pauseTask, removeSimulationListener, rescheduleEvent, rescheduleEvent, run, run, run, scheduleCall, scheduleCall, scheduleCall, scheduleCall, scheduleCall, scheduleCall, scheduleCallObject, scheduleCallObject, scheduleCallPaused, scheduleCallPaused, scheduleCallWP, scheduleCallWP, scheduleEvent, scheduleEvent, scheduleInitCall, scheduleScript, scheduleScript, scheduleTask, scheduleTask, scheduleTask, scheduleTask, scheduleTask, scheduleTask, scheduleTaskObject, scheduleTaskObject, scheduleTaskScript, scheduleTaskScript, scheduleTaskWP, scheduleTaskWP, setStackTraceMode, setTraceOutput, startImmediateTask, startImmediateTask, unscheduledTaskThread, unscheduledTaskThread
Methods inherited from class org.bzdev.scripting.ScriptingContext
callScriptFunction, callScriptFunction, callScriptMethod, callScriptMethod, containsScriptObject, createBindings, createBindingSwapper, createScriptEngine, doGetDefaultBindings, doGetScriptEngine, doGetScriptLanguage, doScriptPrivileged, evalScript, evalScript, evalScript, evalScript, getErrorWriter, getNames, getReader, getScriptLanguage, getScriptObject, getWriter, hasScriptEngine, invokePrivateFunction, invokePrivateFunction, putScriptObject, setErrorWriter, setReader, setWriter, usingGraalVM
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.bzdev.obnaming.ObjectNamerOps
addObjectNamer, checkAltList, configureFactory, configureFactorySupported, createFactories, createFactory, createFactory, createFactory, getNamedObjectClass, getObject, getObject, getObjectNames, getObjectNames, getObjects, getObjects
-
Constructor Details
-
GenericSimulation
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
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
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 nonefactory
- the simulation factoryticksPerUnitTime
- the number of ticks per unit time
-
GenericSimulation
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 factoryticksPerUnitTime
- the number of ticks per unit time when time is provided as a double-precision number
-
-
Method Details
-
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
Get an actor.- Parameters:
name
- the actor's name- Returns:
- the actor; null if none with that name
-
getActorNames
Get actor names.- Returns:
- a set of the names of all actors interned in the simulation's name table
-
getConditionNames
Get condition names.- Returns:
- a set of the names of all conditions interned in the simulation's name table
-
getDomain
Get a domain.- Parameters:
name
- the domain's name- Returns:
- the domain; null if none with that name
-
getDomainNames
Get domain names.- Returns:
- a set of the names of all domains interned in the simulation's name table
-
getDomainMember
Get a domain member.- Parameters:
name
- the domain member's name- Returns:
- the domain member; null if none with that name
-
getDomainMemberNames
Get domain-member names.- Returns:
- a set of the names of all domain members interned in the simulation's name table
-
getGroup
Get a group.- Parameters:
name
- the group's name- Returns:
- the group; null if none with that name
-
getGroupNames
Get group names.- Returns:
- a set of the names of all groups interned in the simulation's name table
-
findMsgFrwdngInfo
Find the names of the forwarding tables (GenericMsgFrwdngInfo
) used by a call tofindCommDomain(GenericActor,Set,GenericActor)
. This method is intended primarily as a debugging aid. It can be used to determine which subclasses ofGenericMsgFrwdngInfo
to instrument.- Parameters:
src
- the actor that will send a messagecommDomainTypes
- the types of domains to allow; null if any domain is acceptabledest
- 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. OtherwiseGenericDomain.communicationMatch(GenericActor,GenericActor)
determines if communication is possible.- Parameters:
src
- the actor that will send a messagedest
- the actor that will receive a messagecommDomainTypes
- 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
Find the names of the forwarding tables (GenericMsgFrwdngInfo
) used by a call tofindCommDomain(GenericActor,Set,GenericActor,GenericDomain)
. This method is intended primarily as a debugging aid. It can be used to determine which subclasses ofGenericMsgFrwdngInfo
to instrument.- Parameters:
src
- the actor that will send a messagedest
- the actor that will receive a messagecommDomainTypes
- the types of domains to allow; null if any domain is acceptabledomain
- 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. OtherwiseGenericDomain.communicationMatch(GenericActor,GenericActor)
determines if communication is possible.- Parameters:
src
- the actor that will send a messagedest
- the actor that will receive a messagecommDomainTypes
- the types of domains to allow; null if any domain is acceptabledomain
- 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
Find the names of the forwarding tables (GenericMsgFrwdngInfo
) used by a call tofindCommDomain(GenericActor,Set,GenericGroup)
. This method is intended primarily as a debugging aid. It can be used to determine which subclasses ofGenericMsgFrwdngInfo
to instrument.- Parameters:
src
- the actor that will send a messagedest
- the group that will receive a messagecommDomainTypes
- 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. OtherwiseGenericDomain.communicationMatch(GenericActor,GenericGroup)
determines if communication is possible.- Parameters:
src
- the actor that will send a messagecommDomainTypes
- the types of domains to allow; null if any domain is acceptabledest
- 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
Find the names of the forwarding tables (GenericMsgFrwdngInfo
) used by a call tofindCommDomain(GenericActor,Set,GenericGroup,GenericDomain)
. This method is intended primarily as a debugging aid. It can be used to determine which subclasses ofGenericMsgFrwdngInfo
to instrument.- Parameters:
src
- the actor that will send a messagedest
- the group that will receive a messagecommDomainTypes
- the types of domains to allow; null if any domain is acceptabledomain
- 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. OtherwiseGenericDomain.communicationMatch(GenericActor,GenericGroup)
determines if communication is possible.- Parameters:
src
- the actor that will send a messagecommDomainTypes
- the types of domains to allow; null if any domain is acceptabledest
- the group that will receive a messagedomain
- 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
Find the names of the forwarding tables (GenericMsgFrwdngInfo
) used by a call tofindCommDomain(GenericGroup,Set,GenericGroup)
. This method is intended primarily as a debugging aid. It can be used to determine which subclasses ofGenericMsgFrwdngInfo
to instrument.- Parameters:
src
- the group that will send a messagecommDomainTypes
- the types of domains to allow; null if any domain is acceptabledest
- 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. OtherwiseGenericDomain.communicationMatch(GenericGroup,GenericGroup)
determines if communication is possible.- Parameters:
src
- the group that will send a messagecommDomainTypes
- the types of domains to allow; null if any domain is acceptabledest
- 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
Find the names of the forwarding tables (GenericMsgFrwdngInfo
) used by a call tofindCommDomain(GenericGroup,Set,GenericGroup,GenericDomain)
. This method is intended primarily as a debugging aid. It can be used to determine which subclasses ofGenericMsgFrwdngInfo
to instrument.- Parameters:
src
- the group that will send a messagedest
- the group that will receive a messagecommDomainTypes
- the types of domains to allow; null if any domain is acceptabledomain
- 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. OtherwiseGenericDomain.communicationMatch(GenericGroup,GenericGroup)
determines if communication is possible.- Parameters:
src
- the group that will send a messagecommDomainTypes
- the types of domains to allow; null if any domain is acceptabledest
- the group that will receive a messagedomain
- 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
Find the names of the forwarding tablesGenericMsgFrwdngInfo
) used by a call tofindCommDomain(GenericGroup,Set,GenericActor)
. This method is intended primarily as a debugging aid. It can be used to determine which subclasses ofGenericMsgFrwdngInfo
to instrument.- Parameters:
src
- the group that will send a messagecommDomainTypes
- the types of domains to allow; null if any domain is acceptabledest
- 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. OtherwiseGenericDomain.communicationMatch(GenericGroup,GenericActor)
determines if communication is possible.- Parameters:
src
- the group that will send a messagecommDomainTypes
- the types of domains to allow; null if any domain is acceptabledest
- 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
Find the names of the forwarding tables (GenericMsgFrwdngInfo
) used by a call tofindCommDomain(GenericGroup,Set,GenericActor,GenericDomain)
. This method is intended primarily as a debugging aid. It can be used to determine which subclasses ofGenericMsgFrwdngInfo
to instrument.- Parameters:
src
- the group that will send a messagecommDomainTypes
- the types of domains to allow; null if any domain is acceptabledest
- the actor that will receive a messagedomain
- 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. OtherwiseGenericDomain.communicationMatch(GenericGroup,GenericActor)
determines if communication is possible.- Parameters:
src
- the group that will send a messagecommDomainTypes
- the types of domains to allow; null if any domain is acceptabledest
- the actor that will receive a messagedomain
- 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
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 eventq
. 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 classSimObject
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.
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 methodscheduleCall
,scheduleScript
, orscheduleCallObject
, 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 methodscheduleCall
,scheduleScript
, orscheduleCallObject
, 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 namedcallableScript
,scheduleScript
,scheduleCall
,scheduleCallObject
, orbindCallable
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 namedcallableScript
,scheduleScript
,scheduleCall
,scheduleCallObject
, orbindCallable
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 methodscheduleTask
,scheduleTaskScript
,scheduleTaskObject
,scheduleTaskWP
,startImmediateTask
, orunscheduledTaskThread
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 methodscheduleTask
,scheduleTaskScript
,scheduleTaskObject
,scheduleTaskWP
,startImmediateTask
, orunscheduledTaskThread
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 methodscheduleTask
,scheduleTaskScript
,scheduleTaskObject
,scheduleTaskWP
,startImmediateTask
, orunscheduledTaskThread
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 methodscheduleTask
,scheduleTaskScript
,scheduleTaskObject
,scheduleTaskWP
,startImmediateTask
, orunscheduledTaskThread
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 methodunscheduledTaskThread
,scheduleTask
,scheduleTaskScript
,scheduleTaskObject
startImmediateTask
,runnableScript
,runnableObject
, orbindRunnable
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 methodunscheduledTaskThread
,scheduleTask
,scheduleTaskScript
,scheduleTaskObject
startImmediateTask
,runnableScript
,runnableObject
, orbindRunnable
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 methodunscheduledTaskThread
,scheduleTask
,scheduleTaskScript
,scheduleTaskObject
startImmediateTask
,runnableScript
,runnableObject
, orbindRunnable
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 methodunscheduledTaskThread
,scheduleTask
,scheduleTaskScript
,scheduleTaskObject
startImmediateTask
,runnableScript
,runnableObject
, orbindRunnable
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 classSimulation
- Parameters:
object
- the script object implementing the adapter- Returns:
- the adapter
- Throws:
IllegalArgumentException
-
getNamedObjectClass
Get the class common to all named objects.- Specified by:
getNamedObjectClass
in interfaceObjectNamerOps<SimObject>
- Returns:
- the class
-
addObjectNamer
Add an alternative object namer for use by getObject methods.- Specified by:
addObjectNamer
in interfaceObjectNamerOps<SimObject>
- Parameters:
altNamer
- the alternative object namer
-
checkAltList
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 interfaceObjectNamerOps<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
Get an object from the object namer's tables.- Specified by:
getObject
in interfaceObjectNamerOps<SimObject>
- Parameters:
name
- the name of the object- Returns:
- the object corresponding to the name provided
-
getObjectNames
Get all the object names from a object namer's tables.- Specified by:
getObjectNames
in interfaceObjectNamerOps<SimObject>
- Returns:
- a set containing the names of all objects interned in the object namer's tables
-
getObjectNames
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 interfaceObjectNamerOps<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
Get a named object with a particular name, provided that the object is a subclass of a specific class.- Specified by:
getObject
in interfaceObjectNamerOps<SimObject>
- Type Parameters:
T
- the type specified by the argument clazz- Parameters:
name
- the name of the objectclazz
- the class of the object- Returns:
- the object or null if the object cannot be found
-
getObjects
Get a collection of all the interned named objects assocated with an object namer.- Specified by:
getObjects
in interfaceObjectNamerOps<SimObject>
- Returns:
- an unmodifiable collection of the objects interned in the object namer's tables.
-
getObjects
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 interfaceObjectNamerOps<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
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 interfaceObjectNamerOps<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 interfaceObjectNamerOps<SimObject>
- Parameters:
factory
- the factory to be configuredscriptObject
- 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 objectIllegalArgumentException
- 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 subclassSimulation
and its subclasses (DramaSimulation
andAnimation2D
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,
will create two ECMAScript variables whose names are alf and gvf.a2d = new Animation2D(scripting, ...); a2d.createFactories("org.bzdev.anim2d", { alf: "AnimationLayer2DFactory", gvf: "GraphViewFactory" });
Unless explicitly implemented, this method will throw an UnsupportedOperationException.
- Specified by:
createFactories
in interfaceObjectNamerOps<SimObject>
- Parameters:
pkg
- the fully-qualified package namescriptObject
- 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 objectIllegalArgumentException
- 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 interfaceObjectNamerOps<SimObject>
- Parameters:
varName
- the name of a scripting-language variablepackageName
- 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 NamedObjectFactoryUnsupportedOperationException
- this object namer does not support scripting;
-
createFactory
Create a factory. The factory must have a single-argument constructor that takes its object namer as its argument.- Specified by:
createFactory
in interfaceObjectNamerOps<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
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 interfaceObjectNamerOps<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
-