next up previous contents index
Next: 8.2.4 Event Handling Up: 8.2 Transformation Strategies Previous: 8.2.2 State Properties   Contents   Index

8.2.3 History

History is the most complex part in the Java code, because it largely depends on the state of the model execution, and cannot be decided statically. The history attribute of a model class keeps track of its histories. Its value changes at run-time. The computation of this part is among the most expensive in the execution of a hierarchical model with history.

Method private void recordHistory(int top_state) records the history of state top_state (suppose it has a history or deep history defined in it) in the history attribute.

history is an array over the state IDs. history[i] for state i is an instance of class History, which has the following attributes:

Calls to the recordHistory method is statically coded in the changeState method. When a model leaves state i with a history in it, recordHistory(i) is called before the state changes.

When the model enters a state with a history recorded in the history attribute, the model dynamically decides the destination states with the history record, and changes the model to them. For normal history, this computation is complex.

Note that history recording is necessary even for non-history states. This is because the compiled model may be imported into such an importation state that it is a history state itself, or some of its superstates are deep history states. In those cases, history manipulation is required for every state.


next up previous contents index
Next: 8.2.4 Event Handling Up: 8.2 Transformation Strategies Previous: 8.2.2 State Properties   Contents   Index
Thomas Huining Feng 2004-04-28