This document describes the TCallBack class.
The class encapsulates a pointer to a function which takes an argument of type TAny* and returns a TInt . The class is generally useful but, in particular, simplifies the programming interface of the CIdle and CPeriodic classes.
Given a suitable function and a pointer to an object, a callback is constructed simply. The function must be a non-member function or a static member of a class. For example:
or, as a static member of class X :
A callback function returns a true value to indicate whether it should be called again. This is important when used with the CIdle and CPeriodic classes. The following code fragment shows the programming paradigm:
Calling cb.CallBack() results in a call to the callback function Foo() passing it the pointer pX .
A common requirement is for the callback function to be a non-static member of a class. This can be implemented by passing, to the callback function, a pointer to an instance of the class of which it is a static member. For example:
where the static function Foo() is implemented as:
Typically, create an instance of class X and, at some later stage, create the callback:
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License v1.0.