I'm having trouble setting up a TimerCallback instance. I need multiple
timers in my class, and as you can have only one instance of a Timer
per class instance, I figured I could use the template timer. I based
the code on what little I could find on the topic, on page 58 of
PowerPlant_X_Migration_Guide.pdf, on the IdleTimerCallback sample.
Header and implementation extracted below...
When I compile, I get the following warning:
-----------------
Warning : illegal implicit member pointer conversion
XDialogCapture.cp line 518 mTimerFreeDiskSpace.Install( this,
&DoTimerFreeDiskSpace, ::GetMainEventLoop(), 0.5, 3.0 );
-----------------
The choke seems to be on my DoTimerFreeDiskSpace function.
I've tried to cast it away without any luck. I also can't find any
suitable pragma to wrap the Install function just to shut the compiler
up.
The code builds and runs perfectly, tho. I just want to get rid of the
reported warning.
Any clues, please?
class DialogCapture : public Timer
{
public:
DialogCapture();
virtual ~DialogCapture();
private:
// Timers
TimerCallback<DialogCapture> mTimerFreeDiskSpace;
void DoTimerFreeDiskSpace();
};
//
---------------------------------------------------------------------------
// RunDialog
//
---------------------------------------------------------------------------
void
DialogCapture::RunDialog()
{
// Install Timer instance
mTimerFreeDiskSpace.Install( this, &DoTimerFreeDiskSpace,
::GetMainEventLoop(), 0.5, 3.0 );
}
//
---------------------------------------------------------------------------
// DoTimerFreeDiskSpace [private]
//
---------------------------------------------------------------------------
void
DialogCapture::DoTimerFreeDiskSpace()
{
}
Ben Artin - 03 Dec 2005 20:22 GMT
> Warning : illegal implicit member pointer conversion
> XDialogCapture.cp line 518 mTimerFreeDiskSpace.Install( this,
> &DoTimerFreeDiskSpace, ::GetMainEventLoop(), 0.5, 3.0 );
> class DialogCapture : public Timer
> {
[quoted text clipped - 5 lines]
>
> void DoTimerFreeDiskSpace();
The callback has to be a static member function, or it has to be outside of the
class.
hth
Ben

Signature
If this message helped you, consider buying an item
from my wish list: <http://artins.org/ben/wishlist>
I changed my name: <http://periodic-kingdom.org/People/NameChange.php>
Michael Hecht - 07 Dec 2005 04:54 GMT
> mTimerFreeDiskSpace.Install( this, &DoTimerFreeDiskSpace,
> ::GetMainEventLoop(), 0.5, 3.0 );
This is a C++ thing. You need to explicitly qualify the member function
name:
mTimerFreeDiskSpace.Install( this,
&DialogCapture::DoTimerFreeDiskSpace, ...
===============
--Michael