Implementing UML Statechart Diagrams
The UML Statechart Diagram is a powerful tool for specifying the dynamic behavior of reactive objects. Reactive objects are objects that respond to events sent from other objects. The response of the reactive object to an event depends on what state the object is in at the time that the event occurred. Implementing a simple Moore State Model, a state model with actions only on state entry is fairly easy. Commonly state models are stored in a two-dimensional array indexed by state and event. When an active object is in a state and receives an event, the execution framework gets the next state of the object by accesses the array element at the index of the current state and the received event. Then the execution framework executes the action associated with the next state.
The UML Statechart Diagram extends Moore state machines to offer many convenient modeling features such as composite states, exit actions, actions on transitions, and guards. These advanced features allow developers to model more complex behavior in a compact form. Although convenient for modeling, these features can be quite daunting when you consider how to implement them. This paper introduces a set of Standard C++ classes that implement UML Statechart Diagrams associated with UML classes.