1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
#include <windows.h>
#include "../include/observable.h"
#include <string>
#include <iostream>
using namespace std;
#define EVT0 "0"
#define EVT1 "1"
#define EVT2 "2"
#define EVT3 "3"
#define EVT4 "4"
#define EVT5 "5"
int main() {
Observable ob;
ob.on(EVT0, new delegate<void()>([&]() {
printf("%d, %d\n", 0, 0);
}));
ob.on(EVT1, new delegate<void(int)>([&](int a) {
printf("%d====\n", a);
}));
ob.on(EVT2, new delegate<void(int,int)>([&](int a, int b) {
printf("%d, %d\n", a, b);
}));
ob.on(EVT3, new delegate<void(string,string,int)>([&](string a, string b, int c) {
cout << a << " " << b << " " << c << endl;
}));
ob.on(EVT4, new delegate<void(string,string,string,int)>([&](string a, string b, string c, int d) {
cout << a << " " << b << " " << c << " " << d << endl;
}));
ob.on(EVT5, new delegate<void(string,string,string,int, int)>([&](string a, string b, string c, int d, int e) {
cout << a << " " << b << " " << c << " " << d << " " << e << endl;
}));
ob.fire(EVT0);
ob.fire(EVT1, 1111);
ob.fire(EVT2, 222, 2222);
ob.fire(EVT3, string("3333"),string("3333"), 3);
ob.fire(EVT4, string("44"), string("4"), string("4444"), 44);
ob.fire(EVT5, string("555"), string("555"), string("55"), 5, 5);
}
|