Package ptolemy.graph.sched
Class ScheduleElement
- java.lang.Object
-
- ptolemy.graph.sched.ScheduleElement
-
public abstract class ScheduleElement extends java.lang.Object
This is an abstract base class for a schedule element. Instances of the Schedule and Firing subclasses are used to construct a schedule(static or dynamic). A Schedule can be thought of as a structure that consists of an iteration count and a list of ScheduleElements. A ScheduleElement can be a Firing, or another Schedule. It is usually required that, all of the lowest-level ScheduleElements are Firings. It is up to the scheduler to enforce this, however. The Schedule class is a ScheduleElement that is a schedule. Schedules are created by schedule analyses. The Firing class is a ScheduleElement that contains a Firing element. Therefore, the top-level ScheduleElement must be an instance of Schedule, and all of the lowest-level elements must each be instances of Firing.This base class implements the getIterationCount() and setIterationCount() methods, which return and set the iteration count for this schedule element. A default value of 1 is used for the iteration count.
- Since:
- Ptolemy II 4.0
- Version:
- $Id$
- 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
,ScheduleAnalysis
- Pt.AcceptedRating:
- red (ssb)
- Pt.ProposedRating:
- red (shahrooz)
-
-
Field Summary
Fields Modifier and Type Field Description protected ScheduleElement
_parent
The parent schedule of this schedule.
-
Constructor Summary
Constructors Constructor Description ScheduleElement()
Construct a schedule element with an iteration count of 1 and with no parent schedule element.ScheduleElement(java.lang.Class firingElementClass)
Construct a schedule element with an iteration count of 1 and with no parent schedule element.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected long
_getVersion()
Return the current version of this schedule element.protected void
_incrementVersion()
Increment the version of this schedule element and if this schedule element has a parent schedule, increment the version of the parent schedule as well.java.lang.Class
firingElementClass()
Return the class type of the firing element in this class.abstract java.util.Iterator
firingElementIterator()
Return the firing element invocation sequence of the schedule in the form of a sequence of firing elements.abstract java.util.Iterator
firingIterator()
Return the firing invocation sequence in the form of a sequence of firings.int
getIterationCount()
Return the iteration count for this schedule.ScheduleElement
getParent()
Return the parent schedule element of this schedule element.void
setIterationCount(int count)
Set the iteration count for this schedule.void
setParent(ScheduleElement parent)
Set the parent schedule element of this schedule element to the specified schedule element.java.lang.String
toParenthesisString(java.util.Map nameMap)
Print the schedule in a nested parenthesis style and set character 'space' as the delimiter.abstract java.lang.String
toParenthesisString(java.util.Map nameMap, java.lang.String delimiter)
Print the schedule in a nested parenthesis style.
-
-
-
Field Detail
-
_parent
protected ScheduleElement _parent
The parent schedule of this schedule. Null means this schedule has no parent.
-
-
Constructor Detail
-
ScheduleElement
public ScheduleElement()
Construct a schedule element with an iteration count of 1 and with no parent schedule element. The constructor that takes a parameter should be used when constructing a schedule element that is contained by another schedule element.
-
ScheduleElement
public ScheduleElement(java.lang.Class firingElementClass)
Construct a schedule element with an iteration count of 1 and with no parent schedule element. The constructor that takes a parameter should be used when constructing a schedule element that is contained by another schedule element.- Parameters:
firingElementClass
- The class of the firing elements that will be added to this schedule.
-
-
Method Detail
-
firingElementClass
public java.lang.Class firingElementClass()
Return the class type of the firing element in this class. Only firing elements of this type are allowed set as a firing element of this ScheduleElement.- Returns:
- Return the class type of the firing element in this class.
-
firingElementIterator
public abstract 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.It must be implemented by the derived classes to provide the proper functionality.
- 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 abstract java.util.Iterator firingIterator()
Return the firing invocation sequence in the form of a sequence of firings. All of the lowest-level nodes should be an instance of Firing. Otherwise, the returned iterator will contain null elements.- Returns:
- An iterator over a sequence of firings.
-
getIterationCount
public int getIterationCount()
Return the iteration count for this schedule. This method returns the iteration count that was set by setIterationCount(). If setIterationCount() was never invoked, then a value of one is returned.- Returns:
- The iteration count for this schedule.
- See Also:
setIterationCount(int)
-
getParent
public ScheduleElement getParent()
Return the parent schedule element of this schedule element.- Returns:
- Return the parent schedule element of this schedule element.
- See Also:
setParent(ScheduleElement)
-
setIterationCount
public void setIterationCount(int count)
Set the iteration count for this schedule. The getIterationCount() method will return the value set by this method. If this method is not invoked, a default value of one will be used.- Parameters:
count
- The iteration count for this schedule.- See Also:
getIterationCount()
-
setParent
public void setParent(ScheduleElement parent)
Set the parent schedule element of this schedule element to the specified schedule element. If this schedule element is added to another schedule element (the parent), then the add() method of the parent will invoke this method. This association is used to notify the parent schedule element when changes are made to this schedule element.- Parameters:
parent
- The parent schedule element of this schedule element.- See Also:
getParent()
-
toParenthesisString
public java.lang.String toParenthesisString(java.util.Map nameMap)
Print the schedule in a nested parenthesis style and set character 'space' as the delimiter. Please seetoParenthesisString(Map, String)
.- Parameters:
nameMap
- The map from firing elements to their short names.- Returns:
- A nested parenthesis expression of the schedule.
-
toParenthesisString
public abstract java.lang.String toParenthesisString(java.util.Map nameMap, java.lang.String delimiter)
Print the schedule in a nested parenthesis style. There are an iteration count (an integer) and some (at least one) iterands within each pair of parentheses. The iterands could be either firings or another schedules. For each firing, it is the firing element (not the firing itself) that will be displayed. To prevent long and unfriendly print out, brief names of elements are required. Please reference the argumentnameMap
.- Parameters:
nameMap
- The map from firing elements to their short names.delimiter
- The delimiter between iterands.- Returns:
- A nested parenthesis expression of the schedule.
-
_getVersion
protected long _getVersion()
Return the current version of this schedule element. The version changes whenever a structural change is made to this schedule element.- Returns:
- The current version of this schedule element.
-
_incrementVersion
protected void _incrementVersion()
Increment the version of this schedule element and if this schedule element has a parent schedule, increment the version of the parent schedule as well. This method will therefore cause a version update to propagate up to all parent schedule elements. This method is called when a structure change is made to this schedule element, and is also called by the immediate children of this schedule element when they are modified.
-
-