multiple callbacks per function pointer / event

Discussion in 'C Programming' started by glennpierce, Feb 14, 2005.

  1. glennpierce

    glennpierce Guest

    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
    glennpierce, Feb 14, 2005
    #1
    1. Advertising

  2. glennpierce wrote:
    > 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, generic way.</heresy>

    > 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
    Ulrich Eckhardt, Feb 14, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?S01aX3N0YXRl?=

    Quick one - Is SESSION per browser instance or per IP Address?

    =?Utf-8?B?S01aX3N0YXRl?=, Apr 4, 2006, in forum: ASP .Net
    Replies:
    7
    Views:
    5,858
    gerry
    Apr 10, 2006
  2. Razvan
    Replies:
    1
    Views:
    398
    tony vee
    Sep 10, 2004
  3. Replies:
    5
    Views:
    2,517
  4. Replies:
    0
    Views:
    338
  5. chris brat
    Replies:
    1
    Views:
    613
    chris brat
    May 10, 2006
Loading...

Share This Page