MainStm

Concrete class of state pattern named MainStm

Implement a different state from Child1Stm / Child2Stm. This class acts as a parent to Child1Stm and Child2Stm. The update method of this class may return the child class Child1Stm or Child2Stm as the next state. This class is also "previous state", which backs when Child1Stm or Child2Stm ends. Also, in this class, there is a gimmick that can record the transition of state using each handler and output the result.

Constructors

this
this()

Alias This

_stm

ditto

Members

Functions

initialize
void initialize()
name
string name()
toString
string toString()
update
TestFlow update()

Variables

_stm
StateTransitor!(State, Event) _stm;
message
Appender!string message;
onError
void delegate() onError;

Inherited Members

From BaseTestFlow

name
string name()

Examples

1 // Create a MainStm
2 auto stm = new MainStm;
3 
4 // Create a context class of TestFlow
5 auto stFlow = new Flow!TestFlow(stm);
6 
7 // Iterate until `stFlow.current` is null.
8 // This process advances the state transition in `stFlow`.
9 while (stFlow.current)
10 {
11 	stFlow.update();
12 }
13 
14 // Finally check the result
15 assert(stm.toString() == import("flow-result.txt"));

Meta