ptolemy.actor.sched
Class Firing

java.lang.Object
  extended by ptolemy.actor.sched.ScheduleElement
      extended by ptolemy.actor.sched.Firing
Direct Known Subclasses:
PSDFScheduler.SymbolicFiring

public class Firing
extends ScheduleElement

This class is a schedule element that contains a reference to an actor and an iteration count. This class is used together with the Schedule class to construct a static schedule. This class is used to represent a single actor repeated some number of times, whereas Schedule is used for multi-actor schedules. The setActor() method is used to create the reference to an actor, and the setIterationCount() method to set the iteration count. The getActor() method will return a reference to this actor, and getIterationCount() will return the iteration count.

It is more efficient to use this class than to simply maintain a list of actors since actors will often fire multiple times consecutively. Using this class (and the Schedule data structure in general) greatly reduces the memory requirements of most large schedules.

Since:
Ptolemy II 1.0
Version:
$Id: Firing.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Brian K. Vogel, Steve Neuendorffer
See Also:
Schedule, ScheduleElement
Accepted Rating:
Yellow (chf)
Proposed Rating:
Green (vogel)

Nested Class Summary
private  class Firing.ActorIterator
          An adapter class for iterating over the elements of this schedule.
 
Field Summary
private  Actor _actor
           
private  java.util.List _firing
           
 
Fields inherited from class ptolemy.actor.sched.ScheduleElement
_parent
 
Constructor Summary
Firing()
          Construct a firing with a default iteration count equal to one and with no parent schedule.
Firing(Actor actor)
          Construct a firing with a actor, an iteration count equal to one and no parent schedule.
 
Method Summary
 java.util.Iterator actorIterator()
          Return the actor invocation sequence of the schedule in the form of a sequence of actors.
 java.util.Iterator firingIterator()
          Return the actor invocation sequence in the form of a sequence of firings.
 Actor getActor()
          Get the actor associated with this Firing.
 void setActor(Actor actor)
          Set the actor associated with this firing.
 java.lang.String toString()
          Output a string representation of this Firing.
 
Methods inherited from class ptolemy.actor.sched.ScheduleElement
_getVersion, _incrementVersion, getIterationCount, setIterationCount, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_actor

private Actor _actor

_firing

private java.util.List _firing
Constructor Detail

Firing

public Firing()
Construct a firing with a default iteration count equal to one and with no parent schedule.


Firing

public Firing(Actor actor)
Construct a firing with a actor, an iteration count equal to one and no parent schedule.

Parameters:
actor - The actor in the firing.
Method Detail

actorIterator

public java.util.Iterator actorIterator()
Return the actor invocation sequence of the schedule in the form of a sequence of actors. For a valid schedule, all of the lowest-level nodes should be an instance of Actor. If the schedule is not valid, then the returned iterator will contain null elements.

A runtime exception is thrown if the underlying schedule structure is modified while the iterator is active.

Specified by:
actorIterator in class ScheduleElement
Returns:
An iterator over a sequence of actors.
Throws:
java.util.ConcurrentModificationException - If the underlying schedule structure is modified while the iterator is active.

firingIterator

public java.util.Iterator firingIterator()
Return the actor invocation sequence in the form of a sequence of firings. Since this ScheduleElement is a Firing, which represents an Actor and an iteration count. the iterator returned will contain exactly one Firing (this Firing).

A runtime exception is thrown if the underlying schedule structure is modified while the iterator is active.

Specified by:
firingIterator in class ScheduleElement
Returns:
An iterator over a sequence of firings.
Throws:
java.util.ConcurrentModificationException - If the underlying schedule structure is modified while the iterator is active.

getActor

public Actor getActor()
Get the actor associated with this Firing. The setActor() method is used to set the actor that this method returns. If setActor() was never called, then throw an exception.

Returns:
The actor associated with this Firing.
See Also:
setActor(Actor)

setActor

public void setActor(Actor actor)
Set the actor associated with this firing. This actor will then be returned when the getActor() method is invoked. If this firing already contains a reference to an actor, then the reference will overwritten.

Parameters:
actor - The actor to associate with this firing.
See Also:
getActor()

toString

public java.lang.String toString()
Output a string representation of this Firing.

Overrides:
toString in class java.lang.Object