A
Angus
Hi all
I am using a C style function which requires a 'callback' function to
be defined. This callback function is called whenever the interface
requests new data.
The function is a bit like this:
create_object(<callback_function>)
I have a class, MyClass, which uses this functionality so I have an
Init() member function which calls create_object.
However the callback_function cannot be a member function - so I make
it a static.
I want the callback_function to call a member function - but a static
function contains no this pointer - so what to do? At present I have
a global pointer to the class which gets initialised when I create the
class. But this does not seem like the most elegant design.
There seems no way to get the C callback to send eg an instance
variable where I could tuck a pointer to the class.
What is the most elegant way to solve this sort of problem?
Angus
I am using a C style function which requires a 'callback' function to
be defined. This callback function is called whenever the interface
requests new data.
The function is a bit like this:
create_object(<callback_function>)
I have a class, MyClass, which uses this functionality so I have an
Init() member function which calls create_object.
However the callback_function cannot be a member function - so I make
it a static.
I want the callback_function to call a member function - but a static
function contains no this pointer - so what to do? At present I have
a global pointer to the class which gets initialised when I create the
class. But this does not seem like the most elegant design.
There seems no way to get the C callback to send eg an instance
variable where I could tuck a pointer to the class.
What is the most elegant way to solve this sort of problem?
Angus