uOttawaUniversity of Ottawa - Canadas University
list of dots

Umple User Manual    [Previous]   [Next]   

Loading

Extending a State

This operator is used to assign a state machine to a specific state inside another state machine, hence turning that state into a composite state. The syntax used for this operator is as follows:

srcStateMachineName as desStateMachineName.stateName.....stateName

This operator involves two state machines. The srcStateMachineName is found in the trait, and the desStateMachineName is found in the client. The state in the client can be simle or composite. This operator provides a practical mechanism to incrementally compose a state machine from various parts. For example, simple 'on/off' pairs of states with events to toggle between are fairly common and can be injected easily into destination states using this operator. If a composited state is extended with this operator, it will trigger our composition algorithm which. Furthermore, the operator can be used to bring more than one state machine inside a state.

In example 9, class C1 has state machine sm with two states s1 and s2. Trait T1 has state machine sm1. Class C1 needs to have state machine sm1 activated when it is in state s2. Class C1 achieves this by specifying the source state machine and destination state when it uses trait T1 (line 15).

Example

/*
	Example 9: showing how the operator "Extending a state by adding a state machine to it" works.
*/
trait T1{
  sm1{    
    m1{
      t2-> m2;
    }
    m2{
      t1-> m1;
    }
  }
}
class C1{
  isA T1<sm1 as sm.s2>;
  sm{
    s1{
      e2-> s2; 
    }
    s2{
      e1-> s1;
    }
  }
}

      

Load the above code into UmpleOnline