diff options
Diffstat (limited to 'src/tests/testSignals.cc')
-rw-r--r-- | src/tests/testSignals.cc | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/tests/testSignals.cc b/src/tests/testSignals.cc index f382289..75f046e 100644 --- a/src/tests/testSignals.cc +++ b/src/tests/testSignals.cc | |||
@@ -49,7 +49,7 @@ struct FunctionClass { | |||
49 | } | 49 | } |
50 | 50 | ||
51 | void takeIt( string& str ) { | 51 | void takeIt( string& str ) { |
52 | cout << "takeIt( " << str << ")" << endl; | 52 | cout << "FunctionClass::takeIt( " << str << " )" << endl; |
53 | } | 53 | } |
54 | 54 | ||
55 | void showMessage( int value, const string& message ) { | 55 | void showMessage( int value, const string& message ) { |
@@ -61,8 +61,21 @@ struct FunctionClass { | |||
61 | void threeArgs( int value, const string& str, double pi ) { | 61 | void threeArgs( int value, const string& str, double pi ) { |
62 | cout << "(" << value << "): " << str << ", pi = " << pi << endl; | 62 | cout << "(" << value << "): " << str << ", pi = " << pi << endl; |
63 | } | 63 | } |
64 | |||
64 | }; | 65 | }; |
65 | 66 | ||
67 | struct Printer { | ||
68 | void printInt(int value) { | ||
69 | cout << "Int:" << value << endl; | ||
70 | } | ||
71 | void printString(string value) { | ||
72 | cout << "string:" << value << endl; | ||
73 | } | ||
74 | void printFloat(float value) { | ||
75 | cout << "Float:" << value << endl; | ||
76 | } | ||
77 | }; | ||
78 | |||
66 | int main() { | 79 | int main() { |
67 | using FbTk::Signal; | 80 | using FbTk::Signal; |
68 | using FbTk::SignalTracker; | 81 | using FbTk::SignalTracker; |
@@ -161,4 +174,22 @@ int main() { | |||
161 | // subject notify its observers | 174 | // subject notify its observers |
162 | source.emit("hello world"); | 175 | source.emit("hello world"); |
163 | } | 176 | } |
177 | |||
178 | // Test argument selector | ||
179 | { | ||
180 | using namespace FbTk; | ||
181 | Signal<void, int, string, float> source; | ||
182 | |||
183 | Printer printer; | ||
184 | source.connect(MemFunSelectArg0(printer, &Printer::printInt)); | ||
185 | source.connect(MemFunSelectArg1(printer, &Printer::printString)); | ||
186 | source.connect(MemFunSelectArg2(printer, &Printer::printFloat)); | ||
187 | |||
188 | source.emit(10, "hello", 3.141592); | ||
189 | |||
190 | Signal<void, string, int> source2; | ||
191 | source2.connect(MemFunSelectArg0(printer, &Printer::printString)); | ||
192 | source2.connect(MemFunSelectArg1(printer, &Printer::printInt)); | ||
193 | source2.emit("world", 37); | ||
194 | } | ||
164 | } | 195 | } |