///////////////////////////////////////////////////////////////////////
// 1/21/2004
// these classes give a similar interface as the one in the Qt library
// An example of how to use the classes is shown below
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
// example
///////////////////////////////////////////////////////////////////////
#if 0
#include
#include "callback.h"
class C1
{
public:
int function (int test)
{
int rt;
char buffer[256];
sprintf (buffer, "%d", test);
rt = callback1 (test);
rt += callback2 (test, buffer);
rt += callback3 (test, buffer, &rt);
return rt;
}
SIGNAL1 (int, callback1, int);
SIGNAL2 (int, callback2, int, char *);
SIGNAL3 (int, callback3, int, char *, int *);
};
class C2
{
public:
int call1 (int t)
{
printf ("c2::callback (%d)\n", t);
return 0;
}
int call2 (int t, char *str)
{
printf ("c2::callback (%d, %s)\n", t, str);
return 0;
}
int call3 (int t, char *str, int *rt)
{
printf ("c2::callback (%d, %s, %d)\n", t, str, *rt);
return 0;
}
};
int main (int argc, char *argv[])
{
C1 c1;
C2 c2;
int rt;
int id1;
int id2;
int id3;
connect1 (&id1, int, &c1, callback, int, C2, &c2, call);
connect2 (&id2, int, &c1, callback1, int, char *, C2, &c2, call);
connect3 (&id3, int, &c1, callback1, int, char *, int *, C2, &c2, call);
rt = c1.function (12345678);
printf ("c1.function returns %d\n", rt);
}
#endif
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
// classes
///////////////////////////////////////////////////////////////////////
#ifndef CALLBACK_H
#define CALLBACK_H
#ifndef OK
#define OK 0
#endif
#ifndef OK
#define ERROR -1
#endif
typedef int CallbackId;
// RT - return type
// C1 - variable of source class
// signal - source function
// T1 - type of first parameter
// CT2 - type of destination class
// C2 - variable of destination class
// slot - destination function
#define DISCONNECT0(C1,signal,ID) (*C1).disconnect_##signal (ID)
#define CONNECT0(ID,RT,C1,signal,CT2,C2,slot) \
{ \
Callback0b
               (
geocities.com/capecanaveral/lab/8679)                   (
geocities.com/capecanaveral/lab)                   (
geocities.com/capecanaveral)