c++ generic function pointer

Hi pros,

I am currently working on a small callback system with templates (I don’t want to use poco for it since I want the baseclass not to be OF only)
and I actually got things working so far.
I can register callBackfunctions from any object just likt with ofEvents. Things are bound to one type of Arguments though. Is there a possibility to make completely generic function Pointers in c++ that take any number of arguments and any kind of them? I actually doubt that this is easily posible but if there is any template pro out there that has an idea, let me know.

this is what I have so far (by the way, this is for an of addon Text console as you might know from quake or half-life :slight_smile:


I think boost can do that with a little work. Since Boost will become part of STL (Standard c++ library) it would maybe be a good idea to base OFs event system on that in the future?


I was thinking about a very similar system, but eventually ended up passing a string as the only argument and then parsing that string to get the things out that i want.
It’s not a solution that is very nice, but it is easy and fast to implement.
I am also just using a simple std::map<string,fPointer> in a single console class to register my functions, so it’s not as versatile.

Looking at your code, it seems like you’re using strings too but going for a more abstracted class based system…

What happens if multiple objects register the same function - will all of those functions get called?

What made you decide on this abstract system instead of just a console class? I would really like to know as I have been wondering about these things myself.
But I don’t want to sidetrack the thread. Sorry for the basic questions, some of the more structural c++ really scares me…


well basically for now I don’t know how the end structure will look like because I am really struggling with the event system and also what parts should be extendable, so I don’t know if it will stay abstracted from the main console class. I allready have a working thing based on strings but it’s kind of crappy to write extra functions for the console which basically just wrap existing ones. It would be so much cooler to be able to register almost any class so you don’t have to write a wrapper for every function which takes a certain argument only. Thats why I am currently looking into the possibilities of making generic function pointers. unfortunatelly c++ does not really make it easy :frowning: .

(sorry, this was in response to a different post, here: http://forum.openframeworks.cc/t/ofxengine,-revived/2307/7)