I've had a look through all the similar questions, but this specific scenario doesn't seem to have come up.
I have a plugin system, where the plugin receives the address of a function to call whenever it wants to insert a hook (which is a class function).
plugin:
struct plugin {
...
bool (*insert_hook)(hook_data*);
...
};
class:
class manager {
...
private:
InsertHook(hook_data *hook);
...
};
creation function in manager:
{
...
typedef bool (manager::*InsertHookFunc)(hook_data*);
InsertHookFunc hook_func = &manager::InsertHook;
// assigning this to the plugin ???
// C2440, cannot convert from 'hook_func' to 'bool (__cdecl *)(hook_data *)'
plugin->insert_hook = hook_func;
...
}
The manager calls into the plugin, and if the plugin needs to insert any hooks, it needs to call into the manager.
What is the correct method for doing it like this? I know it works normally (the plugin is passed a function pointer to the classes creation function to request a plugin object), but it just seems I can't assign it due to it being a class function (using a non-class function, this assignment works fine).
I could create a non-class function as a friend to the manager, but I'm sure this can be done directly, I just can't figure it out...