Hello. Haven't been around for a while and I'm now getting back into my projects trying to solve some problems that have been plaguing me.
I'm trying to write a class that has a method very similar to the attach(), rise(), fall(), etc. methods available to many classes in the mbed library that allow interrupt handlers to be called for their various events. I would like to overload my method for each of the types of handlers, including member functions.
The overload for the static functions is easy to figure out, all we need to do is copy the pointer of an unknown void func(void) and then call it whenever the event is raised.
The overload for the member functions is a bit more tricky. Somehow we need to store the pointer to an unknown class and a pointer to a member function of that class (the user's class). Has anyone been able to do this? I would very much like some help for this part of my class.
I've seen "Feedback wanted from anyone using attach()/rise()/etc with pointer to member functions?" which was started by Simon, and it looks like he's found a better implementation. So far I haven't got ANY implementation, so I'll take any help I can get.
Also, I really don't want to mess with templating my class or turning it into a base class with virtual functions. I'm really looking for behavior similar to InterruptIn and Serial.
Thank you.
Hello. Haven't been around for a while and I'm now getting back into my projects trying to solve some problems that have been plaguing me.
I'm trying to write a class that has a method very similar to the attach(), rise(), fall(), etc. methods available to many classes in the mbed library that allow interrupt handlers to be called for their various events. I would like to overload my method for each of the types of handlers, including member functions.
The overload for the static functions is easy to figure out, all we need to do is copy the pointer of an unknown void func(void) and then call it whenever the event is raised.
The overload for the member functions is a bit more tricky. Somehow we need to store the pointer to an unknown class and a pointer to a member function of that class (the user's class). Has anyone been able to do this? I would very much like some help for this part of my class.
I've seen "Feedback wanted from anyone using attach()/rise()/etc with pointer to member functions?" which was started by Simon, and it looks like he's found a better implementation. So far I haven't got ANY implementation, so I'll take any help I can get.
Also, I really don't want to mess with templating my class or turning it into a base class with virtual functions. I'm really looking for behavior similar to InterruptIn and Serial.
Thank you.