1 static class Sigsig : DesObject 2 { 3 mixin DES; 4 Signal!string message; 5 Signal!float number; 6 7 Signal!(string,int) comp; 8 } 9 10 static class C1 : DesObject 11 { 12 mixin DES; 13 string[] messages; 14 void notSlot( float x ) { } 15 void listen( string msg ) { messages ~= msg; } 16 } 17 18 class C2 : C1 19 { 20 mixin DES; 21 float a; 22 void abcFunc12( float x ) { a = x + 3.15; } 23 } 24 25 class C3 : DesObject 26 { 27 mixin DES; 28 29 string str; 30 int num; 31 32 void cfunc( string s, int i ) 33 { 34 str = s; 35 num = i; 36 } 37 } 38 39 auto sigsig = new Sigsig; 40 auto client = new C2; 41 auto c3 = new C3; 42 43 sigsig.message.connect( client.newSlot( &(client.listen) ) ); 44 auto client_abcFunc12_slot = sigsig.number.connect( client.newSlot( &(client.abcFunc12) ) ); 45 46 sigsig.message( "hello" ); 47 48 assertEq( client.messages.length, 1 ); 49 assertEq( client.messages[0], "hello" ); 50 51 sigsig.number( 0 ); 52 53 assertEq( client.a, 3.15 ); 54 55 sigsig.number.disconnect( client_abcFunc12_slot ); 56 57 sigsig.number( 2 ); 58 assertEq( client.a, 3.15 ); 59 sigsig.number.connect( client_abcFunc12_slot ); 60 sigsig.number( 2 ); 61 assertEq( client.a, 5.15 ); 62 63 sigsig.comp.connect( c3.newSlot( &c3.cfunc ) ); 64 sigsig.comp( "okda", 13 ); 65 assertEq( c3.str, "okda" ); 66 assertEq( c3.num, 13 );