aboutsummaryrefslogtreecommitdiff
path: root/src/tests/signals.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-12-16 23:54:13 +0000
committerMike Buland <eichlan@xagasoft.com>2009-12-16 23:54:13 +0000
commit0d3d73fb0cacd3d1cf7eb8b83ba87f8b740b871a (patch)
tree5e5933681454276d73ceb4ce18719244c9c76d18 /src/tests/signals.cpp
parentafac5804b069e5eb76c799e9edd2eaeff0d99b94 (diff)
downloadlibbu++-0d3d73fb0cacd3d1cf7eb8b83ba87f8b740b871a.tar.gz
libbu++-0d3d73fb0cacd3d1cf7eb8b83ba87f8b740b871a.tar.bz2
libbu++-0d3d73fb0cacd3d1cf7eb8b83ba87f8b740b871a.tar.xz
libbu++-0d3d73fb0cacd3d1cf7eb8b83ba87f8b740b871a.zip
Signals is even safer and works even better. Also, OptParser is nearly done.
Now I just have to come up with a way to modify data that you already have, that sure was a nice feature of the old one, even if it was implemented in a silly way.
Diffstat (limited to '')
-rw-r--r--src/tests/signals.cpp39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/tests/signals.cpp b/src/tests/signals.cpp
index b4b1363..4af2b8e 100644
--- a/src/tests/signals.cpp
+++ b/src/tests/signals.cpp
@@ -51,7 +51,32 @@ private:
51 51
52void pfnc0() 52void pfnc0()
53{ 53{
54 sio << "This doesn't have state, it's pfnc0()!" << sio.nl; 54 sio << ": void pfnc0()" << sio.nl;
55}
56
57void pfnc1( int a )
58{
59 sio << ": void pfnc1( " << a << " )" << sio.nl;
60}
61
62void pfnc2( int a, Bu::FString b )
63{
64 sio << ": void pfnc2( " << a << ", \"" << b << "\" )" << sio.nl;
65}
66
67void pfnc3( int a, Bu::FString b, double c )
68{
69 sio << ": void pfnc3( " << a << ", \"" << b << "\", " << c << " )" << sio.nl;
70}
71
72void pfnc4( int a, Bu::FString b, double c, char d )
73{
74 sio << ": void pfnc4( " << a << ", \"" << b << "\", " << c << ", '" << d << "' )" << sio.nl;
75}
76
77void pfnc5( int a, Bu::FString b, double c, char d, long e )
78{
79 sio << ": void pfnc5( " << a << ", \"" << b << "\", " << c << ", '" << d << "', " << e << " )" << sio.nl;
55} 80}
56 81
57void callit( Signal0<void> sig ) 82void callit( Signal0<void> sig )
@@ -65,21 +90,33 @@ int main()
65 90
66 Signal0<void> cb0( slot( &t, &Thing::fnc0 ) ); 91 Signal0<void> cb0( slot( &t, &Thing::fnc0 ) );
67 cb0(); 92 cb0();
93 cb0 = slot( &pfnc0 );
94 cb0();
68 95
69 Signal1<void, int> cb1( slot( &t, &Thing::fnc1 ) ); 96 Signal1<void, int> cb1( slot( &t, &Thing::fnc1 ) );
70 cb1( 5 ); 97 cb1( 5 );
98 cb1 = slot( &pfnc1 );
99 cb1( 5 );
71 100
72 Signal2<void, int, Bu::FString> cb2( slot( &t, &Thing::fnc2 ) ); 101 Signal2<void, int, Bu::FString> cb2( slot( &t, &Thing::fnc2 ) );
73 cb2( 5, "Hi there" ); 102 cb2( 5, "Hi there" );
103 cb2 = slot( &pfnc2 );
104 cb2( 5, "Hi there" );
74 105
75 Signal3<void, int, Bu::FString, double> cb3( slot( &t, &Thing::fnc3 ) ); 106 Signal3<void, int, Bu::FString, double> cb3( slot( &t, &Thing::fnc3 ) );
76 cb3( 5, "Hi there", 12.85 ); 107 cb3( 5, "Hi there", 12.85 );
108 cb3 = slot( &pfnc3 );
109 cb3( 5, "Hi there", 12.85 );
77 110
78 Signal4<void, int, Bu::FString, double, char> cb4( slot( &t, &Thing::fnc4 ) ); 111 Signal4<void, int, Bu::FString, double, char> cb4( slot( &t, &Thing::fnc4 ) );
79 cb4( 5, "Hi there", 12.85, 'z' ); 112 cb4( 5, "Hi there", 12.85, 'z' );
113 cb4 = slot( &pfnc4 );
114 cb4( 5, "Hi there", 12.85, 'z' );
80 115
81 Signal5<void, int, Bu::FString, double, char, long> cb5( slot( &t, &Thing::fnc5 ) ); 116 Signal5<void, int, Bu::FString, double, char, long> cb5( slot( &t, &Thing::fnc5 ) );
82 cb5( 5, "Hi there", 12.85, 'z', 849 ); 117 cb5( 5, "Hi there", 12.85, 'z', 849 );
118 cb5 = slot( &pfnc5 );
119 cb5( 5, "Hi there", 12.85, 'z', 849 );
83 120
84// Signal1<int, int> cb1( slot( &t, &Thing::fnc1 ) ); 121// Signal1<int, int> cb1( slot( &t, &Thing::fnc1 ) );
85// sio << "Result: " << cb1( 5 ) << sio.nl; 122// sio << "Result: " << cb1( 5 ) << sio.nl;