Jump to content
  • Advertisement
Sign in to follow this  
TechRogue

Pointers to member functions

This topic is 2165 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I can't seem to find any mention of whether this is possible or not. I'll explain what I'd like to do, and if it's impossible feel free to shoot me down. smile.png

I have a keyboard class registered as a singleton in my game engine, so my scripts can access key state. The interface looks like this:


if (keyboard.space)
{
doStuff();
}


The keys (in this case 'space') are implemented as property accessors that return a bool.

I'd like to be able to do something like this:


bind(@keyboard.space, @doStuff);


In this case, a pointer to the accessor would be stored along with a pointer to another function. The first function would be called continually, and if it returns true the second function would be called. I understand I could get the function object by declaration and set the calling object in the application, but I'd like to be able to do this with function and funcdefs.

So I'm wondering two things, actually:

  1. Are pointers to member functions possible currently, or might they be in a future version?
  2. If they are possible, would pointers to accessors need to be declared in long-form (@obj.get_prop), or would the short-form work as well (@obj.prop)?
Edited by Jake Albano

Share this post


Link to post
Share on other sites
Advertisement
It's currently not possible to take pointers to class methods.

I have plans to implement something similar to c# / java delegates, though I don't know when I'll get to it.

Getting the pointer to a virtual property accessor will have to be done through the full name, e.g get_property, otherwise it would not be known which method it is.

Regards,
Andreas

Share this post


Link to post
Share on other sites
Alright, thanks for the info. I look forward to the feature if/when you implement it, but it's not a blocking issue until then. :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!