#include #include "callback.h" typedef char* PCHAR; typedef int* PINT; class C2 { public: int call1 (int t) { return printf ("c2::callback (%d)\n", t); } int call2 (int t, char *str) { return printf ("c2::callback (%d, %s)\n", t, str); } int call3 (int t, char *str, int *rt) { return printf ( "c2::callback (%d, %s, %d)\n", t, str, *rt); } }; class C1 { public: virtual ~C1() {}; int function (int test) { int rt; char buffer[256]; sprintf (buffer, "string %d", test); rt = callback1 (test); rt += callback2 (test, buffer); rt += callback3 (test, buffer, &rt); return rt; } SIGNAL1 (int, callback1, int); SIGNAL2 (int, callback2, int, PCHAR); SIGNAL3 (int, callback3, int, PCHAR, PINT); }; int main (int argc, char *argv[]) { C1 c1; C2 c2; int rt; CallbackId id1; CallbackId id2; CallbackId id3; CONNECT1 (&id1, int, &c1, callback1, int, C2, &c2, call1); CONNECT2 (&id2, int, &c1, callback2, int, PCHAR, C2, &c2, call2); CONNECT3 (&id3, int, &c1, callback3, int, PCHAR, PINT, C2, &c2, call3); rt = c1.function (12345678); printf ("c1.function returns %d\n", rt); DISCONNECT1 (&c1, callback1, int, id1); DISCONNECT2 (&c1, callback2, int, PCHAR, id2); DISCONNECT3 (&c1, callback3, int, PCHAR, PINT, id3); }