|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.graph.sched.ScheduleElement
ptolemy.graph.sched.Schedule
public class Schedule
This class represents a static schedule of firing elements invocation. An instance of this class is returned by the scheduler of a model to represent order of firing element firings in the model. A schedule consists of a list of schedule elements and the number of times the schedule should repeat (called the iteration count).
Each element of the schedule is represented by an instance of the ScheduleElement class. Each element may correspond to a number of firings of a single firing element (represented by the Firing class) or an entire sub-schedule (represented by a hierarchically contained instance of this class). This nesting allows this concise representation of looped schedules. The nesting can be arbitrarily deep, but must be a tree where the leaf nodes represent firings. It is up to the scheduler to enforce this requirement.
The add() and remove() methods are used to add or remove schedule elements. Only elements of type ScheduleElement (Schedule or Firing) may be added to the schedule list. The iteration count is set by the setIterationCount() method. If this method is not invoked, a default value of one will be used.
As an example, suppose that we have an SDF graph containing actors A, B, C, and D, with the firing order ABCBCBCDD. This firing order can be represented by a simple looped schedule. The code to create this schedule appears below.
Schedule S = new Schedule(); Firing S1 = new Firing(); Schedule S2 = new Schedule(); Firing S3 = new Firing(); S.add(S1); S.add(S2); S.add(S3); S1.setFiringElement(A); S2.setIterationCount(3); Firing S2_1 = new Firing(); Firing S2_2 = new Firing(); S2_1.setFiringElement(B); S2_2.setFiringElement(C); S2.add(S2_1); S2.add(S2_2); S3.setIterationCount(2); S3.setFiringElement(D);
Note that this implementation is not synchronized. It is therefore not safe for a thread to make modifications to the schedule structure while multiple threads are concurrently accessing the schedule.
Firing
,
Schedule
,
ScheduleElement
red (ssb) |
red (shahrooz) |
Nested Class Summary | |
---|---|
private class |
Schedule.FiringElementIterator
An adapter class for iterating over the firing elements of this schedule. |
private class |
Schedule.FiringIterator
An adapter class for iterating over the firings of this schedule. |
Field Summary | |
---|---|
private java.util.Map |
_firingElementFiringsMap
|
private java.util.List |
_firingInstancesList
|
protected java.util.List |
_schedule
The list of schedule elements contained by this schedule. |
private int |
_treeDepth
|
Fields inherited from class ptolemy.graph.sched.ScheduleElement |
---|
_parent |
Constructor Summary | |
---|---|
Schedule()
Construct a schedule with iteration count of one and an empty schedule list. |
|
Schedule(java.lang.Class firingElementClass)
Construct a schedule with iteration count of one and an empty schedule list. |
Method Summary | |
---|---|
private java.util.Map |
_getFiringElementFiringsMap()
|
private java.util.List |
_getFiringInstancesList()
|
void |
add(int index,
ScheduleElement element)
Insert the specified schedule element at the specified position in the schedule list. |
void |
add(ScheduleElement element)
Append the specified schedule element to the end of the schedule list. |
int |
appearanceCount(java.lang.Object firingElement)
The number of times the given firing element appears in the schedule. |
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 invocation sequence of this schedule in the form of a sequence of firings. |
java.util.List |
firings(java.lang.Object firingElement)
Get firings for the firing element. |
ScheduleElement |
get(int index)
Return the element at the specified position in the list. |
java.util.Iterator |
iterator()
Return an iterator over the schedule elements of this schedule. |
java.util.List |
lexicalOrder()
Get the lexical order of firing elements. |
int |
maxAppearanceCount()
Get the maximum appearance counts of all firing elements in the schedule. |
ScheduleElement |
remove(int index)
Remove the schedule element at the specified position in the schedule list. |
int |
size()
Return the number of elements in this list. |
java.lang.String |
toParenthesisString(java.util.Map nameMap,
java.lang.String delimiter)
Print the schedule in a nested parenthesis style. |
java.lang.String |
toString()
Output a string representation of this Schedule. |
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 |
---|
protected java.util.List _schedule
private int _treeDepth
private java.util.List _firingInstancesList
private java.util.Map _firingElementFiringsMap
Constructor Detail |
---|
public Schedule()
public Schedule(java.lang.Class firingElementClass)
ScheduleElement
s containing firing elements of the given class
would only be accepted as next elements for this schedule.
firingElementClass
- The given class type.Method Detail |
---|
public void add(ScheduleElement element)
element
- The schedule element to add.public void add(int index, ScheduleElement element)
index
- The index at which the specified element is to be
inserted.element
- The schedule element to add.
java.lang.IndexOutOfBoundsException
- If the specified index is out of
range (index < 0 || index > size()).public int appearanceCount(java.lang.Object firingElement)
firingElement
- The given firing element.
public java.util.Iterator firingElementIterator()
A runtime exception is thrown if the underlying schedule structure is modified while the iterator is active.
firingElementIterator
in class ScheduleElement
java.util.ConcurrentModificationException
- If the
underlying schedule structure is modified while the iterator
is active.public java.util.Iterator firingIterator()
A runtime exception is thrown if the underlying schedule structure is modified while the iterator is active.
Implementation note: This method is optimized to be memory efficient. It walks the schedule tree structure as the iterator methods are invoked.
firingIterator
in class ScheduleElement
java.util.ConcurrentModificationException
- If the
underlying schedule structure is modified while the iterator
is active.public java.util.List firings(java.lang.Object firingElement)
firingElement
- The given firing element.
public ScheduleElement get(int index)
index
- The index of the element to return.
public java.util.Iterator iterator()
A runtime exception is thrown if the underlying schedule structure is modified while the iterator is active.
java.util.ConcurrentModificationException
- If the
underlying schedule structure is modified while the iterator
is active.public java.util.List lexicalOrder()
java.lang.IllegalStateException
- If this is not a single
appearance schedule.public int maxAppearanceCount()
public ScheduleElement remove(int index)
index
- The index of the schedule element to be removed.
public int size()
public java.lang.String toParenthesisString(java.util.Map nameMap, java.lang.String delimiter)
ScheduleElement.toParenthesisString(Map, String)
.
toParenthesisString
in class ScheduleElement
nameMap
- The map from firing elements to their short names.delimiter
- The delimiter between iterands.
public java.lang.String toString()
toString
in class java.lang.Object
private java.util.List _getFiringInstancesList()
private java.util.Map _getFiringElementFiringsMap()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |