Ask Your Question
0

Virtual service callbacks

asked 2012-09-21 10:32:57 -0500

Ammar gravatar image

Hello Community, This might seem a strange question. Is it possible to declare a service callback as virtual? Or more importantly can I override the service callback with another function if required? Thanks

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2012-09-22 03:23:08 -0500

Thomas gravatar image

You can use Boost.Bind to binds methods and use them as callbacks.

Callbacks can be changed at runtime (the API usually allows it but in the worst case you can destroy and recreate a publisher/subscriber) so it is not necessary to use complex dispatch methods. Of course, if it benefits code readability, using virtual methods is good too :)

edit flag offensive delete link more
0

answered 2012-09-21 15:11:30 -0500

ahendrix gravatar image

This should be possible, if you use member function pointers to virtual functions. See: http://www.codeproject.com/Articles/7150/Member-Function-Pointers-and-the-Fastest-Possible

Caveat: I haven't tried it myself; you probably want to play around with it a bit to make sure it'll work for your use case.

Templates may be a better choice.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-09-21 10:32:57 -0500

Seen: 152 times

Last updated: Sep 22 '12