public class AtomicActor<T extends IOPort> extends ComponentEntity<T> implements Actor, FiringsRecordable
CompositeActor
,
IOPort
Green (neuendor) |
Green (eal) |
Entity.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
protected java.util.LinkedList<ActorFiringListener> |
_actorFiringListeners
The list of ActorFiringListeners registered with this object.
|
protected java.util.Set<Initializable> |
_initializables
List of objects whose (pre)initialize() and wrapup() methods
should be slaved to these.
|
protected boolean |
_notifyingActorFiring
Flag that is true if there are actor firing listeners.
|
protected boolean |
_stopRequested
Indicator that a stop has been requested by a call to stop().
|
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
COMPLETED, NOT_READY, STOP_ITERATING
Constructor and Description |
---|
AtomicActor()
Construct an actor in the default workspace with an empty string
as its name.
|
AtomicActor(CompositeEntity container,
java.lang.String name)
Create a new actor in the specified container with the specified
name.
|
AtomicActor(Workspace workspace)
Construct an actor in the specified workspace with an empty
string as a name.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_actorFiring(FiringEvent.FiringEventType type,
int multiplicity)
Send an actor firing event type to all actor firing listeners that
have registered with this actor.
|
protected void |
_actorFiring(FiringEvent event)
Send an actor firing event to all actor firing listeners that
have registered with this actor.
|
protected void |
_declareDelayDependency(IOPort input,
IOPort output,
double timeDelay)
Set the dependency between the input and output port to
represent a time delay with the specified value.
|
void |
addActorFiringListener(ActorFiringListener listener)
Append a listener to the current set of actor firing listeners.
|
void |
addInitializable(Initializable initializable)
Add the specified object to the set of objects whose
preinitialize(), initialize(), and wrapup()
methods should be invoked upon invocation of the corresponding
methods of this object.
|
java.lang.Object |
clone(Workspace workspace)
Clone this actor into the specified workspace.
|
void |
connectionsChanged(Port port)
Create new receivers if the port is
an input port and there is a director.
|
void |
createReceivers()
Create receivers for each input port.
|
void |
declareDelayDependency()
Set the dependency between all output ports and all input
ports of this actor.
|
void |
fire()
Do nothing.
|
CausalityInterface |
getCausalityInterface()
Return a causality interface for this actor.
|
Director |
getDirector()
Return the director responsible for the execution of this actor.
|
Director |
getExecutiveDirector()
Return the executive director (same as getDirector()).
|
Manager |
getManager()
Return the Manager responsible for execution of this actor,
if there is one.
|
void |
initialize()
Initialize this actor.
|
java.util.List<T> |
inputPortList()
List all the input ports.
|
boolean |
isFireFunctional()
Return true.
|
boolean |
isStrict()
Return true unless all input ports have non-empty default values.
|
int |
iterate(int count)
Invoke a specified number of iterations of the actor.
|
Port |
newPort(java.lang.String name)
Create a new IOPort with the specified name.
|
Receiver |
newReceiver()
Return a new receiver of a type compatible with the director.
|
java.util.List<T> |
outputPortList()
List the output ports.
|
boolean |
postfire()
Return true, unless stop() has been called, in which case,
return false.
|
boolean |
prefire()
Return true.
|
void |
preinitialize()
Create receivers and declare delay dependencies.
|
void |
pruneDependencies()
Deprecated.
There is no need to override this method anymore.
Just call removeDependency() in preinitialize().
|
void |
recordFiring(FiringEvent.FiringEventType type)
Record a firing event.
|
void |
removeActorFiringListener(ActorFiringListener listener)
Unregister an actor firing listener.
|
void |
removeDependency(IOPort input,
IOPort output)
Remove the dependency that the specified output port has,
by default, on the specified input port.
|
void |
removeInitializable(Initializable initializable)
Remove the specified object from the list of objects whose
preinitialize(), initialize(), and wrapup()
methods should be invoked upon invocation of the corresponding
methods of this object.
|
void |
setContainer(CompositeEntity container)
Override the base class to invalidate the schedule and
resolved types of the director.
|
void |
stop()
Request that execution of the current iteration stop as soon
as possible.
|
void |
stopFire()
Request that execution of the current iteration complete.
|
void |
terminate()
Terminate execution immediately.
|
void |
wrapup()
Do nothing except invoke the wrapup() methods of any
objects that have been registered with addInitializable().
|
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeChanged, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
description, getContainer, getDisplayName, getFullName, getName, getName, setName
getDerivedLevel, getDerivedList, propagateValue
protected java.util.LinkedList<ActorFiringListener> _actorFiringListeners
protected transient java.util.Set<Initializable> _initializables
protected boolean _notifyingActorFiring
protected boolean _stopRequested
public AtomicActor()
public AtomicActor(Workspace workspace)
workspace
- The workspace that will list this actor.public AtomicActor(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container.name
- The name of this actor within the container.IllegalActionException
- If the entity cannot be contained
by the proposed container (see the setContainer() method).NameDuplicationException
- If the name coincides with
an entity already in the container.public void addInitializable(Initializable initializable)
addInitializable
in interface Initializable
initializable
- The object whose methods should be invoked.removeInitializable(Initializable)
,
CompositeActor.addPiggyback(Executable)
public void addActorFiringListener(ActorFiringListener listener)
addActorFiringListener
in interface FiringsRecordable
listener
- The listener to which to send actor firing messages.removeActorFiringListener(ActorFiringListener)
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class ComponentEntity<T extends IOPort>
workspace
- The workspace for the cloned object.java.lang.CloneNotSupportedException
- If cloned ports cannot have
as their container the cloned entity (this should not occur), or
if one of the attributes cannot be cloned.NamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public void connectionsChanged(Port port)
connectionsChanged
in class Entity<T extends IOPort>
port
- The port that has connection changes.public void createReceivers() throws IllegalActionException
createReceivers
in interface Actor
IllegalActionException
- If any port throws it.createReceivers()
,
CompositeActor.createReceivers()
public void declareDelayDependency() throws IllegalActionException
TimeDelay
,
where output ports depend on input ports with a time delay,
this method should be overridden.
Protected method _declareDelayDependency() should be used
to declare dependency between input and output ports for
this actor.IllegalActionException
- Not thrown in this base
class, derived classes should throw this exception if the
delay dependency cannot be computed.getCausalityInterface()
,
_declareDelayDependency(IOPort, IOPort, double)
public void fire() throws IllegalActionException
fire
in interface Executable
IllegalActionException
- Not thrown in this base class.public CausalityInterface getCausalityInterface() throws IllegalActionException
DefaultCausalityInterface
with the dependency type given by the director, or with a BooleanDependency
if there is no director.
This declares that all output ports of the actor depend on all input
ports, unless the actor calls
removeDependency(IOPort, IOPort)
or
_declareDelayDependency(IOPort, IOPort, double)
.
If this is called multiple times, the same object is returned each
time unless the director has changed since the last call, in
which case a new object is returned.getCausalityInterface
in interface Actor
IllegalActionException
- Thrown in subclasses if causality
interface cannot be computed.public Director getDirector()
getDirector
in interface Actor
public Director getExecutiveDirector()
getExecutiveDirector
in interface Actor
public Manager getManager()
getManager
in interface Actor
public void initialize() throws IllegalActionException
initialize
in interface Initializable
IllegalActionException
- If a derived class throws it.public java.util.List<T> inputPortList()
inputPortList
in interface Actor
public boolean isFireFunctional()
isFireFunctional
in interface Executable
public boolean isStrict() throws IllegalActionException
isStrict
in interface Executable
IllegalActionException
- If the defaultValue expression
cannot be evaluated for an input port.public int iterate(int count) throws IllegalActionException
This base class method actually invokes prefire(), fire(), and postfire(), as described above, but a derived class may override the method to execute more efficient code.
iterate
in interface Executable
count
- The number of iterations to perform.IllegalActionException
- If iterating is not
permitted, or if prefire(), fire(), or postfire() throw it.public Port newPort(java.lang.String name) throws NameDuplicationException
newPort
in class ComponentEntity<T extends IOPort>
name
- The name for the new port.NameDuplicationException
- If this actor already has a port
with the specified name.Workspace.getWriteAccess()
public Receiver newReceiver() throws IllegalActionException
newReceiver
in interface Actor
IllegalActionException
- If there is no director.public java.util.List<T> outputPortList()
outputPortList
in interface Actor
public boolean postfire() throws IllegalActionException
postfire
in interface Executable
IllegalActionException
- Not thrown in this base class.public boolean prefire() throws IllegalActionException
prefire
in interface Executable
IllegalActionException
- Not thrown in this base class.public void preinitialize() throws IllegalActionException
preinitialize
in interface Initializable
IllegalActionException
- Not thrown in this base class.@Deprecated public void pruneDependencies() throws IllegalActionException
CausalityInterface
, at least for the simple
cases where output ports do not depend at all on input ports.IllegalActionException
- Thrown by subclasses if causality interface
cannot be computed.removeDependency(IOPort, IOPort)
,
getCausalityInterface()
public void recordFiring(FiringEvent.FiringEventType type)
recordFiring
in interface FiringsRecordable
type
- The firing event to be recorded.public void removeActorFiringListener(ActorFiringListener listener)
removeActorFiringListener
in interface FiringsRecordable
listener
- The listener to remove from the list of listeners
to which actor firing messages are sent.addActorFiringListener(ActorFiringListener)
public void removeDependency(IOPort input, IOPort output) throws IllegalActionException
CausalityInterface
for the simple cases where output ports do not depend
at all on certain input ports.
There should be one such call for each
input, output pair that does not have a dependency.input
- The input port.output
- The output port that does not depend on the
input port.IllegalActionException
- If causality interface
cannot be computed.getCausalityInterface()
public void removeInitializable(Initializable initializable)
removeInitializable
in interface Initializable
initializable
- The object whose methods should no longer be invoked.addInitializable(Initializable)
,
CompositeActor.removePiggyback(Executable)
public void setContainer(CompositeEntity container) throws IllegalActionException, NameDuplicationException
setContainer
in class ComponentEntity<T extends IOPort>
container
- The proposed container.IllegalActionException
- If the action would result in a
recursive containment structure, or if
this entity and container are not in the same workspace.NameDuplicationException
- If the container already has
an entity with the name of this entity.ComponentEntity.getContainer()
public void stop()
stop
in interface Executable
public void stopFire()
stopFire
in interface Executable
public void terminate()
terminate
in interface Executable
public void wrapup() throws IllegalActionException
wrapup
in interface Initializable
IllegalActionException
- Not thrown in this base class.protected final void _actorFiring(FiringEvent event)
event
- The event.protected final void _actorFiring(FiringEvent.FiringEventType type, int multiplicity)
type
- The type.multiplicity
- The multiplicity of the firing, that is,
the number of times the firing will occur or has occurred.protected void _declareDelayDependency(IOPort input, IOPort output, double timeDelay) throws IllegalActionException
CausalityInterface
for the cases where output ports depend on input ports with
a time delay.
If the time delay is 0.0, this method nonetheless
assumes that the output port does not (immediately) depend on
the input port (this amounts to a superdense time delay of
(0.0, 1)). There should be one such call for each
input, output pair that does not have a dependency.input
- The input port.output
- The output port with a time delay dependency on the
input port.timeDelay
- The time delay.IllegalActionException
- If causality interface
cannot be computed.getCausalityInterface()