1 module des.flow.sysevdata;
2 
3 /++ System event data
4 
5     passed to work element then before change thread state
6 
7     creation propertyes like `SysEvData.pause` and checking propertyes like
8     `SysEvData.isPause` generates from mixin with `slist`
9  +/
10 struct SysEvData
11 {
12     /// store name of system event
13     string msg;
14 
15     /// events names `[ "pause", "work", "stop" ]`
16     enum slist = [ "pause", "work", "stop" ];
17 
18     mixin( getStateListString(slist) );
19 
20     private static string getStateListString( in string[] list ) pure
21     {
22         import std..string;
23         string[] buf;
24 
25         foreach( state; list )
26         {
27             buf ~= format( `static @property SysEvData %1$s() { return SysEvData("%1$s"); }`, state );
28             buf ~= format( `@property bool is%s() { return msg == "%s"; }`, state.capitalize, state );
29         }
30 
31         return buf.join("\n");
32     }
33 }
34 
35 ///
36 unittest
37 {
38     auto ep = SysEvData.pause;
39     assert( ep.isPause );
40     auto ew = SysEvData.work;
41     assert( ew.isWork );
42 }