Stateflow |
 |
Stateflow API Object Hierarchy
Stateflow API objects represent actual Stateflow objects in a Stateflow diagram. Like Stateflow objects, API objects contain or are contained by other Stateflow objects. For example, if state A contains state B in the Stateflow diagram editor, then the API object for state A contains the API object for state B. The following diagram depicts the Stateflow API hierarchy of objects:

Rules of containment define the Stateflow and Stateflow API object hierarchy. For example, charts can contain states but states cannot contain charts. The hierarchy of Stateflow objects, also known as the Stateflow data dictionary, is depicted in the section Overview of the Stateflow Machine. The Stateflow API hierarchy is very similar to the hierarchy of the Stateflow data dictionary and consists of the following layers of containment:
- Root -- The Root object (there is only one) serves as the parent of all Stateflow API objects. It is a placeholder at the top of the Stateflow API hierarchy to distinguish Stateflow tool objects from the objects of other tools such as Simulink and Handle Graphics. The Root object is automatically created when you load a model containing a Stateflow chart or call the method
sfnew
to create a new model with a Stateflow chart.
- Machine -- Objects of type Machine are accessed through Stateflow's Root object. Machine objects are equivalent to Simulink models from a Stateflow perspective. They can hold objects of type Chart, Data/Event, and Target.
- Chart -- Within any Machine object (model) there can be any number of chart objects. Within each object of type Chart, there can be objects of type State, Function, Box, Note, Data, Event, Transition, and Junction. These objects represent the components of a Stateflow chart.
- State/Function/Box -- Nested within objects of type State, Function, and Box, there can be further objects of type State, Function, Box, Note, Junction, Transition, Data, and Event. Levels of nesting can continue indefinitely.
The preceding figure also shows two object types that exist outside the Stateflow containment hierarchy, which are as follows:
- Editor -- Though not a part of the Stateflow containment hierarchy, an object of type Editor provides access to the purely graphical aspects of objects of type Chart. For each Chart object there is an Editor object that provides API access to the Chart object's diagram editor.
- Clipboard -- The Clipboard object has two methods,
copy
and pasteTo
, that use the clipboard as a convenient staging area to implement the operation of copy and paste functionality in the Stateflow API.
| What Is the Stateflow API? | | Getting a Handle on Stateflow API Objects |  |