multiple callbacks per function pointer / event

G

glennpierce

Hi I was wondering if anyone knows of a method to achieve the creation of
events in c. currently I use a function pointer to call one callback.
However, I really need to map the function pointer or event to multiple
callback functions.

I thought I would have functions like NewSignal, EmitSignal and
ConnectSignal but I don't know how I would construct function pointers at
any other time other than compile time. Each new signal would require a
function pointer that takes different arguments, how would you marshall
data to these different function pointers?

I know there are toolkits like GTK that provide this but I am stuck using
Labwindows which provides very little and didn't want systems that provide
their own event loops etc.

Any help it much appreciated.


Thanks

Glenn
 
U

Ulrich Eckhardt

glennpierce said:
Hi I was wondering if anyone knows of a method to achieve the creation of
events in c. currently I use a function pointer to call one callback.
However, I really need to map the function pointer or event to multiple
callback functions.

Build a linked list or array of them.
I thought I would have functions like NewSignal, EmitSignal and
ConnectSignal but I don't know how I would construct function pointers at
any other time other than compile time. Each new signal would require a
function pointer that takes different arguments, how would you marshall
data to these different function pointers?

Yes, you will need different types for different functions. You might get
away with another level of indirection, using a function that knows the
real type and marshals arguments there and returnvalues back. Another tool
that might help is some macros. <heresy> There are several C++ libs that
do this in a type-safe said:
I know there are toolkits like GTK that provide this but I am stuck using
Labwindows which provides very little and didn't want systems that
provide their own event loops etc.

GTK is free software, you are even free to only use parts of it, provided
you accept its license.

Uli
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top