aboutsummaryrefslogtreecommitdiff
path: root/src/tests/signals.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/signals.cpp')
-rw-r--r--src/tests/signals.cpp87
1 files changed, 87 insertions, 0 deletions
diff --git a/src/tests/signals.cpp b/src/tests/signals.cpp
new file mode 100644
index 0000000..b4b1363
--- /dev/null
+++ b/src/tests/signals.cpp
@@ -0,0 +1,87 @@
1#include <bu/signals.h>
2#include <bu/sio.h>
3
4using namespace Bu;
5
6class Thing
7{
8public:
9 Thing() :
10 iState( 82731 )
11 {
12 }
13
14 virtual ~Thing()
15 {
16 }
17
18 void fnc0()
19 {
20 sio << iState << ": void fnc0()" << sio.nl;
21 }
22
23 void fnc1( int a )
24 {
25 sio << iState << ": void fnc1( " << a << " )" << sio.nl;
26 }
27
28 void fnc2( int a, Bu::FString b )
29 {
30 sio << iState << ": void fnc2( " << a << ", \"" << b << "\" )" << sio.nl;
31 }
32
33 void fnc3( int a, Bu::FString b, double c )
34 {
35 sio << iState << ": void fnc3( " << a << ", \"" << b << "\", " << c << " )" << sio.nl;
36 }
37
38 void fnc4( int a, Bu::FString b, double c, char d )
39 {
40 sio << iState << ": void fnc4( " << a << ", \"" << b << "\", " << c << ", '" << d << "' )" << sio.nl;
41 }
42
43 void fnc5( int a, Bu::FString b, double c, char d, long e )
44 {
45 sio << iState << ": void fnc5( " << a << ", \"" << b << "\", " << c << ", '" << d << "', " << e << " )" << sio.nl;
46 }
47
48private:
49 int iState;
50};
51
52void pfnc0()
53{
54 sio << "This doesn't have state, it's pfnc0()!" << sio.nl;
55}
56
57void callit( Signal0<void> sig )
58{
59 sig();
60}
61
62int main()
63{
64 Thing t;
65
66 Signal0<void> cb0( slot( &t, &Thing::fnc0 ) );
67 cb0();
68
69 Signal1<void, int> cb1( slot( &t, &Thing::fnc1 ) );
70 cb1( 5 );
71
72 Signal2<void, int, Bu::FString> cb2( slot( &t, &Thing::fnc2 ) );
73 cb2( 5, "Hi there" );
74
75 Signal3<void, int, Bu::FString, double> cb3( slot( &t, &Thing::fnc3 ) );
76 cb3( 5, "Hi there", 12.85 );
77
78 Signal4<void, int, Bu::FString, double, char> cb4( slot( &t, &Thing::fnc4 ) );
79 cb4( 5, "Hi there", 12.85, 'z' );
80
81 Signal5<void, int, Bu::FString, double, char, long> cb5( slot( &t, &Thing::fnc5 ) );
82 cb5( 5, "Hi there", 12.85, 'z', 849 );
83
84// Signal1<int, int> cb1( slot( &t, &Thing::fnc1 ) );
85// sio << "Result: " << cb1( 5 ) << sio.nl;
86}
87