ptolemy.graph.sched
Class Firing

java.lang.Object
  extended by ptolemy.graph.sched.ScheduleElement
      extended by ptolemy.graph.sched.Firing

public class Firing
extends ScheduleElement

This class is a ScheduleElement that contains a reference to a firing element. The firingElement could be any Object. This class is used together with the Schedule class to construct a Schedule. The setFiringElement() method is used to create the reference to a firing element. The getFiringElement() method will return a reference to this firing element.

It is more efficient to use this class than to simply maintain a list of firing elements since firing elements will often firing 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 4.0
Version:
$Id: Firing.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Shahrooz Shahparnia, Mingyung Ko, University of Maryland at College Park based on a file by Brian K. Vogel, Steve Neuendorffer
See Also:
Firing, Schedule, ScheduleElement
Accepted Rating:
red (ssb)
Proposed Rating:
red (shahrooz)

Nested Class Summary
private  class Firing.FiringElementIterator
          An adapter class for iterating over the elements of this schedule.
 
Field Summary
private  java.util.List _firing
           
private  java.lang.Object _firingElement
           
 
Fields inherited from class ptolemy.graph.sched.ScheduleElement
_parent
 
Constructor Summary
Firing()
          Construct a firing with a default iteration count equal to one and with no parent schedule.
Firing(java.lang.Class firingElementClass)
          Construct a firing with a given firing element type, an iteration count equal to one and no parent schedule.
Firing(java.lang.Object firingElement)
          Construct a firing with a firingElement, an iteration count equal to one and no parent schedule.
 
Method Summary
 java.util.Iterator firingElementIterator()
          Return the firing element invocation sequence of the schedule in the form of a sequence of firing elements.
 java.util.Iterator firingIterator()
          Return the firing element invocation sequence in the form of a sequence of firings.
 java.lang.Object getFiringElement()
          Get the firing element associated with this Firing.
 void setFiringElement(java.lang.Object firingElement)
          Set the firing element associated with this firing.
 java.lang.String toParenthesisString(java.util.Map nameMap, java.lang.String delimiter)
          Print the firing in a parenthesis style.
 java.lang.String toString()
          Return a string representation of this Firing.
 
Methods inherited from class ptolemy.graph.sched.ScheduleElement
_getVersion, _incrementVersion, firingElementClass, getIterationCount, getParent, setIterationCount, setParent, toParenthesisString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_firingElement

private java.lang.Object _firingElement

_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(java.lang.Object firingElement)
Construct a firing with a firingElement, an iteration count equal to one and no parent schedule. A Firing constructed using this constructor, using the setFiringElement() method, will only accept firing elements with the same class type as the given firingElement, using the setFiringElement() method.

Parameters:
firingElement - The firing element in the firing.

Firing

public Firing(java.lang.Class firingElementClass)
Construct a firing with a given firing element type, an iteration count equal to one and no parent schedule. In a Firing constructed using this constructor, the setFiringElement() method, will only accept firing elements with the same given class type, using the setFiringElement() method.

Parameters:
firingElementClass - The class of the firing element in the firing.
Method Detail

firingElementIterator

public java.util.Iterator firingElementIterator()
Return the firing element invocation sequence of the schedule in the form of a sequence of firing elements. For a valid schedule, all of the lowest-level nodes should be an instance of Firing. 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:
firingElementIterator in class ScheduleElement
Returns:
An iterator over a sequence of firing elements.
Throws:
java.util.ConcurrentModificationException - If the underlying schedule structure is modified while the iterator is active.

firingIterator

public java.util.Iterator firingIterator()
Return the firing element invocation sequence in the form of a sequence of firings. Since this ScheduleElement is a Firing, 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.

getFiringElement

public java.lang.Object getFiringElement()
Get the firing element associated with this Firing. The setFiringElement() method is used to set the firing element that this method returns. If setFiringElement() was never called, then throw an exception.

Returns:
The actor associated with this Firing.
See Also:
setFiringElement(Object)

setFiringElement

public void setFiringElement(java.lang.Object firingElement)
Set the firing element associated with this firing. This firing element will then be returned when the getFiringElement() method is invoked. If this firing already contains a reference to a firing element, then the reference will overwritten.

Parameters:
firingElement - The firing element to associate with this firing.
See Also:
getFiringElement()

toParenthesisString

public java.lang.String toParenthesisString(java.util.Map nameMap,
                                            java.lang.String delimiter)
Print the firing in a parenthesis style.

Specified by:
toParenthesisString in class ScheduleElement
Parameters:
nameMap - A mapping from firing element to its short name.
delimiter - The delimiter between iteration count and iterand.
Returns:
The parenthesis expression for this firing.

toString

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

Overrides:
toString in class java.lang.Object
Returns:
Return a string representation of this Firing.