
Hello all:
I am working on a mud engine (essentially a game engine), and I had a quick question. I have an event class (yes, I know about boost::signal, but I don't want to go back and it doesn't support delayed events). I would like to set up my event class so that it will take a function object as it's callback, which allows someone extending the engine to add their own content to use global functions, member functions, lambdas, etc etc.
Now, here is my problem, and this may be more of a c++ question than a boost question; I'm not really sure.
Right now, every time an event gets called, I pass in the object that called it, as well as an EventArgs pointer. So an event callback function might look like this:
void OnMouseDown(Object* obj, OnMouseDownArgs* args);
Now, it might be useful to have the x and y coordenates where the OnMouseDown event was called, which means I end up doing something like:
class OnMouseDownArgs:public EventArgs
{
public:
int x, y;
};
which essentially means that for every new type of event, I have to declare an EventArgs class for that.
So here was my idea; I thought it would be kind of cool to do something like:
Event* OnMouseDown