Package ptolemy.moml
Class ConvertToLazy
- java.lang.Object
-
- ptolemy.moml.ConvertToLazy
-
- All Implemented Interfaces:
ChangeListener
public class ConvertToLazy extends java.lang.Object implements ChangeListener
Read a specified MoML file and convert all instances of TypedCompositeActor that contain more than a specified number of entities to LazyTypedCompositeActor. The converted model's MoML is produced on standard out. To use this on the command line, invoke as follows:$PTII/bin/convertToLazy inputMoML.xml numberOfEntities > outputMoML.xmlorjava -classpath $PTII ptolemy.moml.ConvertToLazy inputMoML.xml numberOfEntities > outputMoML.xmlIf the numberOfEntities argument is not supplied, then it defaults to 100.- Since:
- Ptolemy II 8.0
- Version:
- $Id$
- Author:
- Edward A. Lee
- Pt.AcceptedRating:
- Red (eal)
- Pt.ProposedRating:
- Red (cxh)
-
-
Constructor Summary
Constructors Constructor Description ConvertToLazy(java.lang.String xmlFileName, int threshold)Parse the xml file and convert it.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidchangeExecuted(ChangeRequest change)React to a change request has been successfully executed by doing nothing.voidchangeFailed(ChangeRequest change, java.lang.Exception exception)React to a change request that has resulted in an exception.voidconvert(TypedCompositeActor actor, int threshold)Convert the model.intcount(TypedCompositeActor actor)Count the number of contained entities that have not already been made lazy.static voidmain(java.lang.String[] args)Create an instance of a model and convert it.
-
-
-
Constructor Detail
-
ConvertToLazy
public ConvertToLazy(java.lang.String xmlFileName, int threshold) throws java.lang.ThrowableParse the xml file and convert it.- Parameters:
xmlFileName- A string that refers to an MoML file that contains a Ptolemy II model. The string should be a relative pathname.threshold- The number of contained entities that a composite should have to be converted to a lazy composite.- Throws:
java.lang.Throwable- If there was a problem parsing or running the model.
-
-
Method Detail
-
changeExecuted
public void changeExecuted(ChangeRequest change)
React to a change request has been successfully executed by doing nothing. This method is called after a change request has been executed successfully. In this class, we do nothing.- Specified by:
changeExecutedin interfaceChangeListener- Parameters:
change- The change that has been executed, or null if the change was not done via a ChangeRequest.
-
changeFailed
public void changeFailed(ChangeRequest change, java.lang.Exception exception)
React to a change request that has resulted in an exception. This method is called after a change request was executed, but during the execution in an exception was thrown. This method throws a runtime exception with a description of the original exception.- Specified by:
changeFailedin interfaceChangeListener- Parameters:
change- The change that was attempted or null if the change was not done via a ChangeRequest.exception- The exception that resulted.
-
convert
public void convert(TypedCompositeActor actor, int threshold)
Convert the model.- Parameters:
actor- The model to convert.threshold- The threshold to use.
-
count
public int count(TypedCompositeActor actor)
Count the number of contained entities that have not already been made lazy.- Parameters:
actor- The actor to count.- Returns:
- The number of contained entities (deeply) that are not already lazy.
-
main
public static void main(java.lang.String[] args)
Create an instance of a model and convert it.- Parameters:
args- The command-line arguments providing the number of entities threshold and naming the .xml file to convert.
-
-